def run_test(self): self.parse_args() cmd = self.generate_isolated_script_cmd() env = os.environ.copy() # Assume we want to set up the sandbox environment variables all the # time; doing so is harmless on non-Linux platforms and is needed # all the time on Linux. env[CHROME_SANDBOX_ENV] = CHROME_SANDBOX_PATH valid = True try: env['CHROME_HEADLESS'] = '1' print 'Running command: %s\nwith env: %r' % (' '.join(cmd), env) if self.options.xvfb: exit_code = xvfb.run_executable(cmd, env) else: exit_code = test_env.run_command(cmd, env=env) print 'Command returned exit code %d' % exit_code return exit_code except Exception: traceback.print_exc() valid = False finally: self.clean_up_after_test_run() if not valid: failures = ['(entire test suite)'] with open(self.options.isolated_script_test_output, 'w') as fp: json.dump({ 'valid': valid, 'failures': failures, }, fp) return 1
def RunGTest(options, gtest_args): """Runs gtest with --trace-dir switch pointing at intermediate dir. Args: options: Parsed command line options. gtest_args: List of args to run gtest. Returns gtest run return code. """ trace_dir = _GetTraceDir(options) os.makedirs(trace_dir) gtest_args.append('--trace-dir=%s' % trace_dir) gtest_command = [options.executable] gtest_command.extend(gtest_args) return_code = test_env.run_command(gtest_command) return return_code
def run_command(argv, env=None, cwd=None): print('Running %r in %r (env: %r)' % (argv, cwd, env)) rc = test_env.run_command(argv, env=env, cwd=cwd) print('Command %r returned exit code %d' % (argv, rc)) return rc
#!/usr/bin/env python # Copyright (c) 2019 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Script for use in test_env unittests.""" import test_env if __name__ == '__main__': test_env.run_command(['python', 'test_env_test_script.py'])
#!/usr/bin/env python # Copyright (c) 2019 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Script for use in test_env unittests.""" import os import test_env HERE = os.path.dirname(os.path.abspath(__file__)) TEST_SCRIPT = os.path.join(HERE, 'test_env_test_script.py') if __name__ == '__main__': test_env.run_command([TEST_SCRIPT])
#!/usr/bin/env python # Copyright (c) 2019 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Script for use in test_env unittests.""" import os import sys import test_env HERE = os.path.dirname(os.path.abspath(__file__)) TEST_SCRIPT = os.path.join(HERE, 'test_env_test_script.py') if __name__ == '__main__': test_env.run_command([sys.executable, TEST_SCRIPT])