- Notifications
You must be signed in to change notification settings - Fork1.3k
How to update test files
If you are looking for how to create a new test file, seeHow to contribute to RustPython using CPython's unit tests
Because we have many# TODO: RUSTPYTHON
marks in the test code, updating is not trivial but still straightforward with a few tricks.
I am going to reproduce#3448 again to show the process.
We prefer to use version-tagged CPython source code than untagged one.
In the CPython repository,
$ git checkout v3.11.2
$ cp ../cpython/Lib/test/test_math.py Lib/test/test_math.py
This is the current state. Because we replaced the whole file with a new CPython one, we have the updated parts of the file but we've also lost our original edits.
Don't worry. Just rungit add -p
.
Typey
to accept any updates from CPython

We have 31 parts for this file. Keep going until you hit the original RustPython-specific edits.

Here, we're finally on one of the original edits. Presss
to split it.

Andn
to reject our original edit to be lost.

Andy
to accept CPython update again.

Keep going. Basically,n
for any lines withTODO: RUSTPYTHON
andy
for everything else.
Nowgit diff
shows onlyTODO: RUSTPYTHON
related changes

Commit it
$ git commit -m"Update test_math.py from CPython v3.10.0"
And reset to restore our original edits.
$ git reset --hard
Now the test file is updated, but we don't know if it passes yet - because there are newly added tests now.
Run the tests again
$ cargo run Lib/test/test_math.py
If there are failing tests, follow the instructions fromHow to contribute to RustPython using CPython's unit tests for the newly failing tests.
Please create a Pull Request with these changes. Thank you!