nitunit: linearize test execution
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 26 Oct 2017 21:44:11 +0000 (17:44 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 26 Oct 2017 21:44:11 +0000 (17:44 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/testing/testing_suite.nit
tests/nitunit.args
tests/sav/nitunit_args14.res [new file with mode: 0644]
tests/test_nitunit10.nit [new file with mode: 0644]
tests/test_nitunit11.nit [new file with mode: 0644]
tests/test_nitunit9.nit [new file with mode: 0644]

index 8a49a63..13cf20f 100644 (file)
@@ -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
 
index d55842d..74ce65f 100644 (file)
@@ -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 (file)
index 0000000..c0f1e23
--- /dev/null
@@ -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.
+<testsuites><testsuite package="test_nitunit11::test_nitunit11"></testsuite><testsuite package="test_nitunit11"><testcase classname="nitunit.test_nitunit11.TestNitunit11" name="test_baz" time="0.0"><system-err></system-err></testcase></testsuite></testsuites>
\ No newline at end of file
diff --git a/tests/test_nitunit10.nit b/tests/test_nitunit10.nit
new file mode 100644 (file)
index 0000000..9166f24
--- /dev/null
@@ -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 (file)
index 0000000..1eb67c3
--- /dev/null
@@ -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 (file)
index 0000000..1959919
--- /dev/null
@@ -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