Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add very simple Haskell build system example

  • Loading branch information...
commit 312bc53000d3d2d45aae73c4937e54c276554ae1 1 parent 2942615
@batterseapower authored
View
9 tests/Test.lhs
@@ -164,6 +164,15 @@ main = do
ec <- shake_ "Shakefile.hs" []
ExitSuccess `assertEqualM` ec
+ withTest "simple-hs" ["Main", "Main.hi", "Main.o", "Utility.hi", "Utility.o"] $ do
+ -- 1) Do the build
+ ec <- shake_ "Shakefile.hs" []
+ ExitSuccess `assertEqualM` ec
+
+ -- 2) Check the EXE is OK
+ out <- readProcess "./Main" [] ""
+ "2" `assertEqualM` out
+
-- TODO: test that nothing goes wrong if we change the type of oracle between runs
withTest "deserialization-changes" ["examplefile"] $ do
View
BIN  tests/simple-hs/Main
Binary file not shown
View
5 tests/simple-hs/Main.hs
@@ -0,0 +1,5 @@
+module Main where
+
+import Utility
+
+main = print utility
View
19 tests/simple-hs/Shakefile.hs
@@ -0,0 +1,19 @@
+import Development.Shake
+import Development.Shake.C
+import Development.Shake.System
+
+import System.FilePath
+
+import Control.Monad
+
+main :: IO ()
+main = shake $ do
+ "Main" *> \x -> do
+ need ["Main.o", "Utility.o"]
+ system' ["ghc", "-o", x,
+ "Utility.o", "Main.o"]
+ (\x -> guard (takeExtension x == ".o") >> return [x, replaceExtension x "hi"]) ?@> \o -> do
+ let hs = replaceExtension o "hs"
+ need $ [hs] ++ [y | hs == "Main.hs", y <- ["Utility.hi", "Utility.o"]]
+ system' ["ghc", "-c", hs]
+ want ["Main"]
View
3  tests/simple-hs/Utility.hs
@@ -0,0 +1,3 @@
+module Utility where
+
+utility = 2
Please sign in to comment.
Something went wrong with that request. Please try again.