-
Notifications
You must be signed in to change notification settings - Fork 55
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
Re-structured functional tests. #402
base: master
Are you sure you want to change the base?
Conversation
94d6357
to
9fef5fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv
sounds promising, it really is faster than alternatives. If this indeed fixes our nix setup, more than happy to make this change.
Just some minor nits from me. I've ran the tests and works fine
README.md
Outdated
# recomended way | ||
pipx install poetry | ||
# create a virtual environment | ||
# (it's good to not messing up with your OS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it's good to not mess up with your os
# official isntaller (windows - powershell) | ||
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py - | ||
# Alternatively, you can synchronize it | ||
uv sync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't uv pip install -r pyproject.toml
redundant with uv sync
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what i understood in docs:
-
uv pip install -r pyproject.toml
installs dependencies listed inpyproject.toml
(in local development environment, it do not remove existing packages). -
uv sync
uses theuv.lock
file to enforce reproducible installations.
So the sync
reproduced what i made here. Maybe it's better add this warning?
|
||
```bash | ||
pip3 install -r tests/requirements.txt | ||
python tests/run_tests.py | ||
uv run tests/run_tests.py --test-suite <suite> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add that to run all tests, just omit --test-suite
.
Also, is there a way to list all available ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the same suggestion to @qlrd while he was at casavinteum. And looks like he already implemented.
When tests.py are invoked without -t
or --test-suite
set, it computes every subfolder of tests/
as a suite. test_framework
isnt added as suite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree with davidson, a uv run tests/run_tests.py --list-suites
would be nice, one that is debugging our python tests can use this command to undersand what run_tests.py
see as a suite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
@jaoleal, i improved it and i think is more clear. I added here a --list-suite and will do a rebase.
from test_framework.test_framework import FlorestaTestFramework | ||
from test_framework.electrum_client import ElectrumClient | ||
from test_framework.floresta_rpc import REGTEST_RPC_SERVER | ||
from tests.test_framework.test_framework import FlorestaTestFramework |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a way to set the root dir to /tests/
. Not a roadblocker, but a minor annoyance to need this tests.*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, i will need try here @Davidson-Souza.
This commit aims to optmize developer flow and the experience with tests tool through 1) a replacement of the current python package management; 2) a more organized folder tree strucutre inside tests/; and 3) changes in tests/run_tests.py, tests/prepare.sh and tests/run.sh to comply with the already mentioned changes. The replacement in python package management is from poetry to uv (a rust-based python management tool); this approach have some PROS: (i) built with rust; (ii) faster than poetry; (iii) cleanup some unecessary python dependencies; (iv) more readable pyproject.toml; (v) compatible with python pip install -r approach (for old-school pythonists). Until now, a CON is: (i) this remove some poetry macros. Still seems like a good replacement. The folder structure organization allows you to define test suites in separate folders (e.g. "florestad", "floresta-cli") without needing to define each of them in pyproject.toml. Files ending with "-test.py" in each folder will be recognized and executed. To comply with above mentioned changes, tests/run_tests.py was modified to inlcude an argument `--test-suite` that will search for a folder `tests/<test-suite>`. It was also necessary to change `tests/prepare.sh` and `tests/run.sh` to replace poetry to uv. The README helps the developer to: (i) install uv; (ii) configure functional test environment; (iii) format code; (iv) lint code; (v) run tests. It also updated .gitignore so it can help to avoid add .venv folder that is created by uv tool. updated run_tests.py updated README updated run_tests.py
Improves #252
What is the purpose of this pull request?
Which crates are being modified?
Description
This re-structure aims to optmize developer flow and the experience with tests tool through 1) a replacement of the current python package management; 2) a more organized folder tree strucutre inside tests/; and 3) changes in tests/run_tests.py, tests/prepare.sh and tests/run.sh to comply with the already mentioned changes.
The replacement in python package management is from poetry to uv (a rust-based python management tool); this approach have some PROS: (i) built with rust; (ii) faster than poetry; (iii) cleanup some unecessary python dependencies; (iv) more readable pyproject.toml; (v) compatible with python pip install -r approach (for old-school pythonists). Until now, a CON is: (i) this remove some poetry macros. Still seems like a good replacement.
The folder structure organization allows you to define test suites in separate folders (e.g. "florestad", "floresta-cli") without needing to define each of them in pyproject.toml. Files ending with "-test.py" in each folder will be recognized and executed.
To comply with above mentioned changes, tests/run_tests.py was modified to inlcude an argument
--test-suite
that will search for a foldertests/<test-suite>
. It was also necessary to changetests/prepare.sh
andtests/run.sh
to replace poetry to uv.Notes to the reviewers
A better context about this change is available in #252 (comment) and #391. Tested this approach in https://github.com/qlrd/Floresta/actions/runs/13722793641/job/38381971781
Checklist
just lint
cargo test