Add first set of extension tests - #503
Merged
Merged
Conversation
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.
This PR adds the first automated test suite for the extension
ggsql-vscode, plus a GitHub Actions workflow to run it. It has 20 tests across four files, 27 TextMate scope assertions, and aTestingsection inggsql-vscode/CLAUDE.md.The tests depend on one of the fixes from #502 FYI.
The extension as stock VS Code sees it:
parseCellscell splitting.sqlattachment gating (isGgsqlDocument)This does not include anything that needs a Positron host (the language runtime manager, the Connections pane drivers, and cell execution. Also
sqlAssociation.ts,manager.tsandconnections.ts). I'll add that in a second step after our next release, when we'll have Linux builds for test runners.I checked every test by breaking the code it covers and confirming it goes red, not just by watching the suite go green. A whole-suite scrutiny pass then re-ran independent mutations across all 20. IMO that kind of thing is worth doing, especially with AI-generated code and tests, which can be really low value sometimes.
Findings about the extension itself
Two things surfaced that are not test problems:
cellParser.tsclaimed a marker-free document is treated as one cell. It is not;parseCellsreturns no cells at all, and the whole-document fallback lives inextension.ts. Comment corrected in its own commit.sqlFilesEnabled()'struefallback argument is unreachable.package.jsonalready declares a default forggsql.enableSqlFiles, and VS Code resolves.get()against the registered schema default first. Documented in place for now, no behaviour change.Test infrastructure
Two runners behind
npm test:@vscode/test-clidrives a real VS Code instance for anything needing thevscodeAPI. CI wraps it inxvfb-run.vscode-tmgrammar-testchecks TextMate scopes in plain Node, sonpm run test:grammaris a roughly one second loop with no Electron.Tests compile to
out-test/via a dedicatedtsconfig.test.json, deliberately not toout/, whichesbuild.jsowns. Emitting both toout/would have meant the test build overwriting the extension bundle.The Mocha timeout is set to 5s, matching what I have found works well for the Quarto extension's suite.
npm run lint,npm run check-typesandnpm testare clean, with 20 passing plus the grammar fixture. A cleanrm -rf node_modules && npm ci && npm testalso passes, which is the closest local approximation of the CI run.