Example #1
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 #2
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))
 def try_job_release(self):
     '''
     Create a tagged release and publish to server.
     Build, run all tests, publish binaries and 
     documentation to the web server.
     
     Requires a git_tag as input.
     Assumed to be run on the release branch (should work OK on others as well)
     '''
     if self.options.job_release_I:
         PrintFormatter.printHeader('Building release for tag "%s"' % self.controlData().git_tag, 1);
         if self.is_main_build():
             self.controlData().build_developer_doc = True
             self.controlData().build_user_doc = True
         self.resetInstallerStep()
         self.createUnitTestedPackageStep()
         self.integrationTestPackageStep(skip_extra_install_step_checkout=True)
         self.cxBuilder.finish()
     if self.options.job_release_II:
         targetFolder = self.cxInstaller.getTaggedFolderName()
         PrintFormatter.printHeader('Creating and publishing release for tag "%s"' % self.controlData().git_tag, 1);
         if targetFolder != self.controlData().git_tag:
             PrintFormatter.printInfo("Warning: Target folder [%s] not equal to controldata tag [%s]" % (targetFolder, self.controlData().git_tag) )
         self.publishTaggedRelease()
         if self.is_main_build():
             self.publishTaggedDocumentation()
         self.cxBuilder.finish()
 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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
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 #23
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 #24
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 #25
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 #26
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 #27
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 #28
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 #29
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 #30
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 #31
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 #32
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', 'ON')
     add('CMAKE_PREFIX_PATH:PATH', "/opt/local/libexec/qt5-mac")
     add('CTK_LIB_Visualization/VTK/Core:BOOL', 'ON')
     add('VTK_DIR:PATH', self._createSibling(VTK).configPath())
     add('BUILD_TESTING:BOOL', 'OFF')
     builder.configureCMake()
     PrintFormatter.printInfo('Build CTK during configure step, in order to create CTKConfig.cmake')
     self.build()
Example #33
0
 def _installDMG_PackageMaker(self, dmgfile, pkgName=None):
     '''
     Install the given pkg inside the dmg file.
     '''
     path = os.path.dirname(dmgfile)
     basename = os.path.basename(dmgfile)
     changeDir(path)
     coreName = os.path.splitext(basename)[0]
     if not pkgName:
         pkgName = coreName + '.mpkg'
     PrintFormatter.printInfo("install package %s from file %s" % (pkgName, coreName))
     shell.run('hdiutil attach -mountpoint /Volumes/%s %s' % (coreName, dmgfile))
     target = '/'  # TODO: mount on another (test) volume - this one requires sudo
     shell.run('sudo installer -pkg /Volumes/%s/%s -target %s' % (coreName, pkgName, target))
     shell.run('hdiutil detach /Volumes/%s' % coreName)
     PrintFormatter.printInfo("Installed %s" % pkgName)
Example #34
0
 def _installDMG(self, dmgfile, pkgName=None):
     '''
     Install the given pkg inside the dmg file.
     '''
     path = os.path.dirname(dmgfile)
     basename = os.path.basename(dmgfile)
     changeDir(path)
     coreName = os.path.splitext(basename)[0]
     if not pkgName:
         pkgName = coreName + '.mpkg'
     PrintFormatter.printInfo("install package %s from file %s" % (pkgName, coreName))
     shell.run('hdiutil attach -mountpoint /Volumes/%s %s' % (coreName, dmgfile))
     target = '/'  # TODO: mount on another (test) volume - this one requires sudo
     shell.run('sudo installer -pkg /Volumes/%s/%s -target %s' % (coreName, pkgName, target))
     shell.run('hdiutil detach /Volumes/%s' % coreName)
     PrintFormatter.printInfo("Installed %s" % pkgName)
Example #35
0
    def _writeCTestConfigurationFile(self, path):
        'generate CTestCustom.cmake, needed to avoid CTest truncation of output'
        targetFile = '%s/CTestCustom.cmake' % path
        PrintFormatter.printInfo('Generate ctest file %s' % targetFile)
        site = platform.node()
        buildname = platform.platform()
        content = '''\
# Autogenerated by CustusX test scripts
# Minimal file only.

# See http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest for more variables

# Set output size for tests (in characters/bytes)
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 30000)
set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 30000)
'''
        cx.utils.cxUtilities.writeToNewFile(filename=targetFile, text=content)
