Commit ccb63d10 authored by Wez Furlong's avatar Wez Furlong Committed by Facebook Github Bot

getdeps: respect cmake WORKING_DIRECTORY for tests

Summary:
the cmake `add_test` and related functions allow specifying
the WORKING_DIRECTORY to use for tests.  We weren't respecting this
value, so this diff looks up the WORKING_DIRECTORY from the ctest
json info and adjusts the buck test info json blob that we pass
on the testpilot.

Since that interface only allows passing an argv array, we use
the `cmake -E chdir` command to run a command in a specified
directory in a portable manner.

Reviewed By: strager

Differential Revision: D15274012

fbshipit-source-id: 1f02d461d73178745794703d455494e31c2e09ed
parent b2cecfb5
......@@ -279,6 +279,21 @@ class CMakeBuilder(BuilderBase):
def run_tests(self, install_dirs):
env = self._compute_env(install_dirs)
ctest = path_search(env, "ctest")
cmake = path_search(env, "cmake")
def get_property(test, propname, defval=None):
""" extracts a named property from a cmake test info json blob.
The properties look like:
[{"name": "WORKING_DIRECTORY"},
{"value": "something"}]
We assume that it is invalid for the same named property to be
listed more than once.
"""
props = test.get("properties", [])
for p in props:
if p.get("name", None) == propname:
return p.get("value", defval)
return defval
def list_tests():
output = subprocess.check_output(
......@@ -288,12 +303,16 @@ class CMakeBuilder(BuilderBase):
tests = []
machine_suffix = self.build_opts.host_type.as_tuple_string()
for test in data["tests"]:
working_dir = get_property(test, "WORKING_DIRECTORY")
command = test["command"]
if working_dir:
command = [cmake, "-E", "chdir", working_dir] + command
tests.append(
{
"type": "custom",
"target": "%s-%s-getdeps-%s"
% (self.manifest.name, test["name"], machine_suffix),
"command": test["command"],
"command": command,
}
)
return tests
......
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