-
Notifications
You must be signed in to change notification settings - Fork 1.3k
How to update test files
If you are looking for how to create a new test file, see How 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 run git add -p
.
Type y
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. Press s
to split it.

And n
to reject our original edit to be lost.

And y
to accept CPython update again.

Keep going. Basically, n
for any lines with TODO: RUSTPYTHON
and y
for everything else.
Now git diff
shows only TODO: 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 from How to contribute to RustPython using CPython's unit tests for the newly failing tests.
Please create a Pull Request with these changes. Thank you!