Example #36
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', 'ON')
     add('CMAKE_PREFIX_PATH:PATH', "/opt/local/libexec/qt5-mac")
     add('CTK_LIB_Visualization/VTK/Core:BOOL', 'ON')
     add('VTK_DIR:PATH', self._createSibling(VTK).configPath())
     add('BUILD_TESTING:BOOL', 'OFF')
     builder.configureCMake()
     PrintFormatter.printInfo(
         'Build CTK during configure step, in order to create CTKConfig.cmake'
     )
     self.build()
Example #37
0
    def publishReleaseFolder(self, source, targetFolder, target):
        '''
        Copy a release folder to server
        '''
        PrintFormatter.printHeader('copy/publish package to medtek server', level=2)
        remoteServerPath = target.path
        
        target_path = '%s/%s/%s' % (target.path, targetFolder, self._getUserFriendlyPlatformName())
        PrintFormatter.printInfo('Publishing contents of [%s] to server [%s], remote path [%s]' % (source, target.server, target_path))
        targetBasePath = '%s/%s' % (target.path, targetFolder) # need to create parent folder explicitly

        transfer = cx.utils.cxSSH.RemoteFileTransfer()
        transfer.connect(target.server, target.user)
        transfer.remote_mkdir(targetBasePath)
        transfer.remote_rmdir(target_path) # remove old content if any
        transfer.copyFolderContentsToRemoteServer(source, target_path);
        transfer.close()
Example #38
0
    def publishReleaseFolder(self, source, targetFolder, target):
        '''
        Copy a release folder to server
        '''
        PrintFormatter.printHeader('copy/publish package to medtek server', level=2)
        remoteServerPath = target.path
        
        target_path = '%s/%s/%s' % (target.path, targetFolder, self._getUserFriendlyPlatformName())
        PrintFormatter.printInfo('Publishing contents of [%s] to server [%s], remote path [%s]' % (source, target.server, target_path))
        targetBasePath = '%s/%s' % (target.path, targetFolder) # need to create parent folder explicitly

        transfer = cx.utils.cxSSH.RemoteFileTransfer()
        transfer.connect(target.server, target.user)
        transfer.remote_mkdir(targetBasePath)
        transfer.remote_rmdir(target_path) # remove old content if any
        transfer.copyFolderContentsToRemoteServer(source, target_path);
        transfer.close()
Example #39
0
    def _writeCTestConfigurationFile(self, path):
        'generate CTestCustom.cmake, needed to avoid CTest truncation of output'
        targetFile = '%s/CTestCustom.cmake' % path
        PrintFormatter.printInfo('Generate ctest file %s' % targetFile)
        site = platform.node()
        buildname = platform.platform()
        content = '''\
# Autogenerated by CustusX test scripts
# Minimal file only.

# See http://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest for more variables

# Set output size for tests (in characters/bytes)
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 30000)
set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 30000)
'''
        cx.utils.cxUtilities.writeToNewFile(filename=targetFile, text=content)
Example #40
0
 def runCatchTestsWrappedInCTest(self, path, tag, outFile):
     '''
     Assuming a Catch executable exist in path,
     run all tests with the given tag in separate processes
     using ctest.
     ctest files are generated in path, overwriting existing files.
     ctest-style xml results are written to outFile.
     '''
     PrintFormatter.printInfo('Run ctest tests with tag %s' % tag)
     PrintFormatter.printInfo('Convert catch tests to ctests, i.e. one test per process...')
     tests = self._readCatchTestNames(path, tag=tag)
     ctestfile = '%s/CTestTestfile.cmake'%path
     self._writeCTestFileForCatchTests(path, ctestfile, tests)
     self._writeDartConfigurationFile(path)
     self._writeCTestConfigurationFile(path)
     self.runCTest(path, outfile=outFile)
     shell.rm_r(ctestfile)
