-
Notifications
You must be signed in to change notification settings - Fork 70
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
Use pytest for test running #297
Use pytest for test running #297
Conversation
I should note also: the advanced indexing PR was merged while I was still working on this. There was a small conflict for a few tests but I believe everything is carried over as it should be. But more eyes especially on that would be advised. |
@magnatelee @manopapad For now I am going to fix conflicts as they arise with rebase / force-push to keep the commit history clean. Let me know when you are starting a review and I will switch to merges if needed |
a30a50b
to
bbda5a9
Compare
for more information, see https://pre-commit.ci
moved/renamed/updated the recently merged fft tests in 4b81936 @mferreravila please take a look at the changes cc @magnatelee |
@bryevdv I left some comments. Looks good to me otherwise. One thing I noticed though is that the pytest driver seems to be hiding standard error messages that only show up with the |
@mferreravila 👍 For now I left all the print statements, but I parameterized them and moved to the "check" helper function, which is more convenient with parameterized tests in pytest |
@magnatelee see #297 (comment) for some comments. There's definitely lots of options. E.g. a test wrapper (like |
@magnatelee actually I may not have fully appreciated this comment. Are you saying that there can be runtime error messages with tests still passing? If a runtime error causes a test to fail (or fail to run) then it should be captured and displayed at the end of the pytest report with or without Or, do you mean when running with
|
@magnatelee here is an extremely quick and dirty diff that restores stdout from tests when
Would you like me to include it in this PR for now? I'd plan to fix it better in a PR dedicated to Edit: could also consider |
@bryevdv I wasn't talking about
This doesn't seem to be true. The pytest report only printed out any error messages from Python and masked those from the C++ runtime. I was able to see them only when I passed
Yes, I think we need both |
@mfoerste4 please confirm the merge conflict resolution in daa5ef9 |
Noting that 44771ea sets the default pytest capture mode to |
LGTM |
This PR convert the existing test modules to use
pytest
for test discovery and running. Tests were also updated for minor cleanup and to utilizepytest
features (e.g.parameterize
and fixtures) effectively. The end result is to afford testing options that are more familiar and ergonomic to "standard" python devs.Overview
Cleanup
A few commits perform some minor cleanup on the existing tests:
return
statements throughoutFile movement
To make it easier to use
pytest
for test selection, the existing tests were moved and renamed:3f3c5cb — move files to
integration
subdirectory9f4f410 — prefix all test module filenames with
test_
Moving the files to a subdirectory allows this entire group of tests to be easily run by executing
pytest
with this directory path. Thetest_
prefix is to conform withpytest
expectations for default test discovery.Pytest updates
test_
prefix. By default,pytest
will interpret anything starting withtest
orTest
as test to run.pytest
scaffolding to each test module and the least change to get running. For most tests this was just a couple of lines of boilerplate change. But a few tests required slightly more extensive updates.Notes
test.py
module runs exactly as before. The only change was to update it for the new path to the test files(see note about verbose output, though)legate.core
issue that currently required fixtures to avoid cunumeric array re-use in testsparametrize
anywhere it made sense, so that more fine-grained reporting output becomes available:Further notes will be inline.
Operation
Running
test.py
The existing way to run tests with
test.py
is unchanged:This still generates the existing report:
(Note: Currentlytest.py -v
only shows stdout fromtest.py
and not from tests. This will be straightforward to restore but I would like to do that in a follow-on PR dedicated totest.py
. Test stdout can be observed with either of the methods below with the standard-s
flag. cc @magnatelee)Executing individual tests
Individual tests can still be executed by running the module with
legate
including by passing in runtime command line options:However, now the output is a standard
pytest
report:It is also now possible to pass standard
pytests
options, e.g.-v
for a verbose report:Using
pytest
for test discoveryAlthough it is not yet possible to simply run
pytest <dir>
in the typical way, it is possible to achieve the same operation with a little more explicit invocation:Note that all the standard
pytest
options, e.g. incluing-k
and-m
for test filtering, can be used.The above will run all the tests under
tests/integration
, and generate a standard combinedpytest
report:The full report output text can be seen here:
There are some warning that show up in the output at the end, mostly about implicit casting. I am not sure if these are expected or not (I expect they would be)
Future work
Things that are not in this PR but are planned for follow-on PRs:
pytest
to run the examplesRestoring previous-v
behaviour totest.py
legate -m pytest