Example #1
0
 def clearTestData(self):
     PrintFormatter.printHeader('Clearing all old test data', level=3)
     cxData = self._createComponent(cxComponents.CustusXData)
     #custusx = self._createComponent(cxComponents.CustusX)
     testRunner = self._getTestRunner()
     testRunner.resetCustusXDataRepo(cxData.sourcePath())  
     testRunner.removeResultFiles(outPath=self._getTestResultsPath())
 def removePreviousJob(self):
     'remove all stuff from previous run of the installer'
     PrintFormatter.printHeader('Removing files from previous install', 3)
     shell.rm_r('%s/%s' % (self.install_root, self.system_base_name))
     shell.rm_r('%s/%s*.%s' % (self.installer_path, self.system_base_name, self._getInstallerPackageSuffix()))
     shell.removeTree('%s/temp/Install' % self.root_dir)
     shell.removeTree('%s/%s' % (self.install_root, self.system_base_name))
 def _installWindowsNSISExe(self, filename):
     installfolder = '%s\%s' % (self.install_root, self.system_base_name)
     installfolder = installfolder.replace("/", "\\")
     filename = filename.replace("/", "\\")
     cmd = ["%s" % filename, "/S", "/D=%s" % installfolder]
     shell.run(cmd, convertToString=False)
     PrintFormatter.printInfo('Installed \n\t%s\nto folder \n\t%s ' % (filename, self.install_root))
Example #4
0
 def runCatchTests(self, tag):
     PrintFormatter.printHeader('Run catch tests using tag %s' % tag, level=3)
     # Run all Catch tests and write them in xml format to ./Catch.<tagname>.TestResults.xml
     custusx = self._createComponent(cxComponents.CustusX)
     catchDir = '%s/bin' % custusx.buildPath()
     outpath = self._getTestResultsPath()
     self._getTestRunner().runCatch(catchDir, tag=tag, outpath=outpath)
Example #5
0
 def runCatchTestsWrappedInCTest(self, tag):
     PrintFormatter.printHeader('Run catch tests wrapped in ctest', level=2)
     custusx = self._createComponent(cxComponents.CustusX)
     appPath = '%s/bin' % custusx.buildPath()
     outpath = self._getTestResultsPath()
     testRunner = self._getTestRunner()
     testRunner.runCatchTestsWrappedInCTestGenerateJUnit(tag, appPath, outpath)
Example #6
0
 def publishUserDocs(self, targetFolder):
     PrintFormatter.printHeader('Publish User Docs to server', level=2)
     target = self.assembly.controlData.publish_user_documentation_target
     custusx = self._createComponent(cxComponents.CustusX)
     source = '%s/doc/html_pure' % custusx.buildPath()
     target_path = '%s/%s' % (target.path, targetFolder)
     self.publish(source, target.server, target.user, target_path)
 def testInstallation(self):
     PrintFormatter.printHeader('Test installation', level=2)
     appPath = self._getInstalledBinaryPath()
     self._testExecutable(appPath, 'Catch', '-h')
     self._testExecutable(appPath, self.system_base_name) # defaults to CustusX
     self._testExecutable(appPath, 'OpenIGTLinkServer')
     self._testExecutable(appPath, 'LogConsole')
Example #8
0
 def publishUserDocs(self, targetFolder):
     PrintFormatter.printHeader('Publish User Docs to server', level=2)
     target = self.assembly.controlData.publish_user_documentation_target
     custusx = self._createComponent(cxComponents.CustusX)
     source = '%s/doc/html_pure' %  custusx.buildPath()
     target_path = '%s/%s' % (target.path, targetFolder)        
     self.publish(source, target.server, target.user, target_path)
Example #9
0
 def _movePackageToStandardLocation(self):
     installer = self.createInstallerObject(installer_path=self._getInitialInstallerPackagePath())
     #filepattern = installer.getInstallerPackagePattern()
     source = installer.findInstallerFile()
     dest = '%s/%s' % (self._getStandardInstallerPackagePath(), os.path.basename(source))
     PrintFormatter.printInfo('Copying package files from [%s] to [%s]'%(source,dest))
     shell.cp(source, dest)
