[Tests] Restructure integration tests to table-return shape#7437
Draft
keithharvey wants to merge 1 commit intobeyond-all-reason:masterfrom
Draft
[Tests] Restructure integration tests to table-return shape#7437keithharvey wants to merge 1 commit intobeyond-all-reason:masterfrom
keithharvey wants to merge 1 commit intobeyond-all-reason:masterfrom
Conversation
Restructures the 20 files under luaui/Tests/ and luaui/TestsExamples/
from bare-global hook declarations to a return-table shape, and
updates the dbg_test_runner widget to read test hooks from the table
returned by the chunk.
Motivation: the pre-existing shape required the test files to run
under setfenv(chunk, testEnvironment) and define `function test()`,
`function setup()`, etc. as bare module-level globals that setfenv
redirected into the environment. That works at runtime but emmylua
can't model the sandboxing — it sees 20 files declaring project-wide
globals like `test`, `setup`, `widget`, `unitID`, `initialCameraState`,
etc. To analyze the test files, .emmyrc.json had to blacklist both
test directories under workspace.ignoreDir — a kludge on clearly-ours
code. Lives on its own leaf so the convention change can be discussed
in isolation.
Shape change, per file:
function skip() return ... end ─┐
function setup() ... end │ return {
function test() ... end ├─▶ skip = function() return ... end,
function cleanup() ... end ─┘ setup = function() ... end,
test = function() ... end,
cleanup = function() ... end,
}
Cross-hook shared state (e.g. `widget`, `initialCameraState`, mocks
whose .remove() gets called in cleanup) now declared as file-scope
locals above the return block, so the hook closures capture them
without leaking the names into emmylua's project globals.
Helper functions (runCritterTest, runDistanceTest, test_factory_*,
sanityChecks/failingTests/etc. in selftests) converted from bare
globals to `local function` above the return block — they're only
called from other hooks in the same file.
Runner patch — luaui/Widgets/dbg_test_runner.lua, loadTestFromFile:
- capture the return value of pcall(chunk)
- require it to be a table
- merge its keys into testEnvironment so runTestInternal still reads
bare `skip`/`setup`/`test`/`cleanup` under setfenv(testEnvironment)
Contributor
Integration Test Results16 tests ±0 7 ✅ - 1 3s ⏱️ -1s For more details on these failures, see this check. Results for commit 1b891a9. ± Comparison against base commit 5a1fd3e. |
This was referenced Apr 14, 2026
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of BAR type-error cleanup. Rebuilds idempotently from
masterviajust bar::fmt-mig-generate.Carried-commit leaf. Restructures
luaui/Tests/andluaui/TestsExamples/(20 files) from bare-global hook declarations to areturn { ... }shape, and patchesdbg_test_runner.luato read hooks from the returned table. Isolated so the convention change can be discussed/reverted independently.Branch Topology
All branches in the BAR type-error cleanup stack. Regenerated deterministically by
just bar::fmt-mig-generate. Generated 2026-04-14 18:57:59 UTC.Leaves — each targets
master, mergeable independently:masterstyluabar-lua-codemod bracket-to-dotbar-lua-codemod rename-aliasesbar-lua-codemod detach-bar-modulesbar-lua-codemod i18n-kikitobar-lua-codemod spring-splitbar-lua-codemod integration-testsbar-lua-codemod busted-typesRollups — composite branches stacking the leaves and (for
fmt-llm) the env + LLM layers:mastermig