示例#1
0
    def load(commit, target, test):
        """ Load test result

			raises:
				IOError: When the results files is removed while reading.

			returns:
				TestResult instance
		"""
        commit = git.describe(commit)
        fpath = os.path.join(config.STORAGE_DIR(test, commit=commit),
                             'result.json')

        try:
            with open(fpath) as results:
                data = json.load(results)

                result = TestResult.unserialize(test, data)
                result.test = test
        except IOError as e:
            # if the file did not exist, advice the user to run the test first
            if not os.path.exists(fpath):
                raise ValueError(str(e))
            else:
                raise

        logger.debug("Loaded testresult: %s (commit: %s)" %
                     (str(result), commit))

        return result
示例#2
0
def plugin_environ(test=None):
    """ extend a copy of os.environ with some testing environ vars.
		these include the config.ENV names.

		kwargs:
			test {Test}:
				for setting optional test specific variables
				(TEST_NAME, TEST_LOG)

		return:
			environment {dict}
	"""
    env = os.environ.copy()

    env['TEMP_DIR'] = config.TEMP_DIR
    env['TESTS_DIR'] = config.TESTS_DIR
    env['SRC_DIR'] = config.SRC_DIR

    for key, value in config.ENV.items():
        env[key] = str(value)

    if test is not None:
        env['TEST_NAME'] = test.name
        env['TEST_LOG'] = test.log_path()
        env['RESULTS_DIR'] = os.path.join(
            config.TEMP_DIR, config.STORAGE_DIR(test, commit=git.describe()))

    return env
示例#3
0
    def exists(commit, target, test):
        """ Check if a test results exists

			returns:
				bool
		"""
        commit = git.describe(commit)
        fpath = config.STORAGE_DIR(test, commit=commit)

        return os.path.exists(fpath)
示例#4
0
    def process(self, result):
        # create the path
        path = os.path.join(config.STORAGE_DIR(result.test, result.commit),
                            CCoverageCollector.FILENAME)

        # check if it exists
        if not os.path.exists(path):
            logger.warn("Result for test %s has no coverage data attached" %
                        str(result))
        else:
            self.paths.append(path)
示例#5
0
    def clean(self):
        # clean the existing result dir and create a new one.
        result_dir = config.STORAGE_DIR(self.result.test,
                                        commit=self.result.commit)
        try:
            shutil.rmtree(result_dir)
        except OSError as e:
            if not os.path.isdir(result_dir):
                pass
            else:
                raise e

        logger.debug("Cleaned directory: `%s`" % result_dir)
示例#6
0
文件: models.py 项目: ajrouvoet/dummy
	def storage_dir( self ):
		return config.STORAGE_DIR( self.test, self.commit )
示例#7
0
 def path(self):
     return os.path.join(
         config.STORAGE_DIR(self.result.test, commit=self.result.commit),
         'result.json')