Add a cmake refresh task and mark Test Explorer results outdated after refresh/build (#5007) - #5025
Open
Hannia Valera (hanniavalera) wants to merge 5 commits into
Open
Add a cmake refresh task and mark Test Explorer results outdated after refresh/build (#5007)#5025Hannia Valera (hanniavalera) wants to merge 5 commits into
Hannia Valera (hanniavalera) wants to merge 5 commits into
Conversation
Builds and other automation driven through VS Code tasks (for example a build launched from another extension, where the CMake test view is not visible during the build) had no way to refresh the CMake test information afterwards: the 'CMake: Refresh Tests' command does it, but VS Code tasks cannot invoke arbitrary commands, and there was no equivalent 'cmake' task command. Add a 'refresh' command to the 'cmake' task type that runs the same project.refreshTests() path as the 'CMake: Refresh Tests' command (build the default target, then re-read the CTest information and refresh the Test Explorer). It can be chained after a build task via dependsOn. Updates the task command enum in package.json, docs/tasks.md, and the changelog.
…ds (#5007) After 'CMake: Refresh Tests', the refresh task, and a successful build/build-all/clean-rebuild (command or 'type: cmake' build task), previously-run tests are now marked outdated (muted) in the Test Explorer instead of misleadingly appearing current, since rebuilt binaries make earlier results stale. Adds CTestDriver.markTestResultsOutdated(sourceDir), scoped to the project's root TestItem so other projects sharing the singleton controller are untouched. Invalidation is opt-in (default false) so internal builds during an active test run (preTest, per-test/coverage builds, API builds) never retire an in-flight run's results.
1) Internal cmake.buildTask executions (launched by CMakeDriver.build() for preTest/coverage builds during a test run) no longer refresh/invalidate the Test Explorer: CustomBuildTaskTerminal gains an isInternalBuild flag set only at the internal resolveInternalTask construction site, and Hook C is gated on !isInternalBuild. Prevents retiring an in-flight (coverage) run's own results. 2) Clean All now opts out of marking results outdated (buildAll gains a markOutdated param, default true; cleanAll passes false), matching single-project clean. 3) refreshTestsAfterExternalBuild marks results outdated in a finally so a throwing discovery still retires stale results.
resolveInternalTask is only called from CMakeDriver.build() for internal cmake.buildTask executions, but its else branch returned an execution-bearing task unchanged. findBuildTask's ambiguous/no-match fallback returns a provideTask-built task whose terminal defaults to isInternalBuild=false, so an internal build (e.g. a coverage pre/post build during an active test run) could trip Hook C and retire the in-flight run's results. Drop the if (!execution) guard so every returned task uses an internal terminal (isInternalBuild=true) and a real exitCodePromise; user-facing provideTask/resolveTask remain isInternalBuild=false.
A type: cmake, command: build task now refreshes the test information and marks prior results outdated on completion, so chaining a refresh task after it is redundant. Document that the refresh task is for builds that do not go through a cmake task (external/shell builds, or builds driven by another extension).
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.
Addresses #5007.
Comprehensive fix for #5007 ("refresh the test view from a task"), based on maintainer dogfooding of the original refresh-task change.
1.
refreshcommand for thecmaketask typeAdds a
refreshcommand to thecmaketask type that runs the same path as CMake: Refresh Tests (build the default target, then re-read the CTest information and refresh the Test Explorer). It can be chained after a build viadependsOn, and is invokable from automation that drives builds through tasks.2. Mark previously-run test results as outdated (the real dogfooding bug)
Refreshing the tests re-populated the Test Explorer's items but never retired the prior
TestRunresults, so stale pass/fail icons kept looking current after a refresh or rebuild (the code even had a// TODO: There's no way to mark tests as outdated now.). VS Code'sTestController.invalidateTestResults()is the supported way to mark results outdated (they render muted/de-emphasized, signalling "re-run me" — not literally "yellow", and not cleared).This PR adds a project-root-scoped
CTestDriver.markTestResultsOutdated(sourceDir)(never invalidates other projects sharing the singleton controller) and calls it:refreshtask (CMakeProject.refreshTests()),type: cmakebuild task), since rebuilt binaries make prior results stale — this directly cures the "test view not visible during the build" scenario in [Feature] Ability to refresh Build Analyzer from a task #5007 without needing a second task.Fail-safe design
Build-path invalidation is opt-in (
markOutdateddefaultsfalseonCMakeProject.build()), so internal builds that run during an active test run —preTest, per-test target builds, coverage pre/post builds, API/programmatic builds — never retire an in-flight run's own results. The directtype: cmakebuild task uses anisInternalBuildflag so builds that CMake Tools launches internally viacmake.buildTaskare excluded too; only genuine user-invoked builds/tasks invalidate. Clean (single or all) does not invalidate.Validation
tsc,webpack,yarn lint: clean.yarn backendTests: 369 passing.yarn unitTests: 330 passing.cmake.ctest.testExplorerIntegrationEnabledand test mode as before.Manual verification checklist (Test Explorer state isn't assertable via the public API)
type: cmakebuild task with the Testing view closed → open it: tests are rediscovered and prior results are outdated.cmake.buildTaskset, run tests with coverage → the just-finished run stays current (internal pre/post builds don't retire it).Deliberately out of scope (possible follow-up): marking results outdated on every configure.