Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18803 +/- ##
=======================================
Coverage 98.42% 98.42%
=======================================
Files 174 174
Lines 22333 22333
=======================================
Hits 21982 21982
Misses 351 351 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Can you elaborate on this ? |
1 similar comment
Can you elaborate on this ? |
I presume he just means to not "accidentally" add a leading ./ to the domain arg! This change looks straightforward enough to me, a quick dry run to see what tests are going to be run can be useful before starting a bigger test run. Is skip tests logic the only thing that could get confused by the different path syntax? Should the -d arg be passed through realpath immediately to verify it and make it consistently formatted for all things that use it? |
Signed-off-by: stijn <stijn@ignitron.net>
This is convenient when trying to figure out the correct values for --include/--exclude/--test-dirs/... arguments. Signed-off-by: stijn <stijn@ignitron.net>
Test file paths which get passed to the run_tests function can be absolute or relative and with or without leading slash in the latter case, depending on the arguments to run-tests.py, but the skip_tests list with tests to skip only contains relative paths so using simple string equality comparison easily leads to false negatives. Compare the full absolute path instead such that it doesn't matter anymore in which form the tests are passed. Note: - use realpath to resolve symlinks plus make the comparison case insensitive on windows - the test_file passed to run_one_test is not altered by this commit, such that when the user inputs relative paths the tests are also still displayed with relative paths - likewise the test_file_abspath is not modified because functions like run_micropython rely on it having forward slashes In practice this means that it used to be so that the only forms of running tests for which the skip_tests lists actually worked were: >python ./run-tests.py >python ./run-tests.py -d extmod whereas it now works consistently so also for these invocations, which in the end all point to the exact same path: >python ./run-tests.py -d ./extmod >python ./run-tests.py -d ../tests/extmod >python ./run-tests.py -d /full/path/to/tests/extmod These examples used to not skip any of the tests in the extmod/ directory thereby leading to test failures. Signed-off-by: stijn <stijn@ignitron.net>
Scan the --test-dirs argument for the main tests directory being passed and if so do the same thing as if running from within that main test directory. In practice this makes the following (which used to counterintuitively try and fail to run the .py files in the tests/ directory itself) >python micropython/tests/run-tests.py -d micropython/tests do the same thing as >cd micropython/tests >python ./run-tests.py which is logical and convenient. Signed-off-by: stijn <stijn@ignitron.net>
Signed-off-by: stijn <stijn@ignitron.net>
Yes that's it. Don't know where it came from but I have the habit of always using leading ./ and that is hard to unlearn just for running micropython tests. Probably because of working in different shells and some of them requiring files in current directory needing that in some circumstances. Plus powershell completion/fuzzy search/... I'm using adds it anyway.
I think so, yes. There were some cmdline/ tests which relied on relative paths though so I fixed that. I also added a commit which fixes another issue I've been eying for a while: the test output (i.e. what is displayed, goes in results.json etc) also used to be literally what was passed. But that would result in different display for the exact same file depending on how the path was passed. Also added another commit which makes passing the tests/ directory itself via Issue description is updated with more examples. |
e1c1c6f to
fbbe098
Compare
Test file paths which get passed to the run_tests function can be absolute or relative and with or without leading slash in the latter case, depending on the arguments to run-tests.py, but since that path is used to: - display which tests run - record which tests ran in the results.json - craft the filename for the .exp/.out file for failed tests it is desirable to always use the same file path irregardless of how the user passed the path. In practice this means that all forms of running our own tests like: >python ./run-tests.py -i extmod >python ./run-tests.py -d extmod >python ./run-tests.py -d ./extmod >python ./run-tests.py -d ../tests/extmod >python ./run-tests.py -d /full/path/to/tests/extmod will now consistently all display the tests like pass extmod/time_time_ns.py FAIL extmod/some_failing_test.py and produce output files like results/extmod_some_failing_test.py.exp results/extmod_some_failing_test.py.out instead of displaying/using the exact path as passed. For external tests, meaning not in the tests/ directory, we also want to be consistent so there the choice was made to always use absolute paths. Signed-off-by: stijn <stijn@ignitron.net>
fbbe098 to
6fc41e1
Compare
|
Code size report: |
Summary
Fix confusing issues like
by comparing full paths for the
skip_testslogic.Fix
by running the normal test suite since the directory passed is our own tests/ directory.
Make test display and output consistent, such that
instead will always use the first form extmod/btree1.py, both in display and results.json, and in case of failure will also always output the same .out/.exp files (so not e.g. extmod_btree1.py.exp for the first case but _full_path_to_extmod_btree1.py.exp for the second case).
Add a
--dry-runargument to show which test files would be ran (only implemented for run-tests, not run-multitests etc, would that be wanted?):Testing
Commands shown above and in the commit message were all tested successfully on unix and windows ports.
Trade-offs and Alternatives
Trade-off: code is somewhat more complex,
realpathmight hit filesystem and be slower.Alternative implementation: the overall proper fix would probably be to put any path which enters or is used in run-tests.py to be wrapped in
pathlib.Path(<somepath>).resolve()(maybe even add anexpanduserthere) so any comparison just works and the various realpath/abspath calls and having to differentiate test_file/test_file_abspath/... can be gone.Alternative usage: learn to use run-tests.py 'properly' as to workaround these issues (I for one can apparently not do that because I've ran into this quite way too much :) )