File: Verbosity.hs

package info (click to toggle)
haskell-shake 0.13.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 888 kB
  • ctags: 127
  • sloc: haskell: 6,388; makefile: 35; ansic: 25; sh: 2
file content (39 lines) | stat: -rw-r--r-- 1,273 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

module Examples.Test.Verbosity(main) where

import Development.Shake
import Examples.Util


main = shaken test $ \args obj -> do
    want $ map obj args

    obj "in.txt" *> \out -> do
        a <- getVerbosity
        b <- withVerbosity Normal $ getVerbosity
        writeFile' out $ unwords $ map show [a,b]

    obj "out.txt" *> \out -> do
        x <- getVerbosity
        ys <- withVerbosity Loud $ do
            a <- getVerbosity
            need [obj "in.txt"] -- make sure the inherited verbosity does not get passed along
            b <- getVerbosity
            c <- quietly getVerbosity
            d <- fmap shakeVerbosity getShakeOptions
            return [a,b,c,d]
        z <- getVerbosity
        writeFile' out $ unwords $ map show $ [x] ++ ys ++ [z]

test build obj = do
    build ["out.txt","--clean"]
    assertContents (obj "in.txt") "Normal Normal"
    assertContents (obj "out.txt") "Normal Loud Loud Quiet Normal Normal"

    build ["out.txt","--clean","--verbose"]
    assertContents (obj "in.txt") "Loud Normal"
    assertContents (obj "out.txt") "Loud Loud Loud Quiet Loud Loud"

    build ["out.txt","--clean","--quiet"]
    assertContents (obj "in.txt") "Quiet Normal"
    assertContents (obj "out.txt") "Quiet Loud Loud Quiet Quiet Quiet"