Skip to content

Commit

Permalink
Make the Forward tests not run on Mac (where they fail)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndmitchell committed Dec 15, 2019
1 parent bef4b2e commit 808b87e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Test/Forward.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

module Test.Forward(main) where

import Control.Monad
import Data.Char
import Data.List.Extra
import Development.Shake
import System.Info.Extra
import Development.Shake.Forward
import Development.Shake.FilePath
import Test.Type
Expand All @@ -26,35 +26,40 @@ main = testBuild test $ forwardRule $ do
cacheActionWith "reducer" src $ writeFile' "out.txt" $ filter isUpper src


test build = do
checkVaild act = do
b <- hasTracker
unless b $
putStrLn "Warning: Running forward test but without --forward mode (no tracker)"
if not b then
putStrLn "Warning: Not running forward test (no tracker)"
else if isMac then
putStrLn "Warning: Not running forward test (doesn't work on Mac)"
else
act

test build = checkVaild $ do
-- first clean then copy the source files over
build ["clean"]
copyDirectoryChanged (shakeRoot </> "src/Test/C") "."

-- build and rebuild
build ["--forward" | b]
build ["--forward"]
assertContents "output.txt" "Hello Shake Users!\n"
assertContents "out.txt" "HSU"

-- check that cacheAction doesn't rerun when it shouldn't
writeFile "out.txt" "HHH"
build $ "-j2" : ["--forward" | b]
build ["-j2","--forward"]
assertContents "output.txt" "Hello Shake Users!\n"
assertContents "out.txt" "HHH"

-- modify the constants
orig <- IO.readFile' "constants.c"
writeFile "constants.c" $ replace "Shake" "Rattle" orig
build $ "-j2" : ["--forward" | b]
build ["-j2","--forward"]
assertContents "output.txt" "Hello Rattle Users!\n"
assertContents "out.txt" "HRU"

-- put it back
writeFile "constants.c" orig
build $ "-j2" : ["--forward" | b]
build ["-j2","--forward"]
assertContents "output.txt" "Hello Shake Users!\n"
assertContents "out.txt" "HSU"

0 comments on commit 808b87e

Please sign in to comment.