From 1d11f742cacf0447ed0e2bf75c181e1d1cc3d2dd Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 28 Aug 2018 13:14:16 +0200 Subject: [PATCH] now each module registers its unit tests itself --- src/App/FreeCADInit.py | 3 +++ src/Mod/Arch/Init.py | 2 ++ src/Mod/Draft/Init.py | 2 ++ src/Mod/Fem/Init.py | 2 ++ src/Mod/Mesh/Init.py | 2 ++ src/Mod/Part/Init.py | 2 ++ src/Mod/Part/InitGui.py | 2 ++ src/Mod/PartDesign/Init.py | 2 ++ src/Mod/PartDesign/InitGui.py | 2 ++ src/Mod/Path/Init.py | 2 ++ src/Mod/Sketcher/Init.py | 2 ++ src/Mod/Sketcher/InitGui.py | 6 ++++-- src/Mod/Spreadsheet/Init.py | 2 ++ src/Mod/TechDraw/Init.py | 2 ++ src/Mod/Test/Init.py | 13 ++++++++++--- src/Mod/Test/InitGui.py | 6 ++++++ src/Mod/Test/TestApp.py | 31 ++----------------------------- src/Mod/Test/TestGui.py | 24 ++++-------------------- 18 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/App/FreeCADInit.py b/src/App/FreeCADInit.py index 79fac9dba6..6a008e3bd7 100644 --- a/src/App/FreeCADInit.py +++ b/src/App/FreeCADInit.py @@ -208,6 +208,9 @@ test_ascii = lambda s: all(ord(c) < 128 for c in s) #store the cmake variales App.__cmake__ = cmake; +#store unit test names +App.__unit_test__ = [] + Log ('Init: starting App::FreeCADInit.py\n') # init every application by importing Init.py diff --git a/src/Mod/Arch/Init.py b/src/Mod/Arch/Init.py index 10fc0bd968..7da766e315 100644 --- a/src/Mod/Arch/Init.py +++ b/src/Mod/Arch/Init.py @@ -32,3 +32,5 @@ FreeCAD.addImportType("Collada (*.dae)","importDAE") FreeCAD.addExportType("Collada (*.dae)","importDAE") FreeCAD.addImportType("3D Studio mesh (*.3ds)","import3DS") FreeCAD.addImportType("SweetHome3D XML export (*.zip)","importSH3D") + +FreeCAD.__unit_test__ += [ "TestArch" ] diff --git a/src/Mod/Draft/Init.py b/src/Mod/Draft/Init.py index f3415a091d..79caef3bad 100644 --- a/src/Mod/Draft/Init.py +++ b/src/Mod/Draft/Init.py @@ -30,3 +30,5 @@ App.addExportType("Flattened SVG (*.svg)","importSVG") App.addExportType("Open CAD Format (*.oca)","importOCA") App.addImportType("Autodesk DWG 2D (*.dwg)","importDWG") App.addExportType("Autodesk DWG 2D (*.dwg)","importDWG") + +FreeCAD.__unit_test__ += [ "TestDraft" ] diff --git a/src/Mod/Fem/Init.py b/src/Mod/Fem/Init.py index 53bac65a47..273741354e 100644 --- a/src/Mod/Fem/Init.py +++ b/src/Mod/Fem/Init.py @@ -47,3 +47,5 @@ FreeCAD.addImportType("FEM result Z88 displacements (*o2.txt)", "feminout.import if("BUILD_FEM_VTK" in FreeCAD.__cmake__): FreeCAD.addImportType("FEM result VTK (*.vtk *.vtu)", "feminout.importVTKResults") FreeCAD.addExportType("FEM result VTK (*.vtk *.vtu)", "feminout.importVTKResults") + +FreeCAD.__unit_test__ += [ "TestFem" ] diff --git a/src/Mod/Mesh/Init.py b/src/Mod/Mesh/Init.py index 0b9b0fcd8f..e717b86636 100644 --- a/src/Mod/Mesh/Init.py +++ b/src/Mod/Mesh/Init.py @@ -16,3 +16,5 @@ FreeCAD.addExportType("Object File Format Mesh (*.off)","Mesh") FreeCAD.addExportType("Stanford Triangle Mesh (*.ply)","Mesh") FreeCAD.addExportType("Additive Manufacturing Format (*.amf)","Mesh") FreeCAD.addExportType("Simple Model Format (*.smf)","Mesh") + +FreeCAD.__unit_test__ += [ "MeshTestsApp" ] diff --git a/src/Mod/Part/Init.py b/src/Mod/Part/Init.py index c21e207526..23ecd7cb1b 100644 --- a/src/Mod/Part/Init.py +++ b/src/Mod/Part/Init.py @@ -34,3 +34,5 @@ FreeCAD.addImportType("IGES format (*.iges *.igs)","Part") FreeCAD.addExportType("IGES format (*.iges *.igs)","Part") FreeCAD.addImportType("STEP with colors (*.step *.stp)","ImportGui") FreeCAD.addExportType("STEP with colors (*.step *.stp)","ImportGui") + +FreeCAD.__unit_test__ += [ "TestPartApp" ] diff --git a/src/Mod/Part/InitGui.py b/src/Mod/Part/InitGui.py index 7d1541e736..c0f2d835f7 100644 --- a/src/Mod/Part/InitGui.py +++ b/src/Mod/Part/InitGui.py @@ -60,3 +60,5 @@ class PartWorkbench ( Workbench ): return "PartGui::Workbench" Gui.addWorkbench(PartWorkbench()) + +FreeCAD.__unit_test__ += [ "TestPartGui" ] diff --git a/src/Mod/PartDesign/Init.py b/src/Mod/PartDesign/Init.py index 1a95a67fe4..3d708988e5 100644 --- a/src/Mod/PartDesign/Init.py +++ b/src/Mod/PartDesign/Init.py @@ -24,3 +24,5 @@ #* * #* Juergen Riegel 2002 * #***************************************************************************/ + +FreeCAD.__unit_test__ += [ "TestPartDesignApp" ] diff --git a/src/Mod/PartDesign/InitGui.py b/src/Mod/PartDesign/InitGui.py index 3d994c3e18..f25bd79358 100644 --- a/src/Mod/PartDesign/InitGui.py +++ b/src/Mod/PartDesign/InitGui.py @@ -62,3 +62,5 @@ class PartDesignWorkbench ( Workbench ): return "PartDesignGui::Workbench" Gui.addWorkbench(PartDesignWorkbench()) + +FreeCAD.__unit_test__ += [ "TestPartDesignGui" ] diff --git a/src/Mod/Path/Init.py b/src/Mod/Path/Init.py index 25be32004e..9fc5824f9c 100644 --- a/src/Mod/Path/Init.py +++ b/src/Mod/Path/Init.py @@ -28,3 +28,5 @@ ParGrp = App.ParamGet("System parameter:Modules").GetGroup("Path") ParGrp.SetString("HelpIndex", "Path/Help/index.html") ParGrp.SetString("WorkBenchName", "Path") ParGrp.SetString("WorkBenchModule", "PathWorkbench.py") + +FreeCAD.__unit_test__ += [ "TestPathApp" ] diff --git a/src/Mod/Sketcher/Init.py b/src/Mod/Sketcher/Init.py index 6f038fb0a8..78971447c7 100644 --- a/src/Mod/Sketcher/Init.py +++ b/src/Mod/Sketcher/Init.py @@ -25,3 +25,5 @@ #* Juergen Riegel 2002 * #***************************************************************************/ + +FreeCAD.__unit_test__ += [ "TestSketcherApp" ] diff --git a/src/Mod/Sketcher/InitGui.py b/src/Mod/Sketcher/InitGui.py index b8c7571b01..5b3e5e3f02 100644 --- a/src/Mod/Sketcher/InitGui.py +++ b/src/Mod/Sketcher/InitGui.py @@ -32,11 +32,11 @@ class SketcherWorkbench ( Workbench ): - "Sketcher workbench object" + "Sketcher workbench object" def __init__(self): self.__class__.Icon = FreeCAD.getResourceDir() + "Mod/Sketcher/Resources/icons/SketcherWorkbench.svg" self.__class__.MenuText = "Sketcher" - self.__class__.ToolTip = "Sketcher workbench" + self.__class__.ToolTip = "Sketcher workbench" def Initialize(self): # load the module @@ -51,3 +51,5 @@ class SketcherWorkbench ( Workbench ): return "SketcherGui::Workbench" Gui.addWorkbench(SketcherWorkbench()) + +FreeCAD.__unit_test__ += [ "TestSketcherGui" ] diff --git a/src/Mod/Spreadsheet/Init.py b/src/Mod/Spreadsheet/Init.py index 272bb5c095..a8b1be9eb3 100644 --- a/src/Mod/Spreadsheet/Init.py +++ b/src/Mod/Spreadsheet/Init.py @@ -40,3 +40,5 @@ ParGrp.SetString("WorkBenchModule", "SpreadsheetWorkbench.py") # add Import/Export types App.addImportType("Excel spreadsheet (*.xlsx)","importXLSX") +App.__unit_test__ += [ "TestSpreadsheet" ] + diff --git a/src/Mod/TechDraw/Init.py b/src/Mod/TechDraw/Init.py index 4160106fc5..4a21cb375e 100644 --- a/src/Mod/TechDraw/Init.py +++ b/src/Mod/TechDraw/Init.py @@ -24,3 +24,5 @@ #* * #* Juergen Riegel 2002 * #***************************************************************************/ + +FreeCAD.__unit_test__ += [ "TestTechDrawApp" ] diff --git a/src/Mod/Test/Init.py b/src/Mod/Test/Init.py index a1e7ef580b..1a249c7d2b 100644 --- a/src/Mod/Test/Init.py +++ b/src/Mod/Test/Init.py @@ -2,7 +2,7 @@ # (c) 2001 Juergen Riegel #*************************************************************************** -#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 * +#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 * #* * #* This file is part of the FreeCAD CAx development system. * #* * @@ -13,14 +13,21 @@ #* for detail see the LICENCE text file. * #* * #* FreeCAD is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * +#* but WITHOUT ANY WARRANTY; without even the implied warranty of * #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * #* GNU Lesser General Public License for more details. * #* * #* You should have received a copy of the GNU Library General Public * -#* License along with FreeCAD; if not, write to the Free Software * +#* License along with FreeCAD; if not, write to the Free Software * #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * #* USA * #* * #* Juergen Riegel 2002 * #***************************************************************************/ + +# Base system tests +FreeCAD.__unit_test__ += [ "BaseTests", + "UnitTests", + "Document", + "UnicodeTests", + "TestPythonSyntax" ] diff --git a/src/Mod/Test/InitGui.py b/src/Mod/Test/InitGui.py index c64cba0dfd..ddee8219ea 100644 --- a/src/Mod/Test/InitGui.py +++ b/src/Mod/Test/InitGui.py @@ -77,3 +77,9 @@ class TestWorkbench ( Workbench ): self.appendMenu("Inventor View",list) Gui.addWorkbench(TestWorkbench()) + +# Base system tests +FreeCAD.__unit_test__ += [ "Workbench", + "Menu", + "Menu.MenuDeleteCases", + "Menu.MenuCreateCases" ] diff --git a/src/Mod/Test/TestApp.py b/src/Mod/Test/TestApp.py index 1f7c58ae80..6f851e2e0d 100644 --- a/src/Mod/Test/TestApp.py +++ b/src/Mod/Test/TestApp.py @@ -54,35 +54,8 @@ def tryLoadingTest(testName): return LoadFailed(testName) def All(): - # Base system tests - tests = [ "UnicodeTests", - "Document", - "UnitTests", - "BaseTests" ] - - # Base system gui test - if (FreeCAD.GuiUp == 1): - tests += [ "Workbench", - "Menu" ] - - # add the module tests - tests += [ "TestFem", - "MeshTestsApp", - "TestSketcherApp", - "TestPartApp", - "TestPartDesignApp", - "TestSpreadsheet", - "TestTechDrawApp", - "TestPathApp", - "TestPythonSyntax"] - - # gui tests of modules - if (FreeCAD.GuiUp == 1): - tests += [ "TestSketcherGui", - "TestPartGui", - "TestPartDesignGui", - "TestDraft", - "TestArch" ] + # Registered tests + tests = FreeCAD.__unit_test__ suite = unittest.TestSuite() diff --git a/src/Mod/Test/TestGui.py b/src/Mod/Test/TestGui.py index 0702226a62..f36a19774c 100644 --- a/src/Mod/Test/TestGui.py +++ b/src/Mod/Test/TestGui.py @@ -40,28 +40,12 @@ class TestCmd: """Opens a Qt dialog with all inserted unit tests""" def Activated(self): import QtUnitGui + tests = FreeCAD.__unit_test__ + QtUnitGui.addTest("TestApp.All") QtUnitGui.setTest("TestApp.All") - QtUnitGui.addTest("BaseTests") - QtUnitGui.addTest("UnitTests") - QtUnitGui.addTest("Document") - QtUnitGui.addTest("UnicodeTests") - QtUnitGui.addTest("MeshTestsApp") - QtUnitGui.addTest("TestFem") - QtUnitGui.addTest("TestSketcherApp") - QtUnitGui.addTest("TestPartApp") - QtUnitGui.addTest("TestPartDesignApp") - QtUnitGui.addTest("TestPartDesignGui") - QtUnitGui.addTest("TestPathApp") - QtUnitGui.addTest("TestSpreadsheet") - QtUnitGui.addTest("TestDraft") - QtUnitGui.addTest("TestArch") - QtUnitGui.addTest("TestTechDrawApp") - QtUnitGui.addTest("Workbench") - QtUnitGui.addTest("Menu") - QtUnitGui.addTest("Menu.MenuDeleteCases") - QtUnitGui.addTest("Menu.MenuCreateCases") - QtUnitGui.addTest("TestPythonSyntax") + for test in tests: + QtUnitGui.addTest(test) def GetResources(self): return {'MenuText': 'Self-test...', 'ToolTip': 'Runs a self-test to check if the application works properly'}