Example #10
0
 def _copyFolder(self, source, targetPath):
     targetFolder = os.path.split(source)[1]
     fullTargetPath = '%s/%s' % (targetPath, targetFolder)
     shutil.rmtree(fullTargetPath, True)
     shutil.copytree(source, fullTargetPath)
     PrintFormatter.printInfo("copied folder %s into %s" %
                              (source, targetPath))
Example #11
0
 def _moveDevDocsToStandardLocation(self):
     installer_path=self._getInitialInstallerPackagePath()
     source = '%s/%s' % (installer_path, "doc/html_dev")
     if os.path.exists(source):
         dest = '%s/%s' % (self._getStandardInstallerPackagePath(), os.path.basename(source))
         PrintFormatter.printInfo('Copying dev doc files from [%s] to [%s]'%(source,dest))
         shutil.copytree(source, dest)
Example #12
0
 def removePreviousJob(self):
     'remove all stuff from previous run of the installer'
     PrintFormatter.printHeader('Removing files from previous install', 3)
     shell.rm_r('%s/%s' % (self.install_root, self.system_base_name))
     shell.rm_r('%s/%s*.%s' % (self.installer_path, self.system_base_name, self._getInstallerPackageSuffix()))
     shell.removeTree('%s/temp/Install' % self.root_dir)
     shell.removeTree('%s/%s' % (self.install_root, self.system_base_name))
Example #13
0
 def _installWindowsNSISExe(self, filename):
     installfolder = '%s\%s' % (self.install_root, self.system_base_name)
     installfolder = installfolder.replace("/", "\\")
     filename = filename.replace("/", "\\")
     cmd = ["%s" % filename, "/S", "/D=%s" % installfolder]
     shell.run(cmd, convertToString=False)
     PrintFormatter.printInfo('Installed \n\t%s\nto folder \n\t%s ' % (filename, self.install_root))
Example #14
0
 def publishCoverageInfo(self, targetFolder):
     PrintFormatter.printHeader('Publish Coverage Info to server', level=2)
     target = self.assembly.controlData.publish_coverage_info_target
     custusx = self._createComponent(cxComponents.CustusX)
     source = '%s/gcov/coverage_info' %  self.assembly.controlData.getRootDir()
     target_path = '%s/%s' % (target.path, targetFolder)        
     self.publish(source, target.server, target.user, target_path)
Example #15
0
 def buildAllComponents(self):
     self.assembly.controlData.printSettings()
     PrintFormatter.printHeader('Build all components', level=2)
     self.assembly.selectAllLibraries()
     self.assembly.process(checkout=True,
                          configure=True,
                          build=True)
Example #16
0
 def clearTestData(self):
     PrintFormatter.printHeader('Clearing all old test data', level=3)
     cxData = self._createComponent(cxComponents.CustusXData)
     #custusx = self._createComponent(cxComponents.CustusX)
     testRunner = self._getTestRunner()
     testRunner.resetCustusXDataRepo(cxData.sourcePath())
     testRunner.removeResultFiles(outPath=self._getTestResultsPath())
Example #17
0
 def _testExecutable(self, path, filename, arguments=''):
     PrintFormatter.printHeader('Test executable %s' % filename, level=3)
     fullname = '%s/%s%s' % (path, filename, self._getExecutableSuffix())
     cx.utils.cxUtilities.assertTrue(
         os.path.exists(fullname),
         'Checking existence of installed executable %s' % fullname)
     cmd = '%s %s' % (fullname, arguments)
     self._runApplicationForDuration(cmd, timeout=3)
Example #18
0
 def testInstallation(self):
     PrintFormatter.printHeader('Test installation', level=2)
     appPath = self._getInstalledBinaryPath()
     self._testExecutable(appPath, 'Catch', '-h')
     self._testExecutable(appPath,
                          self.system_base_name)  # defaults to CustusX
     self._testExecutable(appPath, 'OpenIGTLinkServer')
     self._testExecutable(appPath, 'LogConsole')
    def _operation(self, lib, methodname):
            #print '\n================== %s %s========================' % (methodname, lib.name())
            #print '\n%s %-*s %s' % ('='*20, 20, methodname + " " + lib.name(), '='*20)
        text = methodname+" "+lib.name()
        PrintFormatter.printHeader(text)
#            print '\n%s %s' % ('='*20, " %s ".ljust(60, '=')%text)
        method = getattr(lib, methodname)
        method()
