From 02b3883f7e4b53e7173abee3f7367612a2764a67 Mon Sep 17 00:00:00 2001 From: ml Date: Sun, 6 Nov 2016 16:05:20 -0800 Subject: [PATCH] Support for running specific unit tests without breaking existing tests with argument '0' --- src/App/Application.cpp | 31 ++++++++++++------------------- src/App/FreeCADTest.py | 8 +++++--- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index b3ebf2bd2..fa2354c4a 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1024,7 +1024,7 @@ void my_trans_func( unsigned int code, EXCEPTION_POINTERS* pExp ) //switch (code) //{ - // case FLT_DIVIDE_BY_ZERO : + // case FLT_DIVIDE_BY_ZERO : // //throw CMyFunkyDivideByZeroException(code, pExp); // throw Base::Exception("Devision by zero!"); // break; @@ -1145,7 +1145,7 @@ void Application::initTypes(void) App ::GeoFeatureGroupExtensionPython::init(); App ::OriginGroupExtension ::init(); App ::OriginGroupExtensionPython ::init(); - + // Document classes App ::TransactionalObject ::init(); App ::DocumentObject ::init(); @@ -1675,7 +1675,7 @@ void Application::ParseOptions(int ac, char ** av) ("log-file", value(), "Unlike to --write-log this allows to log to an arbitrary file") ("user-cfg,u", value(),"User config file to load/save user settings") ("system-cfg,s", value(),"Systen config file to load/save system settings") - ("run-test,t", value() ,"Test level") + ("run-test,t", value() ,"Test case - or 0 for all") ("module-path,M", value< vector >()->composing(),"Additional module paths") ("python-path,P", value< vector >()->composing(),"Additional python paths") ("single-instance", "Allow to run a single instance of the application") @@ -1884,21 +1884,14 @@ void Application::ParseOptions(int ac, char ** av) } if (vm.count("run-test")) { - int level = vm["run-test"].as(); - switch (level) { - case '0': - // test script level 0 - mConfig["RunMode"] = "Internal"; - mConfig["ScriptFileName"] = "FreeCADTest"; - //sScriptName = FreeCADTest; - break; - default: - //default testing level 0 - mConfig["RunMode"] = "Internal"; - mConfig["ScriptFileName"] = "FreeCADTest"; - //sScriptName = FreeCADTest; - break; - }; + string testCase = vm["run-test"].as(); + if ( "0" == testCase) { + testCase = "TestApp.All"; + } + mConfig["TestCase"] = testCase; + mConfig["RunMode"] = "Internal"; + mConfig["ScriptFileName"] = "FreeCADTest"; + //sScriptName = FreeCADTest; } if (vm.count("single-instance")) { @@ -2161,7 +2154,7 @@ std::string Application::FindHomePath(const char* sCall) // path. In the worst case we simply get q wrong path and FreeCAD is not // able to load its modules. char resolved[PATH_MAX]; -#if defined(FC_OS_BSD) +#if defined(FC_OS_BSD) int mib[4]; mib[0] = CTL_KERN; mib[1] = KERN_PROC; diff --git a/src/App/FreeCADTest.py b/src/App/FreeCADTest.py index f760d1006..6ce4d40a6 100644 --- a/src/App/FreeCADTest.py +++ b/src/App/FreeCADTest.py @@ -1,7 +1,7 @@ -# FreeCAD test module +# FreeCAD test module # (c) 2002 Juergen Riegel # -# Testing the function of the base system and run +# Testing the function of the base system and run # (if existing) the test function of the modules # @@ -34,7 +34,9 @@ Log ("FreeCAD test running...\n\n") import TestApp, sys -testResult = TestApp.TestText("TestApp.All") +testCase = FreeCAD.ConfigGet("TestCase") + +testResult = TestApp.TestText(testCase) Log ("FreeCAD test done\n")