-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Note
Unless stated otherwise, all commands needs to run from the RustPython directory.
This guide assumes that you have a copy of CPython on your machine, and for the rest of the guide we are going to assume that our CPython clone is at ~/cpython/.
If you don't have a copy of CPython you can get one by running:
git clone https://github.com/python/cpython.git ~/cpythonNote
We prefer to use a tagged version for the library updates, to do so run the following:
cd ~/cpython
git checkout v3.13.9Is as simple as:
cp -a ~/cpython/Lib/base64.py Lib/Important
While we try to avoid it as much as possible, we have some libraries that were patched by us. Run:
git diffSearch for RUSTPYTHON, and reapply the patches manually (if there are any)
Because we have many # TODO: RUSTPYTHON marks in the test code, we have written our own tool to update test files.
The tool aims to automate the processes of transferring test marks (# TODO: RUSTPYTHON) from our current version of the test, to the upstream version from CPython.
Simply run:
./scripts/lib_updater.py --from Lib/test/test_os.py --to ~/cpython/Lib/test/test_os.py -o Lib/test/test_os.pyThe tool will:
- Read the patches from
Lib/test/test_os.py(--from) - Apply those patches to
~/cpython/Lib/test/test_os.py(--to) - Write the results to
Lib/test/test_os.py(-o)
Important
We might have patched some tests by commenting unsupported syntax, or changing test behavior because of an implementation detail that needs to be reapplied manually.
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_os.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!