You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/shelltest.hs
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,7 @@ data Args = Args {
68
68
,debug_parse::Bool
69
69
,testpaths:: [FilePath]
70
70
,print_::MaybeString
71
+
,actual::MaybeString
71
72
}deriving (Show, Data, Typeable)
72
73
73
74
argdefs =Args {
@@ -91,6 +92,7 @@ argdefs = Args {
91
92
,debug_parse = def &= help "Show test file parsing results and stop"
92
93
,testpaths = def &= args &= typ "TESTFILES|TESTDIRS"
93
94
,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). 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."
94
96
}
95
97
&= helpArg [explicit, name "help", name "h"]
96
98
&= program progname
@@ -153,6 +155,8 @@ checkArgs :: Args -> IO Args
153
155
checkArgs args =do
154
156
when (null$ testpaths args) $
155
157
warn $ printf "Please specify at least one test file or directory, eg: %s tests" progname
158
+
when (isJust (actual args) &¬ (isJust (print_ args))) $
159
+
warn "Option --actual can only be used with --print."
let errorMatch =maybeTrue (e_actual `matches`) e_expected
185
189
let exitCodeMatch =show x_actual `matches` x_expected
186
190
case print_ args of
187
-
Just format -> printShellTest format st
191
+
Just format -> printShellTest format (actual args) st (mkEither outputMatch o_actual) (mkEither errorMatch e_actual) (mkEither exitCodeMatch x_actual)
188
192
Nothing->if (x_actual ==127) -- catch bad executable - should work on posix systems at least
189
193
thenioError$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
0 commit comments