Repository navigation
test: leave the tests that start processes out of the unit run - #157
Conversation
TST-47. A test that starts a process, reads the real machine or runs a script as a caller would is tagged Integration, and Tests/Invoke-Tests.ps1 -TestType Unit leaves it out; -TestType Integration runs it with the integration suites. The scheduled-task tests of Invoke-IslProcess run on a clock of their own instead of waiting on the real one, and the WhatIf syntax scan reads the module's commands from inside it instead of searching every module for each private one. The unit run takes 69 seconds instead of 157 on a Windows 11 laptop; the build and the ARM job run the tagged tests in a run of their own. Part of #70
fadwen-ai
left a comment
There was a problem hiding this comment.
Moving the tagged tests out of the unit run looks sound: I checked the mocked clock against the polling loop in Invoke-IslProcess, the moved BeforeAll blocks and the discovery-time -Skip flags, and the build and ARM runs that bring the tagged tests back. There are four small findings, all nits:
Tests/Invoke-Tests.ps1:178:-TestType Integration -Tag <X>now also runs unit-folder tests tagged X, because the tag filter is an OR and Integration is added only when no tag is given..github/workflows/quality-gates.yml:228: the second ARM run writes the same job-summary heading (Pester, Unit tests, ...) as the first.CLAUDE.md:171: the pre-push 5.1 command in Checks (-TestType Unit) now skips the process tests, including the 5.1 load test.Tests/Invoke-Tests.ps1:168: no test covers the new way the runner picks Unit and Integration tests.
Out of scope: none
🤖 Generated with Claude Code
… summary, test the selection Pester's tag filter takes a test with any one tag, so -TestType Integration with tags of the caller's own brought unit tests with those tags; with -Tag it keeps to Tests/Integration again. The job summary heading names the tags, so the ARM job's two unit runs can be told apart. Invoke-Tests.Tests.ps1 runs a copy of the runner on a fixture repository for each test type. CLAUDE.md and CONTRIBUTING.md add the tagged run to the 5.1 step before a push.
|
Round 1: 4 fixed, 0 not changed.
🤖 Generated with Claude Code |
fadwen-ai
left a comment
There was a problem hiding this comment.
Re-review of 1b1ddd9 against main: all four round-1 findings are fixed and their threads are resolved.
- With
-Tag,-TestType Integrationkeeps toTests/Integration, and the help says so. - The job-summary heading names the tags, so the second ARM run is labelled
Unit tests tagged Integration. - The 5.1 pre-push blocks in CLAUDE.md and CONTRIBUTING.md run the tagged tests too.
Invoke-Tests.Tests.ps1checks the exact tests that six selections run on a fixture repository. I ran the file at this head on PowerShell 7.6: 7 passed, 0 failed.
I found nothing new in the rest of the diff. The PR description matches the code.
Out of scope: none
🤖 Generated with Claude Code
Summary
Part of #70 (TST-47: the unit tests run in less than 30 seconds). The unit run took 157 seconds on a Windows 11 laptop, and 134 of them went to 28 files whose time came from tests that start processes: child imports of the module, hosts and scheduled tasks launched for real, scripts run as a caller would run them, a child Pester run. Those are integration tests that sit in the unit folders. This tags them, leaves them out of the unit run, and takes the waiting out of the mocked tests that remain. The unit run now takes 69 seconds in one process; the 30-second budget is not reached, and the Notes say what is left.
Changes
Invoke-CallerScriptis taggedIntegrationwhere it is: the child imports and the 5.1 load test ofModule.Contract, the real runs ofModule.WhatIf,Invoke-Tests.Tests.ps1, the process trees ofStop-IslProcessTree, the real child processes ofInvoke-IslProcess,Get-IslDeviceFactand the machine readings ofGet-IslFilterDeviceFactandGet-IslLogonSession, the host comparisons ofGet-IslInboxModuleandGet-IslCoreOnlyFeature, and the calling-script test of seven public commands. The two host comparisons had their host queries in the file'sBeforeAll; they moved into the tagged context, so the unit run does not start the hosts either.Tests/Invoke-Tests.ps1:-TestType Unitleaves the tag out unless-Tag Integrationasks for it;-TestType Integrationruns every test with the tag, inTests/Integrationand in the unit folders, and with-Tagof the caller's own keeps toTests/Integration, since Pester's tag filter takes a test with any one tag;Allis unchanged. The job summary heading names the tags.Tests/Unit/Build/Invoke-Tests.Tests.ps1runs a copy of the runner on a fixture repository for six combinations and checks the exact tests each runs.Invoke-IslProcess.Tests.ps1: the contexts that fake the Task Scheduler mockGet-DateandStart-Sleepwith a clock of their own (TST-31). The polling loop no longer sleeps, and the two tests of a task that never starts check that the module gave up after about five seconds of its clock instead of waiting them out. The file's unit part takes 4.5 seconds instead of 18.Module.WhatIf.Tests.ps1: the syntax-tree scan reads the module's own commands from inside it. From the test's scopeGet-Commandcould not see the 111 private functions it was asked for, and searched every module on the path for each: 9.4 of the test's 10 seconds. It takes 2.3 now and checks the same calls.Build/Invoke-Build.ps1runs the tagged tests after the unit tests, in PowerShell 7 and in Windows PowerShell 5.1, so the build checks what it checked before. The ARM job runs them in a second run; the tests and 5.1 jobs run everything already.CLAUDE.md,CONTRIBUTING.md(both add the tagged run to the 5.1 step before a push) andCHANGELOG.md.Verification
./Tests/Invoke-Tests.ps1 -TestType Uniton PowerShell 7.6: 2,211 passed in 78 seconds through the runner; 69 seconds in one process (Pester's discovery 4.1 s, framework 14.3 s, tests 50.2 s), against 157 before../Build/Invoke-Build.ps1: help and rule reference unchanged, PSScriptAnalyzer clean in 355 files; PowerShell 7.6 unit 2,211 passed and tagged 57 passed; Windows PowerShell 5.1 unit 2,175 passed (37 skipped) and tagged 57 passed; no failures. Before the six selection tests were added, 2,211 + 51 and 2,175 + 51 were the counts of the single runs before this change.Notes
Run.Parallel, which is experimental in 6.2.0 and which the standards allow for a fast-feedback job; that is an owner decision, so Tests reload the module in every file and run longer than the limits (TST-05, TST-47) #70 stays open for it.