Example #41
0
 def runCatchTestsWrappedInCTest(self, path, tag, outFile):
     '''
     Assuming a Catch executable exist in path,
     run all tests with the given tag in separate processes
     using ctest.
     ctest files are generated in path, overwriting existing files.
     ctest-style xml results are written to outFile.
     '''
     PrintFormatter.printInfo('Run ctest tests with tag %s' % tag)
     PrintFormatter.printInfo(
         'Convert catch tests to ctests, i.e. one test per process...')
     tests = self._readCatchTestNames(path, tag=tag)
     ctestfile = '%s/CTestTestfile.cmake' % path
     self._writeCTestFileForCatchTests(path, ctestfile, tests)
     self._writeDartConfigurationFile(path)
     self._writeCTestConfigurationFile(path)
     self.runCTest(path, outfile=outFile)
     shell.rm_r(ctestfile)
Example #42
0
    def run(self):
        options = self.options
        assembly = self.assembly

        if options.all:
            assembly.selectAllLibraries()
        else:
            assembly.selectLibraries(options.components)

        # display help if no components selected
        if len(assembly.getSelectedLibraries()) == 0:
            PrintFormatter.printInfo("No libraries selected, exiting...")
            self.argumentParser.print_help()
            return

        # info + verification
        assembly.controlData.printSettings()
        libs = [
            lib for lib in assembly.libraries
            if lib.name() in assembly.selectedLibraryNames
        ]
        text = ['%45s     %s' % (lib.name(), lib.repository()) for lib in libs]
        print 'Use the following components:\n ', '\n  '.join(text)

        print ''
        print '*********************************************************************'
        print 'The superbuild will check out and build in [repo/../..], expanded to:'
        print ''
        print '    %s' % assembly.controlData.getRootDir()
        print ''
        print '*********************************************************************'
        print ''

        self._promptToContinue(options.silent_mode)

        assembly.process(checkout=options.full or options.checkout,
                         configure_clean=options.configure_clean,
                         configure=options.full or options.configure,
                         clean=options.clean,
                         build=options.full or options.make)

        #self.cxBuilder.finish()
        PrintFormatter.finish()
Example #43
0
    def _installDMG(self, dmgfile, pkgName=None):
        '''
        Install the given pkg inside the dmg file.
        '''
        path = os.path.dirname(dmgfile)
        basename = os.path.basename(dmgfile)
        changeDir(path)
        coreName = os.path.splitext(basename)[0]
        if not pkgName:
            pkgName = coreName + '.mpkg'
        PrintFormatter.printInfo("install DragNDrop package %s" % (dmgfile))

        temp_path = '%s/temp/Install' % self.root_dir
        shell.removeTree(temp_path)
        shell.changeDir(temp_path)

        converted_installer = "%s/%s" % (temp_path, coreName)
        mount_point = "%s/%s" % (temp_path, coreName)

        shell.run('hdiutil convert -quiet %s -format UDTO -o %s' %
                  (dmgfile, converted_installer))
        shell.run(
            'hdiutil attach -quiet -nobrowse -noverify -noautoopen -mountpoint %s %s.cdr'
            % (mount_point, converted_installer))
        #/usr/bin/hdiutil convert -quiet foo.dmg -format UDTO -o bar
        #/usr/bin/hdiutil attach -quiet -nobrowse -noverify -noautoopen -mountpoint right_here bar.cdr

        #        installfolder = '%s' % self.install_root
        shell.changeDir(self.getInstalledFolder())

        shell.run('cp -r %s/*.app %s' %
                  (mount_point, self.getInstalledFolder() + "/"))

        shell.run('hdiutil detach %s' % mount_point)

        #        shell.run('hdiutil attach -mountpoint /Volumes/%s %s' % (coreName, dmgfile))
        #        target = '/'  # TODO: mount on another (test) volume - this one requires sudo
        #        shell.run('sudo installer -pkg /Volumes/%s/%s -target %s' % (coreName, pkgName, target))
        #        shell.run('hdiutil detach /Volumes/%s' % coreName)

        PrintFormatter.printInfo("Installed %s" % dmgfile)
