New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pytest: use output_files for junit XML generation option #10136
pytest: use output_files for junit XML generation option #10136
Conversation
Thanks Tom! It’d be good for us to test Junit XML. You can mostly copy the test_success method, minus setting up the flag + inspecting the XML file in the TestResult. I’m happy to help tomorrow with this. |
This issue is a problem long term, we basically have an API (output_directories) that works locally but won't work with remote execution, which is bad. |
REv2 is what actually defines We should probably have the local execution API print a warning (or maybe even error out) if a file ends up in |
assert file.path.startswith("dist/test-results") | ||
assert b"pants_test.test_good" in file.content | ||
|
||
@pytest.mark.skip(reason="https://github.com/pantsbuild/pants/issues/10141") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is skipped as per discussion with @Eric-Arellano who will fix as per #10141.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Tom!
assert "test_good.py ." in result.stdout | ||
assert result.xml_results is not None | ||
|
||
files: FilesContent = self.request_single_product(FilesContent, result.xml_results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the type hint is necessary. MyPy should be able to refer the type. I can fix this in a followup, though.
files: FilesContent = self.request_single_product(FilesContent, result.xml_results) | |
files = self.request_single_product(FilesContent, result.xml_results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove.
@Eric-Arellano: I have some additional testing to do this afternoon, will let you know when this is ready. I'm still testing the coverage-related change against build.toolchain.com |
Coverage passed remotely:
|
ed655d5
to
9addeda
Compare
Thanks again, Tom! |
…antsbuild#10136) When running pytest with JUnit XML generation enabled, the Pants pytest_runner [uses `output_directories` instead of `output_files` to make the output file known to the process executor](https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/python/rules/pytest_runner.py#L237-L245). This works fine with local execution but breaks with remote execution because RE servers can skip `output_directories` that are not in fact directories. This issue manifests as errors like this: ``` $ ./pants --pytest-junit-xml-dir=dist/test-results [remote-config options] test XXX 05:07:26.01 [INFO] Completed: Run Pytest for XXX 05:07:26.02 [WARN] Failed to generate JUnit XML data for XXX. 05:07:26.02 [INFO] Tests failed: XXX 𐄂 XXX ERROR: --junitxml must be a filename, given: XXX.xml ``` Use `output_files` instead for the JUnit XML generation file. The test runs and JUnit XML is properly generated and written to the local filesystem.
…antsbuild#10136) When running pytest with JUnit XML generation enabled, the Pants pytest_runner [uses `output_directories` instead of `output_files` to make the output file known to the process executor](https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/python/rules/pytest_runner.py#L237-L245). This works fine with local execution but breaks with remote execution because RE servers can skip `output_directories` that are not in fact directories. This issue manifests as errors like this: ``` $ ./pants --pytest-junit-xml-dir=dist/test-results [remote-config options] test XXX 05:07:26.01 [INFO] Completed: Run Pytest for XXX 05:07:26.02 [WARN] Failed to generate JUnit XML data for XXX. 05:07:26.02 [INFO] Tests failed: XXX 𐄂 XXX ERROR: --junitxml must be a filename, given: XXX.xml ``` Use `output_files` instead for the JUnit XML generation file. The test runs and JUnit XML is properly generated and written to the local filesystem.
…antsbuild#10136) When running pytest with JUnit XML generation enabled, the Pants pytest_runner [uses `output_directories` instead of `output_files` to make the output file known to the process executor](https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/python/rules/pytest_runner.py#L237-L245). This works fine with local execution but breaks with remote execution because RE servers can skip `output_directories` that are not in fact directories. This issue manifests as errors like this: ``` $ ./pants --pytest-junit-xml-dir=dist/test-results [remote-config options] test XXX 05:07:26.01 [INFO] Completed: Run Pytest for XXX 05:07:26.02 [WARN] Failed to generate JUnit XML data for XXX. 05:07:26.02 [INFO] Tests failed: XXX 𐄂 XXX ERROR: --junitxml must be a filename, given: XXX.xml ``` Use `output_files` instead for the JUnit XML generation file. The test runs and JUnit XML is properly generated and written to the local filesystem.
…herrypick of #10136) (#10324) When running pytest with JUnit XML generation enabled, the Pants pytest_runner [uses `output_directories` instead of `output_files` to make the output file known to the process executor](https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/python/rules/pytest_runner.py#L237-L245). This works fine with local execution but breaks with remote execution because RE servers can skip `output_directories` that are not in fact directories. This issue manifests as errors like this: ``` $ ./pants --pytest-junit-xml-dir=dist/test-results [remote-config options] test XXX 05:07:26.01 [INFO] Completed: Run Pytest for XXX 05:07:26.02 [WARN] Failed to generate JUnit XML data for XXX. 05:07:26.02 [INFO] Tests failed: XXX 𐄂 XXX ERROR: --junitxml must be a filename, given: XXX.xml ``` Use `output_files` instead for the JUnit XML generation file. The test runs and JUnit XML is properly generated and written to the local filesystem. Co-authored-by: Tom Dyas <tdyas@toolchain.com>
Problem
When running pytest with JUnit XML generation enabled, the Pants pytest_runner uses
output_directories
instead ofoutput_files
to make the output file known to the process executor. This works fine with local execution but breaks with remote execution because RE servers can skipoutput_directories
that are not in fact directories.This issue manifests as errors like this:
Solution
Use
output_files
instead for the JUnit XML generation file.Result
The test runs and JUnit XML is properly generated and written to the local filesystem.