예제 #1
0
	def run( self, target=config.DEFAULT_TARGET, commit=None, store=False ):
		# make sure we have work to do
		assert len( self.tests ) != 0, "No tests to run."

		# if a commit is given, we need to checkout out the commit
		# but keep the tests directory at the current branch
		try:
			# create a lock file to prevent multiple runners on the same repo
			with open( config.LOCK_FILE, 'w' ) as fh:
				fh.write( str( datetime.datetime.now() ))

			# checkout the correct commit
			if commit is not None:
				current = git.current_branch()

				# if not on any branch currently
				# remember the current commit
				if current == "HEAD":
					current = git.describe()

				logger.warning( "Checking out commit `%s`" % commit )
				git.checkout( commit )
				git.checkout( current, paths=[ config.TESTS_DIR ])

			# actual running of the tests
			self._run_tests( target=target, store=store )


		# if a git error is caught while checking out the commit on
		# which to run the tests
		# we can't do anything
		except git.GitError as e:
			logger.error( "Could not checkout `%s`... Sorry!" % commit )
			raise

		finally:
			# make sure to always checkout the original commit again
			if commit is not None:
				try:
					git.checkout( current )
					logger.info( "Checked out the original HEAD again!" )
				except git.GitError as e:
					logger.error(
						"Could not checkout original branch... you'll have to do that yourself."
					)
					raise

			# make sure to remove the lock file
			io.remove_file( config.LOCK_FILE )
예제 #2
0
파일: generic.py 프로젝트: ajrouvoet/dummy
 def pre_test_hook(self, test):
     # remove the statfile
     # to zero the counters
     io.remove_file(self.statpath)
예제 #3
0
	def pre_test_hook( self, test ):
		# remove the statfile
		# to zero the counters
		io.remove_file( self.statpath )