Example #20
0
 def runCatchTestsWrappedInCTest(self, tag):
     PrintFormatter.printHeader('Run catch tests wrapped in ctest', level=2)
     custusx = self._createComponent(cxComponents.CustusX)
     appPath = '%s/bin' % custusx.buildPath()
     outpath = self._getTestResultsPath()
     testRunner = self._getTestRunner()
     testRunner.runCatchTestsWrappedInCTestGenerateJUnit(
         tag, appPath, outpath)
Example #21
0
 def publishCoverageInfo(self, targetFolder):
     PrintFormatter.printHeader('Publish Coverage Info to server', level=2)
     target = self.assembly.controlData.publish_coverage_info_target
     custusx = self._createComponent(cxComponents.CustusX)
     source = '%s/gcov/coverage_info' % self.assembly.controlData.getRootDir(
     )
     target_path = '%s/%s' % (target.path, targetFolder)
     self.publish(source, target.server, target.user, target_path)
Example #22
0
 def runCatchTests(self, tag):
     PrintFormatter.printHeader('Run catch tests using tag %s' % tag,
                                level=3)
     # Run all Catch tests and write them in xml format to ./Catch.<tagname>.TestResults.xml
     custusx = self._createComponent(cxComponents.CustusX)
     catchDir = '%s/bin' % custusx.buildPath()
     outpath = self._getTestResultsPath()
     self._getTestRunner().runCatch(catchDir, tag=tag, outpath=outpath)
 def _operation(self, lib, methodname):
     #print '\n================== %s %s========================' % (methodname, lib.name())
     #print '\n%s %-*s %s' % ('='*20, 20, methodname + " " + lib.name(), '='*20)
     text = methodname + " " + lib.name()
     PrintFormatter.printHeader(text)
     #            print '\n%s %s' % ('='*20, " %s ".ljust(60, '=')%text)
     method = getattr(lib, methodname)
     method()
Example #24
0
 def installPackage(self):
     '''
     Install the package to the default location on this machine,
     based on root_dir if necessary.
     '''
     PrintFormatter.printHeader('Install package', level=3)
     file = self.findInstallerFile()
     PrintFormatter.printInfo('Installing file %s' % file)
     self._installFile(file)
Example #25
0
 def publishUserDocs(self, artefactFolder, targetFolder):
     PrintFormatter.printHeader('Publish User Docs to server', level=2)
     source = '%s/html_pure' %  artefactFolder
     if not os.path.exists(source):
         PrintFormatter.printInfo("Warning folder don't exist: [%s]" % source)
     target = self.assembly.controlData.publish_user_documentation_target
     custusx = self._createComponent(cxComponents.CustusX)
     target_path = '%s/%s' % (target.path, targetFolder)        
     self.publish(source, target.server, target.user, target_path)
Example #26
0
 def _moveDevDocsToStandardLocation(self):
     installer_path = self._getInitialInstallerPackagePath()
     source = '%s/%s' % (installer_path, "doc/html_dev")
     if os.path.exists(source):
         dest = '%s/%s' % (self._getStandardInstallerPackagePath(),
                           os.path.basename(source))
         PrintFormatter.printInfo(
             'Copying dev doc files from [%s] to [%s]' % (source, dest))
         shutil.copytree(source, dest)
Example #27
0
    def publish(self, source, server, user, target_path):
        PrintFormatter.printInfo('Publishing contents of [%s] to server [%s], remote path [%s]' % (source, server, target_path))

        transfer = cx.utils.cxSSH.RemoteFileTransfer()
        transfer.connect(server, user)
        #transfer.remote_mkdir(targetBasePath)
        transfer.remote_rmdir(target_path) # remove old content if any
        transfer.copyFolderContentsToRemoteServer(source, target_path);
        transfer.close()
Example #28
0
 def installPackage(self):
     '''
     Install the package to the default location on this machine,
     based on root_dir if necessary.
     '''
     PrintFormatter.printHeader('Install package', level=3)
     file = self.findInstallerFile()
     PrintFormatter.printInfo('Installing file %s' % file)
     self._installFile(file)
Example #29
0
 def _movePackageToStandardLocation(self):
     installer = self.createInstallerObject(
         installer_path=self._getInitialInstallerPackagePath())
     #filepattern = installer.getInstallerPackagePattern()
     source = installer.findInstallerFile()
     dest = '%s/%s' % (self._getStandardInstallerPackagePath(),
                       os.path.basename(source))
     PrintFormatter.printInfo('Copying package files from [%s] to [%s]' %
                              (source, dest))
     shell.cp(source, dest)
    def checkoutCustusXAndData(self):
        'checkout only CustusX and data. Required if the first build step was not run, f.ex. during integration tests'
        assembly = self.cxBuilder.assembly
        PrintFormatter.printHeader('Checkout libraries required for integration test', level=2)
        #custusx = assembly.getComponent(cx.build.cxComponents.CustusX)
        #cxdata = assembly.getComponent(cx.build.cxComponents.CustusXData)

        #assembly.selectLibraries([custusx.name(), cxdata.name()])
        assembly.selectTestLibraries()
        assembly.process(checkout=True)
Example #31
0
 def publishUserDocs(self, artefactFolder, targetFolder):
     PrintFormatter.printHeader('Publish User Docs to server', level=2)
     source = '%s/html_pure' % artefactFolder
     if not os.path.exists(source):
         PrintFormatter.printInfo("Warning folder don't exist: [%s]" %
                                  source)
     target = self.assembly.controlData.publish_user_documentation_target
     custusx = self._createComponent(cxComponents.CustusX)
     target_path = '%s/%s' % (target.path, targetFolder)
     self.publish(source, target.server, target.user, target_path)
Example #32
0
    def removePreviousInstaller(self):
        PrintFormatter.printHeader('Removing previous installer', 3);

        shell.removeTree(self._getStandardInstallerPackagePath()); # remove everything

        initialInstaller = self.createInstallerObject(installer_path=self._getInitialInstallerPackagePath())
        shell.rm_r(initialInstaller._getInstallerPackagePattern())
        
        standardInstaller = self.createInstallerObject()
        shell.rm_r(standardInstaller._getInstallerPackagePattern())
Example #33
0
    def publish(self, source, server, user, target_path):
        PrintFormatter.printInfo(
            'Publishing contents of [%s] to server [%s], remote path [%s]' %
            (source, server, target_path))

        transfer = cx.utils.cxSSH.RemoteFileTransfer()
        transfer.connect(server, user)
        #transfer.remote_mkdir(targetBasePath)
        #transfer.remote_rmdir(target_path) # remove old content if any
        transfer.copyFolderContentsToRemoteServer(source, target_path)
        transfer.close()
Example #34
0
 def _removeLocalTags(self):    
     '''
     Remove local tags,
     this removes jenkins tags that hides our own.
     # http://stackoverflow.com/questions/1841341/remove-local-tags-that-are-no-longer-on-the-remote-repository
     '''
     PrintFormatter.printInfo('Removing local git tags ...')
     shell.changeDir(self.source_custusx_path)
     # shell.run('git tag -l | xargs git tag -d') no good on windows
     # shell.run('git fetch')
     shell.run('git fetch origin --prune --tags')
Example #35
0
 def runCTest(self, path, outpath=None, outfile=None):
     'Run all ctest tests at path and write them in ctest xml format to outfile'
     if not outfile:
         outfile = '%s/CTestResults.xml' % outpath
     PrintFormatter.printInfo('Run ctest, results to %s' % outfile)
     shell.changeDir(path)
     shell.rm_r('%s/Testing/' % path, "[0-9]*")
     shell.rm_r(outfile)
     shell.run('ctest -D ExperimentalTest --no-compress-output', ignoreFailure=True)
     temp_dir = shell.head(os.path.join(path, 'Testing', 'TAG'), 1)
     shell.cp(os.path.join(path, 'Testing', temp_dir, 'Test.xml'), '%s' % outfile)
Example #36
0
 def _installLinuxZip(self, filename):
     temp_path = '%s/temp/Install' % self.root_dir
     shell.removeTree(temp_path)
     shell.changeDir(temp_path)
     shell.run('tar -zxvf %s' % (filename))  # extract to path
     corename = os.path.basename(filename).split('.tar.gz')[0]
     unpackedfolder = "%s/%s" % (temp_path, corename)
     installfolder = '%s' % self.install_root
     shell.changeDir(installfolder)
     shell.run('cp -r %s/* %s' % (unpackedfolder, installfolder))
     PrintFormatter.printInfo('Installed \n\t%s\nto folder \n\t%s ' % (filename, installfolder))
Example #37
0
 def _installLinuxZip(self, filename):
     temp_path = '%s/temp/Install' % self.root_dir
     shell.removeTree(temp_path)
     shell.changeDir(temp_path)
     shell.run('tar -zxvf %s' % (filename))  # extract to path
     corename = os.path.basename(filename).split('.tar.gz')[0]
     unpackedfolder = "%s/%s" % (temp_path, corename)
     installfolder = '%s' % self.install_root
     shell.changeDir(installfolder)
     shell.run('cp -r %s/* %s' % (unpackedfolder, installfolder))
     PrintFormatter.printInfo('Installed \n\t%s\nto folder \n\t%s ' % (filename, installfolder))
Example #38
0
 def searchForFileWithPattern(self, pattern):
     '''
     find the file matching the pattern
     '''
     PrintFormatter.printInfo('Looking for installers with pattern: %s' % pattern)
     files = glob.glob(pattern)
     cx.utils.cxUtilities.assertTrue(len(files) == 1,
                     'Found %i install files, requiring 1: \n pattern: %s\n Found:\n %s' % 
                     (len(files), pattern, ' \n'.join(files)))
     file = files[0]
     return file
Example #39
0
 def _writeCTestFileForCatchTests(self, path, targetFile, testnames):
     PrintFormatter.printInfo('Generate ctest file %s'%targetFile)
     lines = ['# Autogenerated by CustusX test scripts',
              '# Converts Catch unit test framework to one-test-per-process',
              '# ctest setup.'
                ]
     catchExe = self._getCatchExecutable(path)
     for testname in testnames:
         line = 'ADD_TEST("%s" %s "%s")' % (testname, catchExe, testname)
         lines.append(line)
     cx.utils.cxUtilities.writeToNewFile(filename=targetFile, text='\n'.join(lines))
Example #40
0
 def _removeLocalTags(self):
     '''
     Remove local tags,
     this removes jenkins tags that hides our own.
     # http://stackoverflow.com/questions/1841341/remove-local-tags-that-are-no-longer-on-the-remote-repository
     '''
     PrintFormatter.printInfo('Removing local git tags ...')
     shell.changeDir(self.source_custusx_path)
     # shell.run('git tag -l | xargs git tag -d') no good on windows
     # shell.run('git fetch')
     shell.run('git fetch origin --prune --tags')
Example #41
0
 def _runCTestUnitTests(self):
     PrintFormatter.printHeader('Run ctest tests', level=3)
     # Run all tests and write them in xml format to ctest.unit.*.xml,
     # ctest.xml means ctest format, junit.xml means junit format
     custusx = self._createComponent(cxComponents.CustusX)
     testRunner = self._getTestRunner()
     basename = 'ctest.unit.testresults'
     outpath = self._getTestResultsPath()
     ctestfile = '%s/%s.ctest.xml' % (outpath, basename)
     testRunner.runCTest(custusx.buildPath(), outfile=ctestfile)
     junitfile = '%s/%s.junit.xml' % (outpath, basename)
     testRunner.convertCTestFile2JUnit(ctestfile, junitfile)
Example #42
0
    def removePreviousInstaller(self):
        PrintFormatter.printHeader('Removing previous installer', 3)

        shell.removeTree(self._getStandardInstallerPackagePath())
        # remove everything

        initialInstaller = self.createInstallerObject(
            installer_path=self._getInitialInstallerPackagePath())
        shell.rm_r(initialInstaller._getInstallerPackagePattern())

        standardInstaller = self.createInstallerObject()
        shell.rm_r(standardInstaller._getInstallerPackagePattern())
Example #43
0
 def findInstallerFile(self):
     '''
     Find the full name of the installer file.
     '''
     pattern = self._getInstallerPackagePattern()
     PrintFormatter.printInfo('Looking for installers with pattern: %s' % pattern)
     files = glob.glob(pattern)
     cx.utils.cxUtilities.assertTrue(len(files) == 1,
                     'Found %i install files, requiring 1: \n pattern: %s\n Found:\n %s' % 
                     (len(files), pattern, ' \n'.join(files)))
     file = files[0]
     return file
