Skip to content

Conversation

@saurtron
Copy link
Owner

Work done

Test steps

  • Write the steps needed to test out the changes. Include the expected result.

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
Co-authored-by: sprunk <spr.ng@o2.pl>
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).
@saurtron saurtron reopened this Dec 18, 2024
Repository owner deleted a comment from github-actions bot Dec 18, 2024
@saurtron saurtron closed this Dec 18, 2024
@saurtron saurtron reopened this Dec 18, 2024
@github-actions
Copy link

github-actions bot commented Dec 18, 2024

Test Results

14 tests  ±0   13 ✅ ±0   18s ⏱️ ±0s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    1 ❌ ±0 

For more details on these failures, see this check.

Results for commit eff0721. ± Comparison against base commit baa7b50.

♻️ This comment has been updated with latest results.

@saurtron saurtron closed this Dec 18, 2024
@saurtron saurtron reopened this Dec 18, 2024
@saurtron saurtron force-pushed the master branch 2 times, most recently from 34a9bca to 89fc451 Compare December 21, 2024 18:02
saurtron pushed a commit that referenced this pull request Feb 24, 2025
most muzzleflashes should work now.
@saurtron saurtron force-pushed the master branch 2 times, most recently from 4643179 to b3c7787 Compare April 15, 2025 16:35
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.

4 participants