You've already forked ada_language_server
mirror of
https://github.com/AdaCore/ada_language_server.git
synced 2026-02-12 12:45:50 -08:00
Improve test infrastructure
* Add a launch configuration to run tests that match a given regexp
This commit is contained in:
@@ -8,6 +8,9 @@ end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.tokens]
|
||||
insert_final_newline = false
|
||||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
|
||||
|
||||
106
.vscode/launch.json
vendored
106
.vscode/launch.json
vendored
@@ -25,9 +25,18 @@
|
||||
// debug instance on the same workspace as the development instance.
|
||||
// So you can checkout a second copy of the ALS repository under
|
||||
// ../als-rt and use it with the following line.
|
||||
"${workspaceFolder}/../als-rt"
|
||||
// "${workspaceFolder}/../als-rt"
|
||||
"${workspaceFolder}/integration/vscode/ada/test/TestWorkspace"
|
||||
],
|
||||
"preLaunchTask": "npm: compile"
|
||||
"preLaunchTask": "npm: compile",
|
||||
"env": {
|
||||
// This is necessary to make the "child" vscode inherit the PATH
|
||||
// variable set in the workspace settings. Without it in some setups
|
||||
// (e.g. vscode remote) the child vscode does not get visibility
|
||||
// over the Ada toolchain available in the parent vscode
|
||||
// environment.
|
||||
"PATH": "${env:PATH}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Extension Tests",
|
||||
@@ -43,30 +52,21 @@
|
||||
"--extensionTestsPath=${workspaceFolder}/integration/vscode/ada/out/test/suite/index",
|
||||
"${workspaceFolder}/integration/vscode/ada/test/TestWorkspace"
|
||||
],
|
||||
// Below we make the executables of node modules visible to the tests.
|
||||
// In particular, vscode-tmgrammar-snap is used for syntax highlighting
|
||||
// tests.
|
||||
"env": {
|
||||
// This is necessary to make the "child" vscode inherit the PATH
|
||||
// variable set in the workspace settings. Without it in some setups
|
||||
// (e.g. vscode remote) the child vscode does not get visibility
|
||||
// over the Ada toolchain available in the parent vscode
|
||||
// environment.
|
||||
"PATH": "${env:PATH}",
|
||||
// This is custom env var that we use in
|
||||
// integration/vscode/ada/test/suite/index.ts to prevent timeouts in
|
||||
// tests when debugging
|
||||
"MOCHA_TIMEOUT": "0"
|
||||
},
|
||||
// Below we make the executables of node modules visible to the tests.
|
||||
// In particular, vscode-tmgrammar-snap is used for syntax highlighting
|
||||
// tests.
|
||||
"windows": {
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder}/integration/vscode/ada/node_modules/.bin;${env:PATH}"
|
||||
}
|
||||
},
|
||||
"osx": {
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder}/integration/vscode/ada/node_modules/.bin:${env:PATH}"
|
||||
}
|
||||
},
|
||||
"linux": {
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder}/integration/vscode/ada/node_modules/.bin:${env:PATH}"
|
||||
}
|
||||
},
|
||||
"preLaunchTask": "npm: pretest"
|
||||
},
|
||||
{
|
||||
@@ -83,7 +83,16 @@
|
||||
"--extensionTestsPath=${workspaceFolder}/integration/vscode/ada/out/test/suite/index",
|
||||
"${workspaceFolder}/integration/vscode/ada/test/TestWorkspace"
|
||||
],
|
||||
// Below we make the executables of node modules visible to the tests.
|
||||
// In particular, vscode-tmgrammar-snap is used for syntax highlighting
|
||||
// tests.
|
||||
"env": {
|
||||
// This is necessary to make the "child" vscode inherit the PATH
|
||||
// variable set in the workspace settings. Without it in some setups
|
||||
// (e.g. vscode remote) the child vscode does not get visibility
|
||||
// over the Ada toolchain available in the parent vscode
|
||||
// environment.
|
||||
"PATH": "${env:PATH}",
|
||||
// This is custom env var that we use in
|
||||
// integration/vscode/ada/test/suite/index.ts to prevent timeouts in
|
||||
// tests when debugging
|
||||
@@ -94,24 +103,6 @@
|
||||
// integration/vscode/ada/test/suite/highlighting.test.ts
|
||||
"MOCHA_ALS_UPDATE": "1"
|
||||
},
|
||||
// Below we make the executables of node modules visible to the tests.
|
||||
// In particular, vscode-tmgrammar-snap is used for syntax highlighting
|
||||
// tests.
|
||||
"windows": {
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder}/integration/vscode/ada/node_modules/.bin;${env:PATH}"
|
||||
}
|
||||
},
|
||||
"osx": {
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder}/integration/vscode/ada/node_modules/.bin:${env:PATH}"
|
||||
}
|
||||
},
|
||||
"linux": {
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder}/integration/vscode/ada/node_modules/.bin:${env:PATH}"
|
||||
}
|
||||
},
|
||||
"preLaunchTask": "npm: pretest"
|
||||
},
|
||||
{
|
||||
@@ -121,6 +112,45 @@
|
||||
"target": ".obj/server/ada_language_server",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"valuesFormatting": "parseText"
|
||||
},
|
||||
{
|
||||
"name": "Extension Tests (Test Name Regexp)",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/integration/vscode/ada/out/**/*.js",
|
||||
"!**/node_modules/**"
|
||||
],
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}/integration/vscode/ada",
|
||||
"--extensionTestsPath=${workspaceFolder}/integration/vscode/ada/out/test/suite/index",
|
||||
"${workspaceFolder}/integration/vscode/ada/test/TestWorkspace"
|
||||
],
|
||||
// Below we make the executables of node modules visible to the tests.
|
||||
// In particular, vscode-tmgrammar-snap is used for syntax highlighting
|
||||
// tests.
|
||||
"env": {
|
||||
"MOCHA_GREP": "${input:testPattern}",
|
||||
// This is necessary to make the "child" vscode inherit the PATH
|
||||
// variable set in the workspace settings. Without it in some setups
|
||||
// (e.g. vscode remote) the child vscode does not get visibility
|
||||
// over the Ada toolchain available in the parent vscode
|
||||
// environment.
|
||||
"PATH": "${env:PATH}",
|
||||
// This is custom env var that we use in
|
||||
// integration/vscode/ada/test/suite/index.ts to prevent timeouts in
|
||||
// tests when debugging
|
||||
"MOCHA_TIMEOUT": "0"
|
||||
},
|
||||
"preLaunchTask": "npm: pretest"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"id": "testPattern",
|
||||
"description": "A regexp of tests to run",
|
||||
"type": "promptString"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
2
.vscode/settings.json.tmpl
vendored
2
.vscode/settings.json.tmpl
vendored
@@ -2,7 +2,7 @@
|
||||
"ada.projectFile": "gnat/lsp_server.gpr",
|
||||
"ada.scenarioVariables": {
|
||||
// Use static linking in local development to enable running the
|
||||
// ada_language_server executable after relaction into the VS Code
|
||||
// ada_language_server executable after relocation into the VS Code
|
||||
// extension.
|
||||
"LIBRARY_TYPE": "static"
|
||||
},
|
||||
|
||||
@@ -4,10 +4,10 @@ project Default is
|
||||
("gnatpp.adb",
|
||||
"test.adb");
|
||||
|
||||
for Source_Dirs use ("src");
|
||||
for Source_Dirs use ("src", "highlighing");
|
||||
for Object_Dir use "obj";
|
||||
for Main use Tools_Mains;
|
||||
|
||||
|
||||
package Builder is
|
||||
for Executable ("gnatpp.adb") use "gnatpp";
|
||||
for Executable ("test.adb") use "gnattest";
|
||||
|
||||
@@ -242,6 +242,7 @@ function testSyntaxHighlighting(absFilePath: string, syntax: Syntaxes) {
|
||||
}
|
||||
|
||||
const cmd = [
|
||||
// Use npx to avoid sensitivity to PATH env var
|
||||
'npx',
|
||||
'vscode-tmgrammar-snap',
|
||||
// We pass a non-existing language configuration, otherwise the tool
|
||||
@@ -263,7 +264,7 @@ function testSyntaxHighlighting(absFilePath: string, syntax: Syntaxes) {
|
||||
cmd.push('--updateSnapshot');
|
||||
}
|
||||
|
||||
const proc = spawnSync(cmd[0], cmd.slice(1));
|
||||
const proc = spawnSync(cmd[0], cmd.slice(1), { cwd: workDirPath });
|
||||
|
||||
if (proc.error) {
|
||||
// proc.error is set if we fail to spawn the child process
|
||||
@@ -278,7 +279,9 @@ function testSyntaxHighlighting(absFilePath: string, syntax: Syntaxes) {
|
||||
assert.fail(msg);
|
||||
} else if (proc.status != 0) {
|
||||
const msg =
|
||||
`Return code ${proc.status.toString()} for command: ${cmd.join(' ')}\n` +
|
||||
`Return code ${proc.status.toString()} for command: cd ${workDirPath}; ${cmd.join(
|
||||
' '
|
||||
)}\n` +
|
||||
String(proc.stdout) +
|
||||
String(proc.stderr);
|
||||
assert.fail(msg);
|
||||
|
||||
@@ -35,6 +35,10 @@ export function run(): Promise<void> {
|
||||
mocha.timeout(env['MOCHA_TIMEOUT']);
|
||||
}
|
||||
|
||||
if (env['MOCHA_GREP']) {
|
||||
mocha.grep(env['MOCHA_GREP']);
|
||||
}
|
||||
|
||||
// Run the mocha test
|
||||
mocha.run((failures) => {
|
||||
if (failures > 0) {
|
||||
|
||||
Reference in New Issue
Block a user