Example #44
0
 def runCppCheck(self):
     PrintFormatter.printHeader('Run CppCheck', level=2)
     custusx = self._createComponent(cxComponents.CustusX)
     sourceDir = custusx.sourcePath()
     rootDir = self.assembly.controlData.getRootDir()
     shell.run(['cppcheck',
             '--enable=all',
             '--xml-version=2',
             '-i%s/source/ThirdParty/' % sourceDir,
             '-i%s/source/resource/testUtilities/cisst_code/' % sourceDir,
             '%s/source 2> %s/cppcheck-result.xml' % (sourceDir, rootDir)
             ])
Example #45
0
 def _runCTestUnitTests(self):
     PrintFormatter.printHeader('Run ctest tests', level=3)
     # Run all tests and write them in xml format to ctest.unit.*.xml,
     # ctest.xml means ctest format, junit.xml means junit format
     custusx = self._createComponent(cxComponents.CustusX)
     testRunner = self._getTestRunner()
     basename = 'ctest.unit.testresults'
     outpath = self._getTestResultsPath()
     ctestfile = '%s/%s.ctest.xml' % (outpath, basename)
     testRunner.runCTest(custusx.buildPath(), outfile=ctestfile)
     junitfile='%s/%s.junit.xml' % (outpath, basename)
     testRunner.convertCTestFile2JUnit(ctestfile, junitfile)
Example #46
0
    def generateCoverageReport(self):
        '''
        Given that lcov is initialized and ctest is run,
        Generate html output from the gcov data.
        '''
        PrintFormatter.printHeader('Generating coverage report', level=2)
        gcovTempDir = '%s/gcov' % self.assembly.controlData.getRootDir()
        gcovResultDir = '%s/gcov/coverage_info' % self.assembly.controlData.getRootDir()
        custusx = self._createComponent(cxComponents.CustusX)
        buildDir = custusx.buildPath()
        sourceDir = custusx.sourcePath()

        shell.run(['lcov',
                '--capture',
                '--directory %s' % buildDir,
                '--output-file %s/cx_test.gcov' % gcovTempDir 
                ])
        shell.run(['lcov',
                '--add-tracefile %s/cx_base.gcov' % gcovTempDir,
                '--add-tracefile %s/cx_test.gcov' % gcovTempDir,
                '--output-file %s/cx_total.gcov' % gcovTempDir
                ])
        shell.run(['lcov',
                '--extract %s/cx_total.gcov "%s/source/*"' % (gcovTempDir, sourceDir),
                '--output-file %s/cx_clean0.gcov' % gcovTempDir
                ])
        filterList = ["/opt/*",
                      "/Library/Frameworks/*",
                      "/external/*",
                      "/external_code/*",
                      "/Library/*",
                      "/include/boost/*",
                      "/include/c++/*",
                      "/include/qt4/*",
                      "/usr/*",
                      "/working/Tube-Segmentation-Framework/*", 
                      "/working/ISB_DataStreaming/*", 
                      "/working/Level-Set-Segmentation/*", 
                      "/moc*.cxx",
                      "/CustusX/build_*",
                      "/Examples/*"]
        filterList = ["/ThirdParty/*",
                      "/moc*.cxx",
                      "/Examples/*"]
        fileFilter = " ".join(filterList)
        shell.run(['lcov',
                '--remove %s/cx_clean0.gcov %s' % (gcovTempDir, fileFilter),
                '--output-file %s/cx_clean1.gcov' % gcovTempDir
                ])
        shell.run(['genhtml',
                '%s/cx_clean1.gcov' % gcovTempDir,
                '--output-directory %s' % gcovResultDir
                ])
Example #47
0
 def runCTest(self, path, outpath=None, outfile=None):
     'Run all ctest tests at path and write them in ctest xml format to outfile'
     if not outfile:
         outfile = '%s/CTestResults.xml' % outpath
     PrintFormatter.printInfo('Run ctest, results to %s' % outfile)
     shell.changeDir(path)
     shell.rm_r('%s/Testing/' % path, "[0-9]*")
     shell.rm_r(outfile)
     shell.run('ctest -D ExperimentalTest --no-compress-output',
               ignoreFailure=True)
     temp_dir = shell.head(os.path.join(path, 'Testing', 'TAG'), 1)
     shell.cp(os.path.join(path, 'Testing', temp_dir, 'Test.xml'),
              '%s' % outfile)
