Skip to content
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

Test framework one file #5

Merged
merged 167 commits into from
Dec 26, 2024
Merged

Test framework one file #5

merged 167 commits into from
Dec 26, 2024

Conversation

saurtron
Copy link
Owner

Work done

  • All jobs in one file

salinecitrine and others added 30 commits February 9, 2024 21:48
This is currently just a demonstration, and is not ready for production
use yet.

Tests can be executed with `/runtests <pattern1> ... <patternN>`, where
any test file (excluding file extension) that matches any pattern is
included. `/runtests` by itself will run all tests.

Features:

* setup/cleanup functions can be defined in each test file. cleanup will
always run, even if the test code fails.
* nicely formatted test results, including errors with line information
* two ways to call synced code:
  * `x = SyncedProxy.<Y>.<Z>()`, which is equivalent to `x = Y.Z()`
  executed in a synced context.
  * `x = SyncedRun(function() ... end)`, which allows execution of
  arbitrary code in a synced context. This is faster for things
  involving loops or many synced calls.
* wait API to allow in-game actions to happen during a test. For
example, `Test.waitFrames(5)` will wait 5 frames before resuming test
execution.
* `spy(parent, target)`, which allows tracking all calls to a spied
function.
* isolated environments for each test, while still having access to most
globals accessible to widgets.

Included are several sample widget tests, of a few different kinds:

* balance tests, that set up fights between units
* an example demonstrating different the wait API
* a test for a user widget (gui_battle_resource_tracker)
* several tests for a built-in widget (gui_selfd_icons)
  * some of these have sections testing bugs that are not fixed yet, and
   are thus commented out.

The serpent library is included for straightforward serialization.
right now it breaks wait timeouts
Calling `widgetHandler:EnableWidget(widgetName, true)` instead of
`widgetHandler:EnableWidget(widgetName)` will now allow access to local
variables as if they were globals, with `widget.localVariable`. Read and
write are both supported.
This allows us to leave the widget file untouched and still test it.
This more closely matches how they would be restored with the debug
library (when that becomes an option).
The previous behavior was between coroutine resumes, which led to
callins occasionally being lost.
Previously, line information was lost because the distance was set too
high.
Previously, sometimes the widget wouldn't have enough time to act before
the test checked results.
Otherwise we do a lot of steps very quickly. In headless mode this
significantly impacts how the game runs.
This is a tradeoff - this makes it so we can wait in cases where the
same event happens several times in a test, but it also makes it so we
can't wait for several of the same type of event sequentially (such as
waiting for several UnitCreated or UnitCommand events after causing
several).
Copy link

github-actions bot commented Dec 21, 2024

Test Results

15 tests   12 ✅  18s ⏱️
 1 suites   3 💤
 1 files     0 ❌

Results for commit 077271c.

♻️ This comment has been updated with latest results.

saurtron and others added 24 commits December 21, 2024 12:29
…tprint clearance" gadget and the "debris explosions" gadget (beyond-all-reason#4052)

* removed engine hotfixes gadget and devide its functions to a new footprint clearance gadget and the debris explosions gadget

* revert changes to debris explosion gadget: has already been in: #4053plemented as modrule in
…-all-reason#4081)

Fix typo at gui_transport_weight_limit later causing lua crash.
@saurtron saurtron merged commit b4d8f4c into master2 Dec 26, 2024
1 check passed
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.

9 participants