From 8e4f6bbae913a75e5548ae2c0f9236e8464a5c3d Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 2 Jun 2016 20:03:57 -0400 Subject: [PATCH] nitunit: add `--autosav` for testsuites Signed-off-by: Jean Privat --- src/nitunit.nit | 2 +- src/testing/testing_suite.nit | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/nitunit.nit b/src/nitunit.nit index 8d79e80..c9aa8ae 100644 --- a/src/nitunit.nit +++ b/src/nitunit.nit @@ -20,7 +20,7 @@ import testing var toolcontext = new ToolContext -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_file, 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) diff --git a/src/testing/testing_suite.nit b/src/testing/testing_suite.nit index c15b1c0..a37d243 100644 --- a/src/testing/testing_suite.nit +++ b/src/testing/testing_suite.nit @@ -24,6 +24,8 @@ redef class ToolContext var opt_file = new OptionString("Specify test suite location", "-t", "--target-file") # --pattern var opt_pattern = new OptionString("Only run test case with name that match pattern", "-p", "--pattern") + # --autosav + var opt_autosav = new OptionBool("Automatically create/update .res files for black box testing", "--autosav") end # Used to test nitunit test files. @@ -269,7 +271,8 @@ class TestCase var test_file = test_suite.test_file var res_name = "{test_file}_{method_name.escape_to_c}" var res = toolcontext.safe_exec("{test_file}.bin {method_name} > '{res_name}.out1' 2>&1 '{res_name}.diff' 2>&1