Example #44
0
    def run(self):
        options = self.options
        assembly = self.assembly
                
        if options.all:
            assembly.selectAllLibraries()
        else:
            assembly.selectLibraries(options.components)

        # display help if no components selected
        if len(assembly.getSelectedLibraries())==0:
            PrintFormatter.printInfo("No libraries selected, exiting...")
            self.argumentParser.print_help()
            return

        # info + verification
        assembly.controlData.printSettings()
        libs = [lib for lib in assembly.libraries if lib.name() in assembly.selectedLibraryNames]
        text = ['%45s     %s' % (lib.name(), lib.repository()) for lib in libs]
        print 'Use the following components:\n ', '\n  '.join(text)
        
        print ''
        print '*********************************************************************'
        print 'The superbuild will check out and build in [repo/../..], expanded to:'
        print ''
        print '    %s' % assembly.controlData.getRootDir()
        print ''
        print '*********************************************************************'
        print ''
        
        self._promptToContinue(options.silent_mode)
        
        assembly.process(checkout = options.full or options.checkout, 
                         configure_clean = options.configure_clean, 
                         configure = options.full or options.configure, 
                         clean = options.clean, 
                         build = options.full or options.make)        
        
        #self.cxBuilder.finish()
        PrintFormatter.finish()
Example #45
0
    def run(self):
        options = self.options
        assembly = self.assembly

        if options.all:
            assembly.selectAllLibraries()
        else:
            assembly.selectLibraries(options.components)

        # display help if no components selected
        if len(assembly.getSelectedLibraries()) == 0:
            PrintFormatter.printInfo("No libraries selected, exiting...")
            self.argumentParser.print_help()
            return

        # info + verification
        assembly.controlData.printSettings()
        print "Use the following components:\n ", "\n  ".join(assembly.getSelectedLibraries())

        print ""
        print "*********************************************************************"
        print "The superbuild will check out and build in [repo/../..], expanded to:"
        print ""
        print "    %s" % assembly.controlData.getRootDir()
        print ""
        print "*********************************************************************"
        print ""

        self._promptToContinue(options.silent_mode)

        assembly.process(
            checkout=options.full or options.checkout,
            configure_clean=options.configure_clean,
            configure=options.full or options.configure,
            clean=options.clean,
            build=options.full or options.build,
        )

        # self.cxBuilder.finish()
        PrintFormatter.finish()
Example #46
0
 def _runApplicationForDuration(self, application, timeout):
     '''
     Run the given application for a short time, as a quick verification.
     The stdout is not redirected here, i.e. it might be mangled with the python output.
     '''
     if (platform.system() == 'Windows'):
         application = application.replace("\\", "/")
     PrintFormatter.printInfo('Running application %s' % application)
     startTime = time.time()
     # On linux, cannot run from shell (http://stackoverflow.com/questions/4789837/how-to-terminate-a-python-subprocess-launched-with-shell-true)
     p = subprocess.Popen(shlex.split(application),
                          shell=False,
                          cwd=os.path.dirname(application))
     self._waitForProcessEnd(process=p, timeout=timeout)
     retcode = p.poll()
     elapsedTime = "%.1f" % (time.time() - startTime)
     cx.utils.cxUtilities.assertTrue(
         retcode == None or retcode == 0,
         'Process %s has been running successfully for %ss' %
         (application, elapsedTime))
     if retcode == None:
         PrintFormatter.printInfo("Killing %s ..." % application)
         p.kill()
     p.communicate()
     PrintFormatter.printInfo('Successfully ran %s for %ss' %
                              (application, elapsedTime))
Example #47
0
    def _writeDartConfigurationFile(self, path):
        'generate DartConfiguration.tcl, required by ctest'
        targetFile = '%s/DartConfiguration.tcl' % path
        PrintFormatter.printInfo('Generate ctest file %s' % targetFile)
        site = platform.node()
        buildname = platform.platform()
        timeout = 10*60 # seconds
        content = '''\
# Autogenerated by CustusX test scripts
# Minimal file only.

# Site is something like machine.domain, i.e. pragmatic.crd
Site: %s
# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
BuildName: %s
# Testing options
# TimeOut is the amount of time in seconds to wait for processes
# to complete during testing.  After TimeOut seconds, the
# process will be summarily terminated.
TimeOut: %d
''' % (site,buildname,timeout)
        cx.utils.cxUtilities.writeToNewFile(filename=targetFile, text=content)
