Refactor to remove test args from remote test command #3266
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
plz test [TARGET]
can take an argument to specify specific parts of a test target to run.For example,
plz test //[TARGET] -- [TestSubTarget]
runs the subtarget function rather than all of the test functions in the target.You can also specify what tests to run at a more granular level: e.g. [TestSubTarget/[NestedTestFunction]/[NestedTestFunction]
Problem
When specifying subtargets in
plz test ...
you get an error when you pass an argument that has a slash (e.g.plz test //[TARGET] -- TestSubTarget/MyTestFunction
.This shows up by running an additional test that errors, such as
Root cause
Please is constructing a
cmd
that callstee
and appendsTestArgs
at the end.This constructs a command like
$TEST 2>&1 | tee $TMP_DIR/test.results [one or more subtests]
.This is relevant because
tee
reads fromstdin
($TEST 2>&1
) and writes tostdout
and files ($TMP_DIR/test.results [one or more subtests]
).Thus, this means that
plz test //[TARGET] -- [TestSubTarget]
creates and writes to the fileTestSubTarget
plz test //[TARGET] -- [TestSubTarget/[NestedTestFunction]/[NestedTestFunction]
interprets the forward slashes as file paths and tries to create a file in said path but errors because the directory doesn't existSolution
The implication is that we need to avoid passing the subtests before the pipe to
tee
.I thus removed the
if
statement to avoid passing the test arguments in the command.Testing
I built Please with these changes and it worked as expected, only printing the subtests I passed and no erroring like it does now.
I'm concerned about any regressions and am not sure how to best test this.
Pending work
This only solves the problem on remote execution, not local execution.