9 from webkitpy.benchmark_runner.utils import getPathFromProjectRoot
12 _log = logging.getLogger(__name__)
15 class GenericBenchmarkBuilder(object):
17 def prepare(self, benchmarkPath, patch):
18 self._copyBenchmarkToTempDir(benchmarkPath)
19 return self._applyPatch(patch)
21 def _copyBenchmarkToTempDir(self, benchmarkPath):
22 self.webRoot = tempfile.mkdtemp()
23 _log.debug('Servering at webRoot: %s' % self.webRoot)
24 self.dest = os.path.join(self.webRoot, os.path.split(benchmarkPath)[1])
25 shutil.copytree(getPathFromProjectRoot(benchmarkPath), self.dest)
27 def _applyPatch(self, patch):
30 oldWorkingDirectory = os.getcwd()
31 os.chdir(self.webRoot)
32 errorCode = subprocess.call(['patch', '-p1', '-f', '-i', getPathFromProjectRoot(patch)])
33 os.chdir(oldWorkingDirectory)
35 _log.error('Cannot apply patch, will skip current benchmarkPath')
41 _log.info('Cleanning Benchmark')
43 shutil.rmtree(self.webRoot)