diff --git a/build/fbcode_builder/getdeps.py b/build/fbcode_builder/getdeps.py index 3c6e145d6..4f25ed3c8 100755 --- a/build/fbcode_builder/getdeps.py +++ b/build/fbcode_builder/getdeps.py @@ -696,12 +696,14 @@ class TestCmd(ProjectCmdBase): builder = m.create_builder( loader.build_opts, src_dir, build_dir, inst_dir, ctx, loader ) + builder.run_tests( install_dirs, schedule_type=args.schedule_type, owner=args.test_owner, test_filter=args.filter, retry=args.retry, + no_testpilot=args.no_testpilot, ) install_dirs.append(inst_dir) @@ -719,6 +721,11 @@ class TestCmd(ProjectCmdBase): help="Number of immediate retries for failed tests " "(noop in continuous and testwarden runs)", ) + parser.add_argument( + "--no-testpilot", + help="Do not use Test Pilot even when available", + action="store_true", + ) @cmd("generate-github-actions", "generate a GitHub actions configuration") diff --git a/build/fbcode_builder/getdeps/builder.py b/build/fbcode_builder/getdeps/builder.py index a8a7c15a0..e74a6ef47 100644 --- a/build/fbcode_builder/getdeps/builder.py +++ b/build/fbcode_builder/getdeps/builder.py @@ -100,7 +100,9 @@ class BuilderBase(object): dep_dirs = self.get_dev_run_extra_path_dirs(install_dirs, dep_munger) dep_munger.emit_dev_run_script(script_path, dep_dirs) - def run_tests(self, install_dirs, schedule_type, owner, test_filter, retry): + def run_tests( + self, install_dirs, schedule_type, owner, test_filter, retry, no_testpilot + ): """ Execute any tests that we know how to run. If they fail, raise an exception. """ pass @@ -543,7 +545,9 @@ if __name__ == "__main__": env=env, ) - def run_tests(self, install_dirs, schedule_type, owner, test_filter, retry): + def run_tests( + self, install_dirs, schedule_type, owner, test_filter, retry, no_testpilot + ): env = self._compute_env(install_dirs) ctest = path_search(env, "ctest") cmake = path_search(env, "cmake") @@ -618,7 +622,7 @@ if __name__ == "__main__": retry = 0 testpilot = path_search(env, "testpilot") - if testpilot: + if testpilot and not no_testpilot: buck_test_info = list_tests() buck_test_info_name = os.path.join(self.build_dir, ".buck-test-info.json") with open(buck_test_info_name, "w") as f: @@ -709,12 +713,17 @@ if __name__ == "__main__": retcode = self._run_cmd( args, env=env, use_cmd_prefix=use_cmd_prefix, allow_fail=True ) + if retcode == 0: break if count == 0: # Only add this option in the second run. args += ["--rerun-failed"] count += 1 + if retcode != 0: + # Allow except clause in getdeps.main to catch and exit gracefully + # This allows non-testpilot runs to fail through the same logic as failed testpilot runs, which may become handy in case if post test processing is needed in the future + raise subprocess.CalledProcessError(retcode, args) class NinjaBootstrap(BuilderBase): @@ -1067,7 +1076,9 @@ incremental = false ) self.recreate_dir(build_source_dir, os.path.join(self.inst_dir, "source")) - def run_tests(self, install_dirs, schedule_type, owner, test_filter, retry): + def run_tests( + self, install_dirs, schedule_type, owner, test_filter, retry, no_testpilot + ): if test_filter: args = ["--", test_filter] else: