Generate results of all tests from generated shell scripts too.
catseye
10 years ago
43 | 43 | format _ blocks = |
44 | 44 | prelude ++ (formatBlocks blocks) ++ postlude |
45 | 45 | |
46 | formatBlocks (test@(Test id [(ShellTest cmd)] desc input expectation _):rest) = | |
46 | formatBlocks (test@(Test id [(ShellTest cmd)] desc input _ _):rest) = | |
47 | 47 | let |
48 | expected = case expectation of | |
49 | Output e -> e | |
50 | Exception e -> e -- XXX should we expect this on stderr? | |
51 | 48 | inputHereDoc = hereDoc "input.txt" input |
52 | expectedHereDoc = hereDoc "expected.txt" expected | |
53 | formattedBlock = inputHereDoc ++ expectedHereDoc ++ testExecution cmd id | |
49 | formattedBlock = inputHereDoc ++ testExecution cmd id | |
54 | 50 | in |
55 | 51 | formattedBlock ++ "\n" ++ formatBlocks rest |
56 | 52 | formatBlocks (_:rest) = |
72 | 68 | |
73 | 69 | postlude = |
74 | 70 | "\n\ |
75 | \\n" | |
71 | \rm -f input.txt output.txt\n" | |
76 | 72 | |
77 | 73 | testExecution cmd id = |
78 | 74 | cmd ++ " <input.txt >output.txt\n\ |
79 | \diff -q expected.txt output.txt 2>&1 >/dev/null\n\ | |
80 | \if [ $? -ne 0 ]\n\ | |
81 | \ then\n\ | |
82 | \ echo " ++ (show id) ++ "\n\ | |
83 | \ echo `wc -l output.txt`\n\ | |
84 | \ cat output.txt\n\ | |
85 | \fi\n\ | |
86 | \rm -f input.txt expected.txt output.txt\n" | |
75 | \echo \"output\"\n\ | |
76 | \echo " ++ (show id) ++ "\n\ | |
77 | \echo `wc -l output.txt`\n\ | |
78 | \cat output.txt\n" |