Example #48
0
    def _writeDartConfigurationFile(self, path):
        'generate DartConfiguration.tcl, required by ctest'
        targetFile = '%s/DartConfiguration.tcl' % path
        PrintFormatter.printInfo('Generate ctest file %s' % targetFile)
        site = platform.node()
        buildname = platform.platform()
        timeout = 10 * 60  # seconds
        content = '''\
# Autogenerated by CustusX test scripts
# Minimal file only.

# Site is something like machine.domain, i.e. pragmatic.crd
Site: %s
# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
BuildName: %s
# Testing options
# TimeOut is the amount of time in seconds to wait for processes
# to complete during testing.  After TimeOut seconds, the
# process will be summarily terminated.
TimeOut: %d
''' % (site, buildname, timeout)
        cx.utils.cxUtilities.writeToNewFile(filename=targetFile, text=content)
Example #49
0
    def _installDMG(self, dmgfile, pkgName=None):
        '''
        Install the given pkg inside the dmg file.
        '''
        path = os.path.dirname(dmgfile)
        basename = os.path.basename(dmgfile)
        changeDir(path)
        coreName = os.path.splitext(basename)[0]
        if not pkgName:
            pkgName = coreName + '.mpkg'
        PrintFormatter.printInfo("install DragNDrop package %s" % (dmgfile))

        temp_path = '%s/temp/Install' % self.root_dir   
        shell.removeTree(temp_path)
        shell.changeDir(temp_path)
        
        converted_installer = "%s/%s" % (temp_path, coreName)
        mount_point = "%s/%s" % (temp_path, coreName)

        shell.run('hdiutil convert -quiet %s -format UDTO -o %s' % (dmgfile, converted_installer))
        shell.run('hdiutil attach -quiet -nobrowse -noverify -noautoopen -mountpoint %s %s.cdr' % (mount_point, converted_installer))
#/usr/bin/hdiutil convert -quiet foo.dmg -format UDTO -o bar
#/usr/bin/hdiutil attach -quiet -nobrowse -noverify -noautoopen -mountpoint right_here bar.cdr

#        installfolder = '%s' % self.install_root
        shell.changeDir(self.getInstalledFolder())
        
        shell.run('cp -r %s/*.app %s' % (mount_point, self.getInstalledFolder()+"/"))

        shell.run('hdiutil detach %s' % mount_point)
        
        
#        shell.run('hdiutil attach -mountpoint /Volumes/%s %s' % (coreName, dmgfile))
#        target = '/'  # TODO: mount on another (test) volume - this one requires sudo
#        shell.run('sudo installer -pkg /Volumes/%s/%s -target %s' % (coreName, pkgName, target))
#        shell.run('hdiutil detach /Volumes/%s' % coreName)
        
        PrintFormatter.printInfo("Installed %s" % dmgfile)
 def _runApplicationForDuration(self, application, timeout):
     '''
     Run the given application for a short time, as a quick verification.
     The stdout is not redirected here, i.e. it might be mangled with the python output.
     '''
     if(platform.system() == 'Windows'):
         application = application.replace("\\", "/")
     PrintFormatter.printInfo('Running application %s' % application)
     startTime = time.time()
     # On linux, cannot run from shell (http://stackoverflow.com/questions/4789837/how-to-terminate-a-python-subprocess-launched-with-shell-true)
     p = subprocess.Popen(shlex.split(application), shell=False, cwd=os.path.dirname(application)) 
     self._waitForProcessEnd(process=p, timeout=timeout)
     retcode = p.poll()
     elapsedTime = "%.1f" % (time.time()-startTime)
     cx.utils.cxUtilities.assertTrue(retcode==None or retcode==0, 'Process %s has been running successfully for %ss' % (application, elapsedTime))
     if retcode==None:
         PrintFormatter.printInfo("Killing %s ..." % application)
         p.kill()
     p.communicate()
     PrintFormatter.printInfo('Successfully ran %s for %ss' % (application, elapsedTime))
