def test_xvfb(self): args = ['xvfb-run', '--auto-servernum', '--server-args', '-screen 0 640x480x24', '--error-file', '/some/output.log', '/bin/sh', 'launch_chrome', 'run', 'this-app.apk', '--with-this-option'] self.assertTrue(launch_chrome_util.is_launch_chrome_command(args)) self.assertEqual(['run', 'this-app.apk', '--with-this-option'], launch_chrome_util.remove_leading_launch_chrome_args(args)) args = ['xvfb-run', '--auto-servernum', '--server-args', '-screen 0 640x480x24', '--error-file', '/some/output.log', 'do-something-else'] self.assertFalse(launch_chrome_util.is_launch_chrome_command(args))
def test_xvfb(self): args = [ 'xvfb-run', '--auto-servernum', '--server-args', '-screen 0 640x480x24', '--error-file', '/some/output.log', '/bin/sh', 'launch_chrome', 'run', 'this-app.apk', '--with-this-option' ] self.assertTrue(launch_chrome_util.is_launch_chrome_command(args)) self.assertEqual( ['run', 'this-app.apk', '--with-this-option'], launch_chrome_util.remove_leading_launch_chrome_args(args)) args = [ 'xvfb-run', '--auto-servernum', '--server-args', '-screen 0 640x480x24', '--error-file', '/some/output.log', 'do-something-else' ] self.assertFalse(launch_chrome_util.is_launch_chrome_command(args))
def run_subprocess_test(self, scoreboard, test_name, command, env=None): """Runs a test which runs subprocess and sets status appropriately. - test_name: The name of this test. This should be 'test_fixter#test_method' style. - command: A list of strings. Command line to run subprocess. - env: Environment dict for the subprocess. Maybe None. """ assert not launch_chrome_util.is_launch_chrome_command(command), ( 'For testing with ./launch_chrome, you should use run_subprocess() ' 'method instead.: %s' % str(command)) scoreboard.start_test(test_name) try: self.run_subprocess(command, env=env) status = test_method_result.TestMethodResult.PASS except subprocess.CalledProcessError: status = test_method_result.TestMethodResult.FAIL result = test_method_result.TestMethodResult(test_name, status) scoreboard.update([result])
def _write_args_if_needed(self, args): """Writes args to a file if it is too long and returns a new args.""" # Do not rewrite args of the commands other than launch_chrome because # the commands do not necessarily support the syntax of reading arguments # from a file. if not launch_chrome_util.is_launch_chrome_command(args): return args remaining_args = launch_chrome_util.remove_leading_launch_chrome_args(args) args_string = '\n'.join(remaining_args) # Do not rewrite args to file if the argument list is short enough. if len(args_string) < SuiteRunnerBase.WRITE_ARGS_MIN_LENGTH: return args args_dir = os.path.join(build_common.get_build_dir(), 'integration_tests') file_util.makedirs_safely(args_dir) args_file = os.path.join(args_dir, self._name + '_args') with open(args_file, 'w') as f: f.write(args_string) return args[:-len(remaining_args)] + ['@' + args_file]
def _write_args_if_needed(self, args): """Writes args to a file if it is too long and returns a new args.""" # Do not rewrite args of the commands other than launch_chrome because # the commands do not necessarily support the syntax of reading arguments # from a file. if not launch_chrome_util.is_launch_chrome_command(args): return args remaining_args = launch_chrome_util.remove_leading_launch_chrome_args( args) args_string = '\n'.join(remaining_args) # Do not rewrite args to file if the argument list is short enough. if len(args_string) < SuiteRunnerBase.WRITE_ARGS_MIN_LENGTH: return args args_dir = os.path.join(build_common.get_build_dir(), 'integration_tests') file_util.makedirs_safely(args_dir) args_file = os.path.join(args_dir, self._name + '_args') with open(args_file, 'w') as f: f.write(args_string) return args[:-len(remaining_args)] + ['@' + args_file]
def test_not_launch_chrome(self): args = ['gcc', '-c', 'whatever'] self.assertFalse(launch_chrome_util.is_launch_chrome_command(args))
def test_normal(self): args = ['/bin/sh', 'launch_chrome', 'run', 'whatever'] self.assertTrue(launch_chrome_util.is_launch_chrome_command(args)) self.assertEqual( ['run', 'whatever'], launch_chrome_util.remove_leading_launch_chrome_args(args))
def test_normal(self): args = ['/bin/sh', 'launch_chrome', 'run', 'whatever'] self.assertTrue(launch_chrome_util.is_launch_chrome_command(args)) self.assertEqual(['run', 'whatever'], launch_chrome_util.remove_leading_launch_chrome_args(args))