From 61e9c7897630bfe23a2bf6c2a02803c1fc8dd51d Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 1 Mar 2019 07:56:46 -0500 Subject: [PATCH] nitunit: do not write empty testsuites in the xml file Signed-off-by: Jean Privat --- src/nitunit.nit | 14 +++++++++----- tests/sav/nitunit_args1.res | 2 +- tests/sav/nitunit_args10.res | 2 +- tests/sav/nitunit_args11.res | 2 +- tests/sav/nitunit_args12.res | 2 +- tests/sav/nitunit_args13.res | 2 +- tests/sav/nitunit_args14.res | 2 +- tests/sav/nitunit_args9.res | 8 ++++---- 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/nitunit.nit b/src/nitunit.nit index fe8fb7b..125c514 100644 --- a/src/nitunit.nit +++ b/src/nitunit.nit @@ -84,19 +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) - var ts = modelbuilder.test_unit(m) - if ts != null then page.add ts + 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 diff --git a/tests/sav/nitunit_args1.res b/tests/sav/nitunit_args1.res index f1851ee..7cec735 100644 --- a/tests/sav/nitunit_args1.res +++ b/tests/sav/nitunit_args1.res @@ -35,5 +35,5 @@ Test suites: Classes: 1; Test Cases: 3; Failures: 1 assert !@#$%^&*() var x = new X assert x.foo2 -Runtime error: Assert failed (test_test_nitunit.nit:38) +Runtime error: Assert failed (test_test_nitunit.nit:38) \ No newline at end of file diff --git a/tests/sav/nitunit_args10.res b/tests/sav/nitunit_args10.res index 5fdb314..cbfc0cd 100644 --- a/tests/sav/nitunit_args10.res +++ b/tests/sav/nitunit_args10.res @@ -5,4 +5,4 @@ Docunits: Entities: 4; Documented ones: 0; With nitunits: 0 Test suites: Classes: 1; Test Cases: 2; Failures: 0 [SUCCESS] All 2 tests passed. - \ No newline at end of file + \ No newline at end of file diff --git a/tests/sav/nitunit_args11.res b/tests/sav/nitunit_args11.res index 0d1829d..a640323 100644 --- a/tests/sav/nitunit_args11.res +++ b/tests/sav/nitunit_args11.res @@ -13,4 +13,4 @@ Docunits: Entities: 5; Documented ones: 0; With nitunits: 0 Test suites: Classes: 1; Test Cases: 3; Failures: 3 [FAILURE] 3/3 tests failed. `nitunit.out` is not removed for investigation. - \ No newline at end of file + \ No newline at end of file diff --git a/tests/sav/nitunit_args12.res b/tests/sav/nitunit_args12.res index 9015b4a..4932785 100644 --- a/tests/sav/nitunit_args12.res +++ b/tests/sav/nitunit_args12.res @@ -11,4 +11,4 @@ Docunits: Entities: 5; Documented ones: 0; With nitunits: 0 Test suites: Classes: 1; Test Cases: 3; Failures: 1 [FAILURE] 1/3 tests failed. `nitunit.out` is not removed for investigation. - \ No newline at end of file + \ No newline at end of file diff --git a/tests/sav/nitunit_args13.res b/tests/sav/nitunit_args13.res index 8c8d3f9..84dbc07 100644 --- a/tests/sav/nitunit_args13.res +++ b/tests/sav/nitunit_args13.res @@ -11,4 +11,4 @@ Docunits: Entities: 3; Documented ones: 0; With nitunits: 0 Test suites: Classes: 1; Test Cases: 3; Failures: 1 [FAILURE] 1/3 tests failed. `nitunit.out` is not removed for investigation. - \ No newline at end of file + \ No newline at end of file diff --git a/tests/sav/nitunit_args14.res b/tests/sav/nitunit_args14.res index c0f1e23..3cb2d30 100644 --- a/tests/sav/nitunit_args14.res +++ b/tests/sav/nitunit_args14.res @@ -15,4 +15,4 @@ Docunits: Entities: 7; Documented ones: 0; With nitunits: 0 Test suites: Classes: 1; Test Cases: 7; Failures: 1 [FAILURE] 1/7 tests failed. `nitunit.out` is not removed for investigation. - \ No newline at end of file + \ No newline at end of file diff --git a/tests/sav/nitunit_args9.res b/tests/sav/nitunit_args9.res index 404c270..7682e35 100644 --- a/tests/sav/nitunit_args9.res +++ b/tests/sav/nitunit_args9.res @@ -59,11 +59,11 @@ Docunits: Entities: 22; Documented ones: 0; With nitunits: 0 Test suites: Classes: 3; Test Cases: 8; Failures: 7 [FAILURE] 7/8 tests failed. `nitunit.out` is not removed for investigation. -test_nitunit4/test_bad_comp.nit:25,10--19: Error: method or variable `bad_method` unknown in `TestSuiteBadComp`. +test_nitunit4/test_bad_comp.nit:25,10--19: Error: method or variable `bad_method` unknown in `TestSuiteBadComp`. test_nitunit4/test_bad_comp.nit:25,10--19: Error: method or variable `bad_method` unknown in `TestSuiteBadComp`. -nitunit.out/gen_test_bad_comp2.nit:11,10--17: Error: expected 1 argument(s) for `test_bad(param: Bool)`; got 0. See introduction at `test_nitunit4::TestSuiteBadComp::test_bad`. +nitunit.out/gen_test_bad_comp2.nit:11,10--17: Error: expected 1 argument(s) for `test_bad(param: Bool)`; got 0. See introduction at `test_nitunit4::TestSuiteBadComp::test_bad`. nitunit.out/gen_test_bad_comp2.nit:11,10--17: Error: expected 1 argument(s) for `test_bad(param: Bool)`; got 0. See introduction at `test_nitunit4::TestSuiteBadComp::test_bad`. -Before Test +Before Test Tested method After Test Runtime assert: <TestTestSuite>.before @@ -82,4 +82,4 @@ After Test Before Test Tested method After Test - \ No newline at end of file + \ No newline at end of file -- 1.7.9.5