mirror of
https://github.com/facebook/proxygen.git
synced 2025-08-08 18:02:05 +03:00
fbcode_builder: getdeps: use testpilot when available to record tests
Summary: If `testpilot` is available, generate a buck compatible json file describing the available test binaries and feed that to testpilot to have it run the tests. A later (yet to be written) diff will be able to pass appropriate flags down to testpilot in continuous runs and that will allow testpilot to auto-disable and file tasks for tests in the opensource builds. Reviewed By: simpkins Differential Revision: D14766856 fbshipit-source-id: 4e144ff18f6788cf5e830d29788eabd2dbbae46a
This commit is contained in:
committed by
Facebook Github Bot
parent
cddc502b92
commit
cf6c8a3233
@@ -9,9 +9,11 @@
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from .envfuncs import Env, add_path_entry, path_search
|
||||
@@ -276,8 +278,53 @@ class CMakeBuilder(BuilderBase):
|
||||
def run_tests(self, install_dirs):
|
||||
env = self._compute_env(install_dirs)
|
||||
ctest = path_search(env, "ctest")
|
||||
|
||||
def list_tests():
|
||||
output = subprocess.check_output(
|
||||
[ctest, "--show-only=json-v1"], env=env, cwd=self.build_dir
|
||||
)
|
||||
data = json.loads(output.decode("utf-8"))
|
||||
tests = []
|
||||
machine_suffix = self.build_opts.host_type.as_tuple_string()
|
||||
for test in data["tests"]:
|
||||
tests.append(
|
||||
{
|
||||
"type": "custom",
|
||||
"target": "%s-%s-getdeps-%s"
|
||||
% (self.manifest.name, test["name"], machine_suffix),
|
||||
"command": test["command"],
|
||||
}
|
||||
)
|
||||
return tests
|
||||
|
||||
testpilot = path_search(env, "testpilot")
|
||||
if 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:
|
||||
json.dump(buck_test_info, f)
|
||||
|
||||
env.set("http_proxy", "")
|
||||
env.set("https_proxy", "")
|
||||
self._run_cmd(
|
||||
[ctest, "--output-on-failure", "-j", str(self.build_opts.num_jobs)], env=env
|
||||
[
|
||||
testpilot,
|
||||
# Need to force the repo type otherwise testpilot on windows
|
||||
# can be confused (presumably sparse profile related)
|
||||
"--force-repo",
|
||||
"fbcode",
|
||||
"--force-repo-root",
|
||||
self.build_opts.fbsource_dir,
|
||||
"--buck-test-info",
|
||||
buck_test_info_name,
|
||||
],
|
||||
cwd=self.build_opts.fbcode_builder_dir,
|
||||
env=env,
|
||||
)
|
||||
else:
|
||||
self._run_cmd(
|
||||
[ctest, "--output-on-failure", "-j", str(self.build_opts.num_jobs)],
|
||||
env=env,
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user