Commit eac2397b by Jamie Madill Committed by Commit Bot

Trace Tests: Work around autoninja.bat change on Win.

A breaking change to autoninja.bat was causing the script to fail to find 'python3.bat' in this configuration. Work around the issue by instead invoking 'ninja.exe' directly with the correct '-j' argument. Bug: angleproject:5766 Change-Id: Ie01d7e8c4caf80661f420ccfc55a8d951a4e1b4f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2787186Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent f28d63e9
...@@ -223,7 +223,7 @@ class SubProcess(): ...@@ -223,7 +223,7 @@ class SubProcess():
class ChildProcessesManager(): class ChildProcessesManager():
@classmethod @classmethod
def _GetGnAndAutoninjaAbsolutePaths(self, depot_tools_path): def _GetGnAndNinjaAbsolutePaths(self, depot_tools_path):
def find_depot_tools_from_env(): def find_depot_tools_from_env():
depot_tools_name = "depot_tools" depot_tools_name = "depot_tools"
...@@ -234,13 +234,13 @@ class ChildProcessesManager(): ...@@ -234,13 +234,13 @@ class ChildProcessesManager():
for path in paths: for path in paths:
if path.endswith(depot_tools_name): if path.endswith(depot_tools_name):
return path return path
logging.exception("No gn or autoninja found on system") logging.exception("No gn or ninja found on system")
def bat(name): def winext(name, ext):
return name + '.bat' if platform == "win32" else name return ("%s.%s" % (name, ext)) if platform == "win32" else name
path = depot_tools_path if depot_tools_path else find_depot_tools_from_env() path = depot_tools_path if depot_tools_path else find_depot_tools_from_env()
return os.path.join(path, bat('gn')), os.path.join(path, bat('autoninja')) return os.path.join(path, winext('gn', 'bat')), os.path.join(path, winext('ninja', 'exe'))
def __init__(self, depot_tools_path): def __init__(self, depot_tools_path):
# a dictionary of Subprocess, with pid as key # a dictionary of Subprocess, with pid as key
...@@ -248,12 +248,11 @@ class ChildProcessesManager(): ...@@ -248,12 +248,11 @@ class ChildProcessesManager():
# list of Python multiprocess.Process handles # list of Python multiprocess.Process handles
self.workers = [] self.workers = []
self._gn_path, self._autoninja_path = self._GetGnAndAutoninjaAbsolutePaths( self._gn_path, self._ninja_path = self._GetGnAndNinjaAbsolutePaths(depot_tools_path)
depot_tools_path)
def RunSubprocess(self, command, env=None, pipe_stdout=True, timeout=None): def RunSubprocess(self, command, env=None, pipe_stdout=True, timeout=None):
proc = SubProcess(command, env, pipe_stdout) proc = SubProcess(command, env, pipe_stdout)
debug('Creating subprocess: %s with pid %d' % (' '.join(command), proc.Pid())) debug('Created subprocess: %s with pid %d' % (' '.join(command), proc.Pid()))
self.subprocesses[proc.Pid()] = proc self.subprocesses[proc.Pid()] = proc
try: try:
returncode, output = self.subprocesses[proc.Pid()].Join(timeout) returncode, output = self.subprocesses[proc.Pid()].Join(timeout)
...@@ -310,8 +309,27 @@ class ChildProcessesManager(): ...@@ -310,8 +309,27 @@ class ChildProcessesManager():
cmd = [self._gn_path, 'gen', '--args=%s' % args_str, build_dir] cmd = [self._gn_path, 'gen', '--args=%s' % args_str, build_dir]
return self.RunSubprocess(cmd, pipe_stdout=pipe_stdout) return self.RunSubprocess(cmd, pipe_stdout=pipe_stdout)
def RunAutoninjaProcess(self, build_dir, target, pipe_stdout): def RunNinjaProcess(self, args, build_dir, target, pipe_stdout):
cmd = [self._autoninja_path, '-C', build_dir, target] cmd = [self._ninja_path]
# This code is taken from depot_tools/autoninja.py
if args.use_goma:
num_cores = multiprocessing.cpu_count()
cmd.append('-j')
core_multiplier = 40
j_value = num_cores * core_multiplier
if sys.platform.startswith('win'):
# On windows, j value higher than 1000 does not improve build performance.
j_value = min(j_value, 1000)
elif sys.platform == 'darwin':
# On Mac, j value higher than 500 causes 'Too many open files' error
# (crbug.com/936864).
j_value = min(j_value, 500)
cmd.append('%d' % j_value)
cmd += ['-C', build_dir, target]
return self.RunSubprocess(cmd, pipe_stdout=pipe_stdout) return self.RunSubprocess(cmd, pipe_stdout=pipe_stdout)
...@@ -597,7 +615,8 @@ class TestBatch(): ...@@ -597,7 +615,8 @@ class TestBatch():
skipped_tests)) skipped_tests))
return continued_tests return continued_tests
def BuildReplay(self, replay_build_dir, composite_file_id, tests, child_processes_manager): def BuildReplay(self, args, replay_build_dir, composite_file_id, tests,
child_processes_manager):
# write gni file that holds all the traces files in a list # write gni file that holds all the traces files in a list
self.CreateGNIFile(composite_file_id, tests) self.CreateGNIFile(composite_file_id, tests)
# write header and cpp composite files, which glue the trace files with # write header and cpp composite files, which glue the trace files with
...@@ -618,12 +637,12 @@ class TestBatch(): ...@@ -618,12 +637,12 @@ class TestBatch():
GroupedResult(GroupedResult.CompileFailed, "Build replay failed at gn generation", GroupedResult(GroupedResult.CompileFailed, "Build replay failed at gn generation",
output, tests)) output, tests))
return False return False
returncode, output = child_processes_manager.RunAutoninjaProcess( returncode, output = child_processes_manager.RunNinjaProcess(args, replay_build_dir,
replay_build_dir, REPLAY_BINARY, True) REPLAY_BINARY, True)
if returncode != 0: if returncode != 0:
self.results.append( self.results.append(
GroupedResult(GroupedResult.CompileFailed, "Build replay failed at autoninja", GroupedResult(GroupedResult.CompileFailed, "Build replay failed at ninja", output,
output, tests)) tests))
return False return False
return True return True
...@@ -799,8 +818,8 @@ def RunTests(args, worker_id, job_queue, result_list, message_queue): ...@@ -799,8 +818,8 @@ def RunTests(args, worker_id, job_queue, result_list, message_queue):
result_list.append(test_batch.GetResults()) result_list.append(test_batch.GetResults())
message_queue.put(str(test_batch.GetResults())) message_queue.put(str(test_batch.GetResults()))
continue continue
success = test_batch.BuildReplay(replay_build_dir, composite_file_id, continued_tests, success = test_batch.BuildReplay(args, replay_build_dir, composite_file_id,
child_processes_manager) continued_tests, child_processes_manager)
if test_batch.keep_temp_files: if test_batch.keep_temp_files:
composite_file_id += 1 composite_file_id += 1
if not success: if not success:
...@@ -881,9 +900,9 @@ def main(args): ...@@ -881,9 +900,9 @@ def main(args):
logging.error(output) logging.error(output)
child_processes_manager.KillAll() child_processes_manager.KillAll()
return EXIT_FAILURE return EXIT_FAILURE
# run autoninja to build all tests # run ninja to build all tests
returncode, output = child_processes_manager.RunAutoninjaProcess( returncode, output = child_processes_manager.RunNinjaProcess(args, capture_build_dir,
capture_build_dir, args.test_suite, False) args.test_suite, False)
if returncode != 0: if returncode != 0:
logging.error(output) logging.error(output)
child_processes_manager.KillAll() child_processes_manager.KillAll()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment