nitunit: factorize test_dir processing into test_base.
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 27 Aug 2014 06:06:46 +0000 (02:06 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 27 Aug 2014 06:09:10 +0000 (02:09 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/testing/testing_base.nit
src/testing/testing_doc.nit

index 7e0c616..243a51e 100644 (file)
@@ -27,4 +27,11 @@ redef class ToolContext
        var opt_dir = new OptionString("Working directory (default is '.nitunit')", "--dir")
        # opt --no-act
        var opt_noact = new OptionBool("Does not compile and run tests", "--no-act")
+
+       # Working directory for testing.
+       fun test_dir: String do
+               var dir = opt_dir.value
+               if dir == null then return ".nitunit"
+               return dir
+       end
 end
index 9d93dc6..e370b8a 100644 (file)
@@ -213,8 +213,7 @@ redef class ModelBuilder
 
                ts.attr("package", mmodule.full_name)
 
-               var prefix = toolcontext.opt_dir.value
-               if prefix == null then prefix = ".nitunit"
+               var prefix = toolcontext.test_dir
                prefix = prefix.join_path(mmodule.to_s)
                var d2m = new NitUnitExecutor(toolcontext, prefix, o, ts)