Beispiel #1
0
	def setup(self, numTests=0, cycles=1, xargs=None, threads=0, testoutdir=u'', runner=None, **kwargs):
		self.runner = runner
		if not self.destDir: raise Exception('Cannot set destDir to ""')
		self.destDir = toLongPathSafe(os.path.normpath(os.path.join(runner.project.root, self.destDir\
				.replace('@OUTDIR@', os.path.basename(runner.outsubdir)) \
				)))
		if os.path.exists(self.destDir) and all(f.endswith(('.txt', '.zip')) for f in os.listdir(self.destDir)):
			deletedir(self.destDir) # remove any existing archives (but not if this dir seems to have other stuff in it!)

		self.archiveAtEndOfRun = str(self.archiveAtEndOfRun).lower()=='true'

		self.fileExcludesRegex = re.compile(self.fileExcludesRegex) if self.fileExcludesRegex else None
		self.fileIncludesRegex = re.compile(self.fileIncludesRegex) if self.fileIncludesRegex else None

		self.maxArchiveSizeMB = float(self.maxArchiveSizeMB)
		self.maxArchives = int(self.maxArchives)
		
		self.__totalBytesRemaining = int(float(self.maxTotalSizeMB)*1024*1024)

		if self.archiveAtEndOfRun:
			self.queuedInstructions = []

		self.skippedTests = []
		self.archivesCreated = 0
		
		self.__artifactWriters = [w for w in self.runner.writers if isinstance(w, ArtifactPublisher)]
		def pub(path, category):
			path = fromLongPathSafe(path).replace('\\','/')
			for a in self.__artifactWriters:
				a.publishArtifact(path, category)

		self.runner.publishArtifact = pub
Beispiel #2
0
 def setup(self, **kwargs):
     # Creates the output directory for the writing of the test summary files.
     self.outputDir = (os.path.join(kwargs['runner'].project.root, 'target',
                                    'pysys-reports') if not self.outputDir
                       else os.path.join(kwargs['runner'].output +
                                         '/..', self.outputDir))
     deletedir(self.outputDir)
     mkdir(self.outputDir)
     self.cycles = kwargs.pop('cycles', 0)
Beispiel #3
0
    def setup(self,
              numTests=0,
              cycles=1,
              xargs=None,
              threads=0,
              testoutdir=u'',
              runner=None,
              **kwargs):
        for k in self.pluginProperties:
            if not hasattr(type(self), k):
                raise UserError('Unknown property "%s" for %s' % (k, self))

        self.runner = runner
        if not self.destDir: raise Exception('Cannot set destDir to ""')

        # avoid double-expanding (which could mess up ${$} escapes), but if using default value we need to expand it
        if self.destDir == TestOutputArchiveWriter.destDir:
            self.destDir = runner.project.expandProperties(self.destDir)
        self.destDir = toLongPathSafe(
            os.path.normpath(os.path.join(runner.output + '/..',
                                          self.destDir)))
        if os.path.exists(self.destDir) and all(
                f.endswith(('.txt', '.zip'))
                for f in os.listdir(self.destDir)):
            deletedir(
                self.destDir
            )  # remove any existing archives (but not if this dir seems to have other stuff in it!)

        self.fileExcludesRegex = re.compile(
            self.fileExcludesRegex) if self.fileExcludesRegex else None
        self.fileIncludesRegex = re.compile(
            self.fileIncludesRegex) if self.fileIncludesRegex else None

        self.__totalBytesRemaining = int(
            float(self.maxTotalSizeMB) * 1024 * 1024)

        if self.archiveAtEndOfRun:
            self.queuedInstructions = []

        self.skippedTests = []
        self.archivesCreated = 0

        self.includeNonFailureOutcomes = [
            str(o) for o in OUTCOMES
        ] if self.includeNonFailureOutcomes == '*' else [
            o.strip().upper()
            for o in self.includeNonFailureOutcomes.split(',') if o.strip()
        ]
        for o in self.includeNonFailureOutcomes:
            if not any(o == str(outcome) for outcome in OUTCOMES):
                raise UserError(
                    'Unknown outcome display name "%s" in includeNonFailureOutcomes'
                    % o)
