From 2f5927f0d0840ee22192da45217a30c204f5b504 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Thu, 26 Oct 2017 17:44:11 -0400 Subject: [PATCH] nitunit: linearize test execution Signed-off-by: Alexandre Terrasa --- src/testing/testing_suite.nit | 24 +++++++++++++++++------ tests/nitunit.args | 1 + tests/sav/nitunit_args14.res | 18 ++++++++++++++++++ tests/test_nitunit10.nit | 42 +++++++++++++++++++++++++++++++++++++++++ tests/test_nitunit11.nit | 42 +++++++++++++++++++++++++++++++++++++++++ tests/test_nitunit9.nit | 39 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 tests/sav/nitunit_args14.res create mode 100644 tests/test_nitunit10.nit create mode 100644 tests/test_nitunit11.nit create mode 100644 tests/test_nitunit9.nit diff --git a/src/testing/testing_suite.nit b/src/testing/testing_suite.nit index 8a49a63..13cf20f 100644 --- a/src/testing/testing_suite.nit +++ b/src/testing/testing_suite.nit @@ -481,7 +481,9 @@ redef class MClassDef for mclassdef in in_hierarchy.direct_greaters do res.add_all mclassdef.before end - return res.to_a + var lin = res.to_a + mmodule.linearize_mpropdefs(lin) + return lin end # Methods tagged with `before_all` in this class definition @@ -497,7 +499,9 @@ redef class MClassDef for mclassdef in in_hierarchy.direct_greaters do res.add_all mclassdef.before_all end - return res.to_a + var lin = res.to_a + mmodule.linearize_mpropdefs(lin) + return lin end # Methods tagged with `after` in this class definition @@ -513,7 +517,9 @@ redef class MClassDef for mclassdef in in_hierarchy.direct_greaters do res.add_all mclassdef.after end - return res.to_a + var lin = res.to_a + mmodule.linearize_mpropdefs(lin) + return lin.reversed end # Methods tagged with `after_all` in this class definition @@ -529,7 +535,9 @@ redef class MClassDef for mclassdef in in_hierarchy.direct_greaters do res.add_all mclassdef.after_all end - return res.to_a + var lin = res.to_a + mmodule.linearize_mpropdefs(lin) + return lin.reversed end end @@ -546,7 +554,9 @@ redef class MModule end end end - return res + var lin = res.to_a + linearize_mpropdefs(lin) + return lin end # Methods tagged with `after_all` at the module level (in `Sys`) @@ -561,7 +571,9 @@ redef class MModule end end end - return res + var lin = res.to_a + linearize_mpropdefs(lin) + return lin.reversed end end diff --git a/tests/nitunit.args b/tests/nitunit.args index d55842d..74ce65f 100644 --- a/tests/nitunit.args +++ b/tests/nitunit.args @@ -11,3 +11,4 @@ test_nitunit5.nit --no-color -o $WRITE test_nitunit6.nit --no-color -o $WRITE test_nitunit7.nit --no-color -o $WRITE test_nitunit8.nit --no-color -o $WRITE +test_nitunit11.nit --no-color -o $WRITE diff --git a/tests/sav/nitunit_args14.res b/tests/sav/nitunit_args14.res new file mode 100644 index 0000000..c0f1e23 --- /dev/null +++ b/tests/sav/nitunit_args14.res @@ -0,0 +1,18 @@ +==== Test-suite of module test_nitunit11::test_nitunit11 | tests: 7 +[OK] test_nitunit9$TestNitunit9$before_class +[OK] test_nitunit10$TestNitunit10$before_class2 +[OK] test_nitunit11$TestNitunit11$before_class3 +[OK] test_nitunit11$TestNitunit11$test_baz +[OK] test_nitunit11$TestNitunit11$after_class3 +[OK] test_nitunit10$TestNitunit10$after_class2 +[KO] test_nitunit9$TestNitunit9$after_class + test_nitunit9.nit:36,2--38,4: Runtime Error in file nitunit.out/gen_test_nitunit11.nit + Output + Runtime error: Assert failed (test_nitunit9.nit:37) + + +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 diff --git a/tests/test_nitunit10.nit b/tests/test_nitunit10.nit new file mode 100644 index 0000000..9166f24 --- /dev/null +++ b/tests/test_nitunit10.nit @@ -0,0 +1,42 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module test_nitunit10 is test + +import test_nitunit9 + +class TestNitunit10 + super TestNitunit9 + test + + fun before_class2 is before_all do + assert true + end + + fun before2 is before do + assert true + end + + fun test_bar is test do + assert true + end + + fun after2 is after do + assert true + end + + fun after_class2 is after_all do + assert true + end +end diff --git a/tests/test_nitunit11.nit b/tests/test_nitunit11.nit new file mode 100644 index 0000000..1eb67c3 --- /dev/null +++ b/tests/test_nitunit11.nit @@ -0,0 +1,42 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module test_nitunit11 is test + +import test_nitunit10 + +class TestNitunit11 + super TestNitunit10 + test + + fun before_class3 is before_all do + assert true + end + + fun before3 is before do + assert true + end + + fun test_baz is test do + assert true + end + + fun after3 is after do + assert true + end + + fun after_class3 is after_all do + assert true + end +end diff --git a/tests/test_nitunit9.nit b/tests/test_nitunit9.nit new file mode 100644 index 0000000..1959919 --- /dev/null +++ b/tests/test_nitunit9.nit @@ -0,0 +1,39 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module test_nitunit9 is test + +class TestNitunit9 + test + + fun before_class is before_all do + assert true + end + + fun before is before do + assert true + end + + fun test_foo is test do + assert true + end + + fun after is after do + assert true + end + + fun after_class is after_all do + assert false + end +end -- 1.7.9.5