nitunit: extract `generate_single_docunit` from `test_single_docunit`
authorJean Privat <jean@pryen.org>
Tue, 20 Jun 2017 17:42:35 +0000 (13:42 -0400)
committerJean Privat <jean@pryen.org>
Thu, 31 May 2018 13:30:05 +0000 (09:30 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/testing/testing_doc.nit

index 6063736..30a0eb4 100644 (file)
@@ -215,20 +215,29 @@ class NitUnitExecutor
                end
        end
 
-       # Executes a single doc-unit in its own program.
-       # Used for docunits larger than a single block of code (with modules, classes, functions etc.)
-       fun test_single_docunit(du: DocUnit)
+       # Produce a single unit file for the docunit `du`.
+       fun generate_single_docunit(du: DocUnit): String
        do
                cpt += 1
                var file = "{prefix}-{cpt}.nit"
 
-               toolcontext.info("Execute doc-unit {du.full_name} in {file}", 1)
-
                var f
                f = create_unitfile(file)
                f.write(du.block)
                f.close
 
+               du.test_file = file
+               return file
+       end
+
+       # Executes a single doc-unit in its own program.
+       # Used for docunits larger than a single block of code (with modules, classes, functions etc.)
+       fun test_single_docunit(du: DocUnit)
+       do
+               var file = generate_single_docunit(du)
+
+               toolcontext.info("Compile doc-unit {du.full_name} in {file}", 1)
+
                if toolcontext.opt_noact.value then return
 
                var res = compile_unitfile(file)