Re-write flag values to place generated files in undeclared outputs dir#7
Conversation
Some common pytest plugins, such as pytest-reportlog, pytest-json-report and pytest-html, allow the user to generate reports, accepting a file path as a flag. In Bazel, these generated files can only be accessed if placed inside the test undeclared outputs dir. However, bazel doesn't provide any way to expand environment variable values provided in args. This commit rewrites flag values for the plugins mentioned above, prepend the test undeclared output dir folder to the value of the corresponding flags.
|
@caseyduquettesc Thanks for accepting the PR! Small question - when trying out this with So, in my repo, I override it back ( |
|
@amartani Yeah there is a gotcha. If output is captured, However, I was just refreshing myself on what |
|
That does work, but I think I would still personally prefer the default pytest behavior by default, and tell people to use That said, it's easy to override, both when using the rule from |
Some common pytest plugins, such as pytest-reportlog, pytest-json-report and pytest-html, allow the user to generate reports, accepting a file path as a flag. In Bazel, these generated files can only be accessed if placed inside the test undeclared outputs dir. However, bazel doesn't provide any way to expand environment variable values provided via args.
This commit rewrites flag values for the plugins mentioned above, prepend the test undeclared output dir folder to the value of the corresponding flags. This allows passing relative paths to these flags (via
args = []or via--test_arg), and the shim fixes the flag values.