Beispiel #4
0
 def clean(self):
     """Remove large files and folders if the test passes"""
     if self.testcase.getOutcome() == PASSED:
         self.log.info('Purging node %s output directory of large files' %
                       self.name)
         os.remove(self.jar)
         map(lambda x: deletedir(os.path.join(self.directory, x)),
             ['artemis', 'brokers'])
Beispiel #5
0
    def clean(self):
        Project.findAndLoadProject(outdir=self.outsubdir)

        descriptors = createDescriptors(self.arguments,
                                        None, [], [],
                                        None,
                                        self.workingDir,
                                        expandmodes=False)
        supportMultipleModesPerRun = Project.getInstance().getProperty(
            'supportMultipleModesPerRun', True)

        for descriptor in descriptors:
            if self.all:
                modulepath = os.path.join(descriptor.testDir,
                                          descriptor.module)
                cache = os.path.join(os.path.dirname(modulepath),
                                     "__pycache__")
                if os.path.isdir(cache):
                    log.info("Deleting pycache: " + cache)
                    deletedir(cache)
                else:
                    log.debug('__pycache__ does not exist: %s', cache)
                path = modulepath + ".pyc"
                if os.path.exists(path):
                    log.info("Deleting compiled Python module: " + path)
                    os.remove(path)
                else:
                    log.debug('.pyc does not exist: %s', path)

            for mode in (descriptor.modes or [None]):
                pathToDelete = os.path.join(descriptor.testDir,
                                            descriptor.output, self.outsubdir)

                if os.path.isabs(self.outsubdir
                                 ):  # must delete only the selected testcase
                    pathToDelete += "/" + descriptor.id

                if supportMultipleModesPerRun and mode:
                    pathToDelete += '~' + mode

                if os.path.exists(pathToDelete):
                    log.info("Deleting output directory: " + pathToDelete)
                    deletedir(pathToDelete)
                else:
                    log.debug("Output directory does not exist: " +
                              pathToDelete)
Beispiel #6
0
    def setup(self,
              numTests=0,
              cycles=1,
              xargs=None,
              threads=0,
              testoutdir=u'',
              runner=None,
              **kwargs):
        for k in self.pluginProperties:
            if not hasattr(type(self), k):
                raise UserError('Unknown property "%s" for %s' % (k, self))

        self.runner = runner
        if not self.destDir: raise Exception('Cannot set destDir to ""')
        if not self.fileIncludesRegex:
            raise Exception('fileIncludesRegex must be specified for %s' %
                            type(self).__name__)

        self.destDir = os.path.normpath(
            os.path.join(runner.output + '/..', self.destDir))
        if pathexists(self.destDir + os.sep + 'pysysproject.xml'):
            raise Exception('Cannot set destDir to testRootDir')

        # the code below assumes (for long path safe logic) this includes correct slashes (if any)
        self.outputPattern = self.outputPattern.replace('/', os.sep).replace(
            '\\', os.sep)

        if self.destArchive:
            self.destArchive = os.path.join(self.destDir, self.destArchive)

        if os.path.exists(self.destDir):
            deletedir(
                self.destDir
            )  # remove any existing archives (but not if this dir seems to have other stuff in it!)

        def prepRegex(exp):
            if not exp: return None
            if not exp.endswith('$'):
                exp = exp + '$'  # by default require regex to match up to the end to avoid common mistakes
            return re.compile(exp)

        self.fileExcludesRegex = prepRegex(self.fileExcludesRegex)
        self.fileIncludesRegex = prepRegex(self.fileIncludesRegex)

        self.collectedFileCount = 0