Skip to content

Commit

Permalink
Add support for running a single test
Browse files Browse the repository at this point in the history
  • Loading branch information
cannam committed Feb 13, 2023
1 parent d4f079a commit 443c648
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions test.sml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,39 @@ fun all_tests () =
prefixed "dtw" dtw_tests @
prefixed "hmm" hmm_tests

fun usage () =
(print ("Usage: " ^ CommandLine.name () ^ " [testname]\n");
print ("The default is to run all tests.\n");
OS.Process.exit OS.Process.failure)

fun main () =
(Log.resetElapsedTime ();
if (foldl (fn (t, acc) => if TestRunner.run t
then acc
else false)
true
(all_tests ()))
then OS.Process.exit OS.Process.success
else (print "Some tests failed\n"; OS.Process.exit OS.Process.failure))
let val tests = all_tests ()
val () = Log.resetElapsedTime ()
in
case CommandLine.arguments () of
[test] =>
(case foldl (fn ((name, tests), (found, succeeded)) =>
if name = test
then (true, TestRunner.run (name, tests) andalso
succeeded)
else (found, succeeded))
(false, true)
tests of
(false, _) => (print ("Unknown test \"" ^ test ^ "\"\n");
usage ())
| (_, false) => OS.Process.exit OS.Process.failure
| _ => OS.Process.exit OS.Process.success)
| [] =>
if (foldl (fn (t, acc) => if TestRunner.run t
then acc
else false)
true
tests)
then OS.Process.exit OS.Process.success
else (print "Some tests failed\n";
OS.Process.exit OS.Process.failure)
| _ => usage ()
end
handle ex =>
(TextIO.output (TextIO.stdErr,
"Exception caught at top level: " ^ exnMessage ex ^
Expand Down

0 comments on commit 443c648

Please sign in to comment.