def run_wpr_test(self, udid, test_name, recipe_path, replay_path): """Runs a single WPR test. Args: udid: UDID for the simulator to run the test on test_name: Test name(format: ios_website) of this wpr test. recipe_path: Path to the recipe file (i.e. ios_costco.test) replay_path: Path to the replay file (i.e. ios_costco) Returns [parser, return code from test] where parser: a XCTest or GTestLogParser which has processed all the output from the test """ LOGGER.info('Running test for recipe %s', recipe_path) self.wprgo_start(replay_path) # TODO(crbug.com/881096): Consider reusing get_launch_command # and adding the autofillautomation flag to it # TODO(crbug.com/881096): We only run AutofillAutomationTestCase # as we have other unit tests in the suite which are not related # to testing website recipe/replays. We should consider moving # one or the other to a different suite. # For the website replay test suite, we need to pass in a single # recipe at a time, with flags "autofillautomation={recipe_path}", # "--enable-features=AutofillShowTypePredictions". The args are written in # xctestrun file, which is produced through EgtestsApp and LaunchCommand # defined in xcodebuild_runner. wpr_test_cmd = self.get_wpr_test_command(recipe_path, test_name) proc = self.start_proc(wpr_test_cmd) old_handler = self.set_sigterm_handler( lambda _signum, _frame: self.handle_sigterm(proc)) if self.xctest_path: parser = xctest_utils.XCTestLogParser() else: parser = gtest_utils.GTestLogParser() test_runner.print_process_output(proc, 'xcodebuild', parser) proc.wait() self.set_sigterm_handler(old_handler) sys.stdout.flush() self.wprgo_stop() return parser, proc.returncode
def _launch_app_once(self, out_sub_dir, verify_fetched_within_launch=False): """Launches app once. Args: out_sub_dir: (str) Sub dir under |self.out_dir| for this attempt output. verify_fetched_within_launch: (bool) Whether to verify that the fetch would happens in current launch. Returns: (test_result_util.ResultCollection): Raw EG test result of the launch. """ launch_out_dir = os.path.join(self.out_dir, out_sub_dir) if verify_fetched_within_launch: self.test_app.test_args.append( _VERIFY_FETCHED_IN_CURRENT_LAUNCH_ARG) cmd = self.test_app.command(launch_out_dir, 'id=%s' % self.udid, 1) proc = subprocess.Popen( cmd, env=self.env_vars or {}, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) output = test_runner.print_process_output(proc) if _VERIFY_FETCHED_IN_CURRENT_LAUNCH_ARG in self.test_app.test_args: self.test_app.test_args.remove( _VERIFY_FETCHED_IN_CURRENT_LAUNCH_ARG) return self.log_parser.collect_test_results(launch_out_dir, output)
def launch_attempt(self, cmd): """Launch a process and do logging simultaneously. Args: cmd: (list[str]) A command to run. Returns: output - command output as list of strings. """ proc = subprocess.Popen( cmd, env=self.env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) return test_runner.print_process_output(proc)