Example #48
0
 def resetCustusXDataRepo(self, path):
     '''
     Reset the test data git repo,
     and delete the temp subfolder.
     This matches the structure of the CustusX git data repo.
     '''
     PrintFormatter.printInfo('Reset/Clear Data repository...')
     # clear local modifications in the data folder - the tests might cause these changes
     shell.changeDir(path)
     shell.run('git fetch --all')
     shell.run('git reset --hard')
     tempDir = "%s/temp" % path
     shell.removeTree(tempDir)
Example #49
0
 def resetCustusXDataRepo(self, path):
     '''
     Reset the test data git repo,
     and delete the temp subfolder.
     This matches the structure of the CustusX git data repo.
     '''
     PrintFormatter.printInfo('Reset/Clear Data repository...')
     # clear local modifications in the data folder - the tests might cause these changes
     shell.changeDir(path)
     shell.run('git fetch --all')
     shell.run('git reset --hard')
     tempDir = "%s/temp" % path
     shell.removeTree(tempDir)
Example #50
0
 def configure(self):
     builder = self._getBuilder()
     add = builder.addCMakeOption
     add('CTK_QT_VERSION:STRING', 5)
     add('CTK_ENABLE_DICOM:BOOL', 'ON')
     add('CTK_LIB_DICOM/Widgets:BOOL', 'ON')
     add('CTK_ENABLE_PluginFramework:BOOL', 'ON')
     #add('CTK_BUILD_SHARED_LIBS:BOOL', self.controlData.getBuildShared())
     add('CTK_BUILD_SHARED_LIBS:BOOL', 'ON')
     add('CMAKE_PREFIX_PATH:PATH', "/opt/local/libexec/qt5-mac")
     builder.configureCMake()
     PrintFormatter.printInfo('Build CTK during configure step, in order to create CTKConfig.cmake')
     self.build()
Example #51
0
 def runCppCheck(self):
     PrintFormatter.printHeader('Run CppCheck', level=2)
     custusx = self._createComponent(cxComponents.CustusX)
     sourceDir = custusx.sourcePath()
     rootDir = self.assembly.controlData.getRootDir()
     shell.run([
         'cppcheck', '--enable=all', '--xml-version=2',
         '-i%s/source/ThirdParty/' % sourceDir,
         '-i%s/source/plugins/org.custusx.anglecorrection/core/Tests/catch.hpp'
         % sourceDir,
         '-i%s/source/resource/testUtilities/cisst_code/' % sourceDir,
         '%s/source 2> %s/cppcheck-result.xml' % (sourceDir, rootDir)
     ])
Example #52
0
 def _writeCTestFileForCatchTests(self, path, targetFile, testnames):
     PrintFormatter.printInfo('Generate ctest file %s' % targetFile)
     lines = [
         '# Autogenerated by CustusX test scripts',
         '# Converts Catch unit test framework to one-test-per-process',
         '# ctest setup.'
     ]
     catchExe = self._getCatchExecutable(path)
     for testname in testnames:
         line = 'ADD_TEST("%s" %s "%s")' % (testname, catchExe, testname)
         lines.append(line)
     cx.utils.cxUtilities.writeToNewFile(filename=targetFile,
                                         text='\n'.join(lines))
Example #53
0
    def generateCoverageReport(self):
        '''
        Given that lcov is initialized and ctest is run,
        Generate html output from the gcov data.
        '''
        PrintFormatter.printHeader('Generating coverage report', level=2)
        gcovTempDir = '%s/gcov' % self.assembly.controlData.getRootDir()
        gcovResultDir = '%s/gcov/coverage_info' % self.assembly.controlData.getRootDir(
        )
        custusx = self._createComponent(cxComponents.CustusX)
        buildDir = custusx.buildPath()
        sourceDir = custusx.sourcePath()

        shell.run([
            'lcov', '--capture',
            '--directory %s' % buildDir,
            '--output-file %s/cx_test.gcov' % gcovTempDir
        ])
        shell.run([
            'lcov',
            '--add-tracefile %s/cx_base.gcov' % gcovTempDir,
            '--add-tracefile %s/cx_test.gcov' % gcovTempDir,
            '--output-file %s/cx_total.gcov' % gcovTempDir
        ])
        shell.run([
            'lcov',
            '--extract %s/cx_total.gcov "%s/source/*"' %
            (gcovTempDir, sourceDir),
            '--output-file %s/cx_clean0.gcov' % gcovTempDir
        ])
        filterList = [
            "/opt/*", "/Library/Frameworks/*", "/external/*",
            "/external_code/*", "/Library/*", "/include/boost/*",
            "/include/c++/*", "/include/qt4/*", "/usr/*",
            "/working/Tube-Segmentation-Framework/*",
            "/working/ISB_DataStreaming/*",
            "/working/Level-Set-Segmentation/*", "/moc*.cxx",
            "/CustusX/build_*", "/Examples/*"
        ]
        filterList = ["/ThirdParty/*", "/moc*.cxx", "/Examples/*"]
        fileFilter = " ".join(filterList)
        shell.run([
            'lcov',
            '--remove %s/cx_clean0.gcov %s' % (gcovTempDir, fileFilter),
            '--output-file %s/cx_clean1.gcov' % gcovTempDir
        ])
        shell.run([
            'genhtml',
            '%s/cx_clean1.gcov' % gcovTempDir,
            '--output-directory %s' % gcovResultDir
        ])
