Skip to content
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

Add the ability to write junit test results file for pytest runs. #9594

Merged
merged 24 commits into from Apr 28, 2020

Conversation

asherf
Copy link
Member

@asherf asherf commented Apr 20, 2020

Problem

With the transition of pytest to the v2 engine, we lost the ability to write junit-xml results files when test runs.
This can't be solved by passing options thru directly to pytest since it expect a junit-xml result file name, which means we need a unique name for each target.

Solution

Introduce the ability to calculate the junit-xml file name based on a user provided direcotry (option) and the test target name.

Result

JUnit xml result files which can be processed by CI (CircleCI for example) so failing test can be seen w/o digging thru endless logs.

https://docs.pytest.org/en/latest/usage.html#creating-junitxml-format-files

@asherf asherf marked this pull request as draft April 20, 2020 00:46
Problem

With the transition of pytest to the v2 engine, we lost the ability to write junit-xml results files when test runs.
This can't be solved by passing options thru directly to pytest since it expect a junit-xml result file name, which means we need a unique name for each target.

 Solution

Introduce the ability to calculate the junit-xml file name based on a user provided direcotry (option) and the test target name.

 Result

JUnit xml result files which can be processed by CI (CircleCI for example) so failing test can be seen w/o digging thru endless logs.
@asherf asherf marked this pull request as ready for review April 20, 2020 03:02
@asherf
Copy link
Member Author

asherf commented Apr 20, 2020

Happy to take feedback and improve this implementation... as I am not a 100% this is the optimal way to address this issue.

@asherf
Copy link
Member Author

asherf commented Apr 20, 2020

@stuhood @Eric-Arellano

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you for taking the time to fix this! I hope my comment helps. Please feel free to ask any clarifications and I'm happy to pair on this too if it would help :)

src/python/pants/core/goals/test.py Outdated Show resolved Hide resolved
@asherf
Copy link
Member Author

asherf commented Apr 26, 2020

Updated, also added junit_family as per https://docs.pytest.org/en/latest/deprecations.html#junit-family-default-value-change-to-xunit2
thanks to @Eric-Arellano for pairing with to help get this over the finish line!

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay! This looks really good.

src/python/pants/backend/python/subsystems/pytest.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/subsystems/pytest.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/rules/pytest_runner.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/rules/pytest_runner.py Outdated Show resolved Hide resolved
src/python/pants/backend/python/rules/pytest_runner.py Outdated Show resolved Hide resolved
src/python/pants/core/goals/test.py Outdated Show resolved Hide resolved
@asherf
Copy link
Member Author

asherf commented Apr 28, 2020

Screen Shot 2020-04-27 at 6 28 22 PM

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Will merge on green :)

@Eric-Arellano Eric-Arellano merged commit df7019f into pantsbuild:master Apr 28, 2020
@asherf asherf deleted the py2 branch April 28, 2020 04:30
This was referenced Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants