-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
mpremote/tests: Rewrite test runner to run correctly under Windows. #17089
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #17089 +/- ##
==========================================
- Coverage 98.41% 98.38% -0.03%
==========================================
Files 171 171
Lines 22210 22239 +29
==========================================
+ Hits 21857 21880 +23
- Misses 353 359 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code size report:
|
Windows - Git BashSome test cases pass : ./test_eval_exec_run.sh: OK all others fail Tests fail when
Details
testrub with 'echo -n "" | sha256sum -t' fix
```
EUROPE+josverl@josverl-sb5 MINGW64 /d/mypython/micropython/tools/mpremote/tests (mpremote-testfix)
$ ./run-mpremote-tests.sh
./test_eval_exec_run.sh: OK
./test_filesystem.sh: FAIL
13,15c13,15
< cp C:/Users/josverl/AppData/Local/Temp/tmp.U2wf3UI3x1/a.py :
< cp C:/Users/josverl/AppData/Local/Temp/tmp.U2wf3UI3x1/a.py :b.py
< cp C:/Users/josverl/AppData/Local/Temp/tmp.U2wf3UI3x1/a.py :c.py
---
> cp |
@Josverl could you test the latest push? I've now majorly rewritten most of the test runner script with far more paranoid/maximalist quoting, and updated it to use a separate results directory to match the behavior of the main test suite (with a This also reduces some of the jank by inverting the way the tests are compared -- that is, instead of trying to use sed to replace instances of the temporary directory path with the string Also updated, it uses a diff compare mode that ignores carriage returns, and outputs the failure diffs at the end in unified-diff format the same way the main test suite does. I've also fixed the tests that were individually broken due to insufficient quoting, and added |
aaea140
to
c885ac3
Compare
initial results : recursive now also FAILS ./test_eval_exec_run.sh: OK common issues : I think the bash syntax: I think the diffing on errors would be better to understand when main problems in filesystem test
Details : https://gist.github.com/Josverl/32de060bfa072f19ea55ad326aca6403 🪲While debugging I found this bug 🦗 The same command works just fine in Windows powershell or even an old style command prompt. Personally I think that test are best written using a test framework, such as pytest. https://github.com/Josverl/micropython/blob/mpr/pytest/tools/mpremote/tests/test_filesystem.py |
I really need to spend some more time getting my Windows build environment working so we're not just playing telephone on this.
I'll try to see about refactoring this.
You're right that that that doesn't address all possible escaping problems, but there is one remaining issue I also just spotted even with that, in that it's actually the missing
Good catch, the other test runners also diff their
Could you run that command with
Agreed, this should also at least support
Almost definitely. There's a saying that, if you're using arrays in bash, it's time to rewrite it in a different language... and the rewrite technically does, even if just barely. As a shell tool, it makes sense to have the test case files for mpremote in shell languages, but I do think it'll be useful to rewrite the test runner in python so it can reuse and integrate with parts of the other test runners. I want to get to a working 'good' config first before refactoring further, though -- it's not just the runner that's broken, many of the actual tests are too. |
ec064be
to
e6c22b2
Compare
e6c22b2
to
c7182e4
Compare
Is this ready for another test run? |
Not really, no; just rebased this in order to more easily experiment with #12802 --- since its patch theoretically enables raw repl mode on the unix port, and might make it possible to run the mpremote tests as part of CI. |
7cf5415
to
545b256
Compare
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
45fa6d5
to
05abd10
Compare
Replacing the original bash script with a test script derived from the main suite's run-tests.py. Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
05abd10
to
c18a821
Compare
@Josverl Just rewrote the test driver to use more-or-less the same test code as the main suite's I've tested it against my own boards and can confirm it works correctly on unix; and since it's now just doing exactly what the main test suite does it should be compatible with windows too. Theoretically, hopefully you can confirm this. It now also looks for and tries to run Still need to test the merge with #12802 or #16141 to confirm that the micropython socket server it sets up actually works though, and add the relevant CI jobs for it. On a separate note, does the Windows port of micropython support raw repl mode? If it's possible to add an mpremote CI job for windows that'd be pretty useful to have too, given that it's been one of the tool's main pain points. |
Summary
This PR rewrites the test runner script used for testing mpremote to run correctly under Windows, and adds some functionality present in the main test runner that it was previously missing.
This PR adds inheritance behavior for the
TESTS_DIR
andMPREMOTE
variables in therun-mpremote-tests.sh
test script. It adds a newRESULT_DIR
variable that can be specified to direct the runner for a path to place output.exp
and.out
files. It expands the use of the input arguments to allow specifying multiple test scripts.Among other things, this rewrite also enables multiple concurrent instances of the test runner to be run against multiple simultaneously-connected target boards, via:
Previously, the test runner had no way to override its automatic serial port selection, and concurrent instances had no way to specify different output paths to avoid clobbering each other's
.out
files.Testing
I've tested these changes manually and as part of the local automations I've been using to test #16994. I can confirm they address the configurability and concurrency issues described above.
For the moment I'm relying on @Josverl to report on whether this rewrite runs appropriately under Windows implementations of bash.
Trade-Offs and Alternatives
Some attention should probably be paid to adapting this to also run against locally-runnable ports, so that the mpremote tests can be added to automated CI/CD.