Commit cd9669af authored by Koray Polat's avatar Koray Polat Committed by Facebook GitHub Bot

Add option to run tests without Testpilot even when it's available

Summary:
- Added a commandline flag to ignore testpilot even when it's available
- Fixed an oversight that caused getdeps to return 0 even if ctest tests have failed.

Reviewed By: wez

Differential Revision: D23161362

fbshipit-source-id: 1ed97c481315e2b39f1128680386390930194970
parent a6de480b
......@@ -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")
......
......@@ -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:
......
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