X-Git-Url: http://nitlanguage.org diff --git a/src/nitunit.nit b/src/nitunit.nit index bed744c..125c514 100644 --- a/src/nitunit.nit +++ b/src/nitunit.nit @@ -16,11 +16,13 @@ # see `testing/README` module nitunit +import frontend import testing var toolcontext = new ToolContext +toolcontext.keep_going = true -toolcontext.option_context.add_option(toolcontext.opt_full, toolcontext.opt_output, toolcontext.opt_dir, toolcontext.opt_noact, toolcontext.opt_pattern, toolcontext.opt_file, toolcontext.opt_gen_unit, toolcontext.opt_gen_force, toolcontext.opt_gen_private, toolcontext.opt_gen_show, toolcontext.opt_nitc) +toolcontext.option_context.add_option(toolcontext.opt_full, toolcontext.opt_output, toolcontext.opt_dir, toolcontext.opt_noact, toolcontext.opt_pattern, toolcontext.opt_autosav, toolcontext.opt_gen_unit, toolcontext.opt_gen_force, toolcontext.opt_gen_private, toolcontext.opt_gen_show, toolcontext.opt_nitc) toolcontext.tooldescription = "Usage: nitunit [OPTION]... ...\nExecutes the unit tests from Nit source files." toolcontext.process_options(args) @@ -31,10 +33,6 @@ if toolcontext.opt_gen_unit.value then print "Option --pattern cannot be used with --gen-suite" exit(0) end - if toolcontext.opt_file.value != null then - print "Option --target-file cannot be used with --gen-suite" - exit(0) - end else if toolcontext.opt_gen_force.value then print "Option --force must be used with --gen-suite" @@ -63,6 +61,11 @@ if toolcontext.opt_gen_unit.value then exit(0) end +# When testing `nitunit`, disable time. +if "NIT_TESTING".environ != "" then + toolcontext.opt_no_time.value = true +end + "NIT_TESTING".setenv("true") "NIT_TESTING_ID".setenv(pid.to_s) "SRAND".setenv("0") @@ -81,18 +84,23 @@ for a in args do end # Try to load the file as a markdown document var mdoc = modelbuilder.load_markdown(a) - page.add modelbuilder.test_mdoc(mdoc) + var ts = modelbuilder.test_mdoc(mdoc) + if not ts.children.is_empty then page.add ts end for a in module_files do var g = modelbuilder.identify_group(a) if g == null then continue - page.add modelbuilder.test_group(g) + var ts = modelbuilder.test_group(g) + if not ts.children.is_empty then page.add ts end for m in mmodules do - page.add modelbuilder.test_markdown(m) - page.add modelbuilder.test_unit(m) + var ts + ts = modelbuilder.test_markdown(m) + if not ts.children.is_empty then page.add ts + ts = modelbuilder.test_unit(m) + if ts != null and not ts.children.is_empty then page.add ts end var file = toolcontext.opt_output.value @@ -152,5 +160,8 @@ else end print "{head} {fail}/{total} tests failed." + print "`{test_dir}` is not removed for investigation." exit 1 end + +test_dir.rmdir