Example #54
0
 def runLineCounter(self):
     PrintFormatter.printHeader('Run Line counter SLOCCOUNT', level=2)
     custusx = self._createComponent(cxComponents.CustusX)
     sourceDir = custusx.sourcePath()
     rootDir = self.assembly.controlData.getRootDir()
     results_file = '%s/sloccount_raw.sc' % rootDir 
     shell.run(['sloccount',
             '--duplicates --wide --details',
             '%s >%s' % (sourceDir, results_file)
             ])
     
     cleaned_results_file = '%s/sloccount.sc' % rootDir 
     filter = '--remove="3rdParty/ config/ install/ /data/"'
     cx.utils.cxClean_sloccount.clean_sloccount(results_file, cleaned_results_file, filter)
Example #55
0
 def findInstallerFile(self):
     '''
     Find the full name of the installer file.
     '''
     pattern = self._getInstallerPackagePattern()
     PrintFormatter.printInfo('Looking for installers with pattern: %s' %
                              pattern)
     files = glob.glob(pattern)
     cx.utils.cxUtilities.assertTrue(
         len(files) == 1,
         'Found %i install files, requiring 1: \n pattern: %s\n Found:\n %s'
         % (len(files), pattern, ' \n'.join(files)))
     file = files[0]
     return file
Example #56
0
    def createReleaseFolder(self):
        '''
        Create a folder containing all the files required for a Release.
        Ready to be moved to a distribution server.
        '''
        PrintFormatter.printHeader('create local release folder', level=2)
        targetPath = self._generateReleaseFolderName()
        PrintFormatter.printInfo('Creating folder %s' % targetPath)
        #shell.run('mkdir -p %s' % targetPath)
        shell.makeDirs(targetPath)
        installerFile = self.findInstallerFile()
        self._copyFile(installerFile, targetPath)
#        self.copyReleaseFiles(targetPath)                        
        return targetPath
Example #57
0
 def createReleaseFolder(self):
     '''
     Create a folder containing all the files required for a Release.
     Ready to be moved to a distribution server.
     '''
     PrintFormatter.printHeader('create local release folder', level=2)
     targetPath = self._generateReleaseFolderName()
     PrintFormatter.printInfo('Creating folder %s' % targetPath)
     #shell.run('mkdir -p %s' % targetPath)
     shell.makeDirs(targetPath)
     installerFile = self.findInstallerFile()
     self._copyFile(installerFile, targetPath)
     #        self.copyReleaseFiles(targetPath)
     return targetPath
Example #58
0
 def configure(self):
     builder = self._getBuilder()
     add = builder.addCMakeOption
     add('CTK_QT_VERSION:STRING', 5)
     add('CTK_ENABLE_DICOM:BOOL', 'ON')
     add('CTK_LIB_DICOM/Widgets:BOOL', 'ON')
     add('CTK_ENABLE_PluginFramework:BOOL', 'ON')
     #add('CTK_BUILD_SHARED_LIBS:BOOL', self.controlData.getBuildShared())
     add('CTK_BUILD_SHARED_LIBS:BOOL', 'ON')
     add('CMAKE_PREFIX_PATH:PATH', "/opt/local/libexec/qt5-mac")
     builder.configureCMake()
     PrintFormatter.printInfo(
         'Build CTK during configure step, in order to create CTKConfig.cmake'
     )
     self.build()