X-Git-Url: http://nitlanguage.org diff --git a/src/testing/testing_doc.nit b/src/testing/testing_doc.nit index 4a4e33c..cadf871 100644 --- a/src/testing/testing_doc.nit +++ b/src/testing/testing_doc.nit @@ -36,8 +36,8 @@ class NitUnitExecutor # The XML node associated to the module var testsuite: HTMLTag - # All blocks of code from a same `ADoc` - var blocks = new Array[Buffer] + # The current test-case xml element + var tc: HTMLTag is noautoinit # All failures from a same `ADoc` var failures = new Array[String] @@ -55,14 +55,20 @@ class NitUnitExecutor # used to generate distinct names var cpt = 0 + # The last docunit extracted from a mdoc. + # + # Is used because a new code-block might just be added to it. + var last_docunit: nullable DocUnit = null + # The entry point for a new `ndoc` node # Fill `docunits` with new discovered unit of tests. # # `tc` (testcase) is the pre-filled XML node fun extract(mdoc: MDoc, tc: HTMLTag) do - blocks.clear + last_docunit = null failures.clear + self.tc = tc self.mdoc = mdoc @@ -79,12 +85,7 @@ class NitUnitExecutor toolcontext.modelbuilder.unit_entities += 1 toolcontext.modelbuilder.failed_entities += 1 end - if blocks.is_empty then testsuite.add(tc) - end - - if blocks.is_empty then return - for block in blocks do - docunits.add new DocUnit(mdoc, tc, block.write_to_string) + if last_docunit == null then testsuite.add(tc) end end @@ -105,6 +106,10 @@ class NitUnitExecutor end test_simple_docunits(simple_du) + + for du in docunits do + testsuite.add du.to_xml + end end # Executes multiples doc-units in a shared program. @@ -157,30 +162,17 @@ class NitUnitExecutor toolcontext.modelbuilder.unit_entities += 1 i += 1 toolcontext.info("Execute doc-unit {du.testcase.attrs["name"]} in {file} {i}", 1) - var res2 = sys.system("{file.to_program_name}.bin {i} >>'{file}.out1' 2>&1 '{file}.out1' 2>&1 >'{file}.out1' 2>&1 '{file}.out1' 2>&1 '{file}.out1' 2>&1