-
-
Notifications
You must be signed in to change notification settings - Fork 88
Add integration test setup; check for legacy/new scope duplicates #1428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AndreasArvidsson
merged 5 commits into
main
from
pokey/add-integration-test-setup-check-for-legacynew-scope-duplicates
Jun 17, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c4191dd
Add integration test setup; check for legacy/new scope duplicates
pokey e9dd31d
Merge branch 'main' into pokey/add-integration-test-setup-check-for-l…
pokey 7b07fc2
Update getNodeMatcher.ts
pokey b88b925
Updates
pokey bc8b74a
Show all error messages rather than failing immediately
pokey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import assert = require("assert"); | ||
import { languageMatchers } from "./languages/getNodeMatcher"; | ||
import { TreeSitter } from "./typings/TreeSitter"; | ||
import { legacyLanguageIds } from "./languages/LegacyLanguageId"; | ||
import { LanguageDefinitions } from "./languages/LanguageDefinitions"; | ||
|
||
/** | ||
* Run tests that require multiple components to be instantiated, as well as a | ||
* full context, eg including tree sitter, but that are too closely tied to the | ||
* engine to be defined in cursorless-vscode-e2e | ||
* | ||
* @param treeSitter The tree sitter instance | ||
* @param languageDefinitions The language definitions instance | ||
*/ | ||
export async function runIntegrationTests( | ||
treeSitter: TreeSitter, | ||
languageDefinitions: LanguageDefinitions, | ||
) { | ||
await assertNoScopesBothLegacyAndNew(treeSitter, languageDefinitions); | ||
} | ||
|
||
async function assertNoScopesBothLegacyAndNew( | ||
treeSitter: TreeSitter, | ||
languageDefinitions: LanguageDefinitions, | ||
) { | ||
const errors: string[] = []; | ||
for (const languageId of legacyLanguageIds) { | ||
await treeSitter.loadLanguage(languageId); | ||
|
||
Object.keys(languageMatchers[languageId]).map((scopeTypeType) => { | ||
if ( | ||
languageDefinitions.get(languageId)?.getScopeHandler({ | ||
type: scopeTypeType, | ||
}) != null | ||
) { | ||
errors.push( | ||
`Scope '${scopeTypeType}' defined as both legacy and new for language ${languageId}`, | ||
); | ||
} | ||
}); | ||
} | ||
|
||
assert.deepStrictEqual(errors, []); | ||
} |
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
12 changes: 12 additions & 0 deletions
12
packages/cursorless-vscode-e2e/src/suite/cursorlessEngineIntegration.test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { getCursorlessApi } from "@cursorless/vscode-common"; | ||
import { endToEndTestSetup } from "../endToEndTestSetup"; | ||
|
||
suite("Cursorless engine integration", async function () { | ||
endToEndTestSetup(this); | ||
|
||
test("integration", async () => { | ||
const cursorlessApi = await getCursorlessApi(); | ||
const { runIntegrationTests } = cursorlessApi.testHelpers!; | ||
await runIntegrationTests(); | ||
}); | ||
}); |
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we instead expose
treeSitter
andlanguageDefinitions
, then we could avoidrunIntegrationTests
ending up in the prod bundle, right?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I don't think that would help. The issue is that the test needs to be defined inside cursorless engine; see PR description for more detail. Also notice that treeSitter actually comes from the caller, so exposing it wouldn't actually do anything
We'd need to expose everything imported in the file that defines the integration tests
But maybe I've misunderstood your proposal?