Skip to content

Commit

Permalink
Added test for 'Dyre.configCheck' parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
willdonnelly committed Sep 12, 2009
1 parent 019476f commit 0c560df
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Tests/config-check/ConfigCheckTest.hs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
module ConfigCheckTest where

import qualified Config.Dyre as Dyre
import System.IO

configCheckMain = Dyre.wrapMain $ Dyre.defaultParams
{ Dyre.projectName = "configCheckTest"
, Dyre.realMain = putStrLn
, Dyre.showError = const
, Dyre.statusOut = const . return $ ()
}

configCheckTest = Dyre.wrapMain $ Dyre.defaultParams
{ Dyre.projectName = "configCheckTest"
, Dyre.realMain = putStrLn
, Dyre.showError = const
, Dyre.statusOut = const . return $ ()
, Dyre.configCheck = False
}
2 changes: 2 additions & 0 deletions Tests/config-check/Main.hs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
import ConfigCheckTest
main = configCheckMain "main"
2 changes: 2 additions & 0 deletions Tests/config-check/configCheckTestA.hs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
import ConfigCheckTest
main = configCheckTest "custom-a"
2 changes: 2 additions & 0 deletions Tests/config-check/configCheckTestB.hs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
import ConfigCheckTest
main = configCheckTest "custom-b"
34 changes: 34 additions & 0 deletions Tests/config-check/runTest.sh
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

# Tests Dyre's ability to recompile a custom configuration
# upon relaunch, and restore the state again after.

# Assert the equality of two strings.
function assert() {
if [ "$1" != "$2" ]; then
echo "Failed test $3";
exit 1;
fi
}

mkdir working
cd working

### TEST A ###
cp ../ConfigCheckTest.hs ../Main.hs .
cp ../configCheckTestA.hs ./configCheckTest.hs
ghc --make Main.hs -o configCheck 2> /dev/null
OUTPUT_A=`./configCheck --dyre-debug`
assert "$OUTPUT_A" "custom-a" "A"

sleep 1

### TEST B ###
cp ../configCheckTestB.hs ./configCheckTest.hs
mv cache/configCheckTest* configCheck
OUTPUT_B=`./configCheck --dyre-debug`
assert "$OUTPUT_B" "custom-a" "B"

echo "Passed"
cd ..
rm -r working

0 comments on commit 0c560df

Please sign in to comment.