File: Assume.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 (45 lines) | stat: -rw-r--r-- 1,052 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
40
41
42
43
44
45

module Examples.Test.Assume(main) where

import Development.Shake
import Examples.Util
import Control.Monad
import Development.Shake.FilePath


main = shaken test $ \args obj -> do
    want $ map obj args
    obj "*.out" *> \out -> do
        cs <- mapM (readFile' . obj . (:".src")) $ takeBaseName out
        writeFile' out $ concat cs


test build obj = do
    let set file c = writeFile (obj $ file : ".src") [c]
    let ask file c = do src <- readFile (obj $ file ++ ".out"); src === c

    forM_ ['a'..'f'] $ \c -> set c c
    build ["--sleep","abc.out"]
    ask "abc" "abc"

    set 'b' 'd'
    build ["--sleep","abc.out"]
    ask "abc" "adc"
    set 'b' 'p'
    build ["--sleep","abc.out","--touch"]
    build ["abc.out"]
    ask "abc" "adc"
    set 'c' 'z'
    build ["--sleep","abc.out"]
    ask "abc" "apz"

    build ["bc.out","c.out"]
    ask "bc" "pz"
    set 'b' 'r'
    set 'c' 'n'
    build ["--sleep","abc.out","--touch"]
    ask "abc" "apz"
    build ["ab.out","--always-make"]
    ask "ab" "ar"
    build ["c.out"]
    ask "c" "z"