Skip to content

Commit 2c21c63

Browse files
committed
Update doc, fix bug
1 parent c7e29f4 commit 2c21c63

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/shelltest.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ argdefs = Args {
9292
,debug_parse = def &= help "Show test file parsing results and stop"
9393
,testpaths = def &= args &= typ "TESTFILES|TESTDIRS"
9494
,print_ = def &= typ "FORMAT" &= opt "v3" &= groupname "Print test file" &= help "Print test files in specified format (default: v3)."
95-
,actual = def &= typ "MODE" &= opt "all" &= help "Combined with --print, print test files with actual results (stdout, stderr, exit status). Mode 'all' prints all actual results (default). Mode 'update' prints actual results only for non-matching results, i.e. regular expressions in tests are retained."
95+
,actual = def &= typ "MODE" &= opt "all" &= help "Combined with --print, print test files with actual results (stdout, stderr, exit status). This can be used to generate or update tests. Mode 'all' prints all actual results (default). Mode 'update' prints actual results only for non-matching results, i.e. regular expressions in tests are retained."
9696
}
9797
&= helpArg [explicit, name "help", name "h"]
9898
&= program progname
@@ -188,9 +188,11 @@ prepareShellTest args printTests st@ShellTest{testname=n,command=c,stdin=i,stdou
188188
let outputMatch = maybe True (o_actual `matches`) o_expected
189189
let errorMatch = maybe True (e_actual `matches`) e_expected
190190
let exitCodeMatch = show x_actual `matches` x_expected
191-
if (x_actual == 127) -- catch bad executable - should work on posix systems at least
192-
then ioError $ userError $ unwords $ filter (not . null) [e_actual, printf "Command: '%s' Exit code: %i" cmd x_actual] -- XXX still a test failure; should be an error
193-
else assertString $ concat $ filter (not . null) [
191+
if printTests
192+
then printShellTest (actual args) st (mkEither outputMatch o_actual) (mkEither errorMatch e_actual) (mkEither exitCodeMatch x_actual)
193+
else if (x_actual == 127) -- catch bad executable - should work on posix systems at least
194+
then ioError $ userError $ unwords $ filter (not . null) [e_actual, printf "Command: '%s' Exit code: %i" cmd x_actual] -- XXX still a test failure; should be an error
195+
else assertString $ concat $ filter (not . null) [
194196
if any not [outputMatch, errorMatch, exitCodeMatch]
195197
then printf "Command (at line %s):\n%s\n" (show ln) cmd
196198
else ""
@@ -204,8 +206,6 @@ prepareShellTest args printTests st@ShellTest{testname=n,command=c,stdin=i,stdou
204206
then ""
205207
else showExpectedActual args{diff=False} "exit code" x_expected (show x_actual)
206208
]
207-
when printTests $
208-
printShellTest (actual args) st (mkEither outputMatch o_actual) (mkEither errorMatch e_actual) (mkEither exitCodeMatch x_actual)
209209

210210
-- | Run a shell command line, passing it standard input if provided,
211211
-- and return the standard output, standard error output and exit code.

0 commit comments

Comments
 (0)