Example #51
0
 def _copyFile(self, source, targetPath):
     shutil.copy2(source, targetPath)
     PrintFormatter.printInfo("copied file %s into %s" % (source, targetPath))
Example #52
0
    def runCatch(self, path, tag, outpath=None, outfile=None):
        'Run all Catch tests at path and write them in junit xml format to outfile'
        if not outfile:
            baseName = self._createCatchBaseFilenameFromTag(tag)
            outfile = '%s/%s.junit.xml' % (outpath, baseName)
        PrintFormatter.printInfo('Run catch with tag %s, results to %s' %
                                 (tag, outfile))
        shell.changeDir(path)
        shell.rm_r(outfile)
        exe = self._getCatchExecutable(path)
        if (platform.system() == 'Windows'):
            cmd = 'set_run_environment.bat %s %s --reporter junit --out %s' % (
                exe, tag, outfile)
        else:
            cmd = '%s %s --reporter junit --out %s' % (exe, tag, outfile)
        result = shell.run(cmd, ignoreFailure=True, keep_output=True)
        if result.returncode >= 0:
            PrintFormatter.printInfo('catch reported %s failing tests' %
                                     result.returncode)
#        if result.returncode < 0:
        if self._catch_has_failed(result):
            PrintFormatter.printInfo('catch failed with returncode %s' %
                                     result.returncode)
            PrintFormatter.printInfo('Removing outfile %s' % outfile)
            shell.rm_r(outfile)
            PrintFormatter.printHeader('Analyzing catch failure', 2)
            PrintFormatter.printInfo('Running catch tests wrapped in ctest.')
            PrintFormatter.printInfo('This should identify crashing tests.')
            self.runCatchTestsWrappedInCTestGenerateJUnit(tag, path, outpath)
Example #53
0
 def _copyFile(self, source, targetPath):
     shutil.copy2(source, targetPath)
     PrintFormatter.printInfo("copied file %s into %s" %
                              (source, targetPath))
Example #54
0
 def convertCTestFile2JUnit(self, ctestFile, junitFile):
     PrintFormatter.printInfo('Convert [%s] to [%s]' %
                              (ctestFile, junitFile))
     cx.utils.cxConvertCTest2JUnit.convertCTestFile2JUnit(
         ctestFile, junitFile)
Example #55
0
 def convertCTestFile2JUnit(self, ctestFile, junitFile):
     PrintFormatter.printInfo('Convert [%s] to [%s]' % (ctestFile, junitFile))
     cx.utils.cxConvertCTest2JUnit.convertCTestFile2JUnit(ctestFile, junitFile)
Example #56
0
    def runCatch(self, path, tag, outpath=None, outfile=None):
        'Run all Catch tests at path and write them in junit xml format to outfile'
        if not outfile:
            baseName = self._createCatchBaseFilenameFromTag(tag)
            outfile = '%s/%s.junit.xml' % (outpath, baseName)
        PrintFormatter.printInfo('Run catch with tag %s, results to %s' % (tag, outfile))
        shell.changeDir(path)
        shell.rm_r(outfile)
        exe = self._getCatchExecutable(path)
        if(platform.system() == 'Windows'):
            cmd = 'set_run_environment.bat %s %s --reporter junit --out %s' % (exe, tag, outfile)
        else:
            cmd = '%s %s --reporter junit --out %s' % (exe, tag, outfile)
        result = shell.run(cmd, ignoreFailure=True, keep_output=True)
        if result.returncode >= 0:
            PrintFormatter.printInfo('catch reported %s failing tests' % result.returncode)                        
#        if result.returncode < 0:
        if self._catch_has_failed(result):
            PrintFormatter.printInfo('catch failed with returncode %s' % result.returncode)            
            PrintFormatter.printInfo('Removing outfile %s' % outfile)            
            shell.rm_r(outfile)
            PrintFormatter.printHeader('Analyzing catch failure', 2)            
            PrintFormatter.printInfo('Running catch tests wrapped in ctest.')            
            PrintFormatter.printInfo('This should identify crashing tests.')            
            self.runCatchTestsWrappedInCTestGenerateJUnit(tag, path, outpath)
Example #57
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))