Skip to content

Implement selftest#332

Merged
yujiahu415 merged 4 commits intoumyelab:masterfrom
ruck94301:implement-selftest
Dec 29, 2025
Merged

Implement selftest#332
yujiahu415 merged 4 commits intoumyelab:masterfrom
ruck94301:implement-selftest

Conversation

@ruck94301
Copy link
Contributor

@ruck94301 ruck94301 commented Dec 18, 2025

I've convinced myself this is a good idea. If you're not as convinced, no worries, challenge me to defend it!

1. Why?
Because this is important for eventually testing compiled-builds. Pyinstaller has a reasonably good discovery process for finding what should be included when compiling, but it's not perfect. Missing items (if any) need to be identified manually and added to pyinstaller config file. Still need to test a compiled-build before blessing it for release, otherwise there's an unacceptable risk of releasing an "incomplete" LabGym. That risk needs to be mitigated, and performing a self-test is useful to develop confidence in the compiled-build candidate-for-release.

2. This seems useful only for compiled-builds, so why introduce it into main branch now? Why not wait and keep it in a separate dev branch for now?
That position is valid. But I'm thinking that as we write unit tests now (irrelevant of timeline for compiled-builds), we want those unit tests to work inside the LabGym context as well, so this lets us easily demonstrate that we are writing unit tests that are ultimately runnable from inside LabGym. As you can see from this PR, I had to rewrite some existing unit tests slightly to get them runnable from inside LabGym. I'm thinking better to not let unit test coverage grow with incompatibilities, that's the advantage of merging it now instead of later.

3. Is there any normal-user -facing change?
Yes there's a new menubar item "Misc" --> "Selftest" that pops up a modal dialog.
For now, instead of actually running the tests, it only gives instructions how to get LabGym to run the selftest.
I wanted to be able to run selftest from the menubar, but so far, I’m not seeing a good way to do it. That’s because wx.App is supposed to be a singleton, and, if you run unit tests that make changes to that wx.App instance, then you risk leaving behind a polluted wx.App.

4. How do you actually run the selftests?
Start LabGym with selftest action specified.
Either by command line option (--selftest) or by configfile entry, “selftest = true” (case sensitive!).
LabGym will execute selftests (same as pytest LabGym/tests/test*.py to run all test modules in LabGym/tests folder), then exit without proceeding to normal operation. Try it like
LabGym --debug --selftest

Without the --capture=no, it seemed like capturing wasn't reverted after pytest.main().
OTOH, I am unable to reproduce in a simple-test-case to report as a pytest bug.  :-/
@yujiahu415 yujiahu415 merged commit 6fe70cb into umyelab:master Dec 29, 2025
4 checks passed
@ruck94301 ruck94301 deleted the implement-selftest branch December 30, 2025 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants