Skip to content

Commit

Permalink
Fix tests part 1 (#1705)
Browse files Browse the repository at this point in the history
* Fix tests

* Requires node 16 or higher

* Hopefully fix test issues on windows

* fix spaces in folder for tests
  • Loading branch information
StephenWeatherford authored Jun 19, 2024
1 parent 822dde9 commit 1810b63
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 282 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/common/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ steps:
- task: NodeTool@0
displayName: "Install node.js"
inputs:
versionSpec: 14.21.3
versionSpec: 18

- script: npm install -g [email protected]
displayName: "Install npm"
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"**/node_modules": true
},
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"files.exclude": {
"**/.git": true,
Expand Down
30 changes: 25 additions & 5 deletions gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

// tslint:disable:no-unsafe-any no-console prefer-template no-implicit-dependencies export-name

import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath } from '@vscode/test-electron';
import * as assert from 'assert';
import * as cp from 'child_process';
import * as fse from 'fs-extra';
Expand All @@ -15,7 +16,6 @@ import * as process from 'process';
import * as recursiveReadDir from 'recursive-readdir';
import * as shelljs from 'shelljs';
import { gulp_webpack } from 'vscode-azureextensiondev';
import { downloadAndUnzipVSCode, resolveCliPathFromVSCodeExecutablePath } from "vscode-test";
import { DEFAULT_TESTCASE_TIMEOUT_MS, langServerDotnetVersion, languageServerFolderName } from './common';
import { getTempFilePath } from './test/support/getTempFilePath';

Expand Down Expand Up @@ -94,23 +94,43 @@ async function test(): Promise<void> {
console.log("");

const vscodeExecutablePath = await downloadAndUnzipVSCode();
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath);
const [cliRawPath, ...cliArguments] =
resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
const cliPath = `"${cliRawPath}"`;

const extensionInstallArguments = [
...cliArguments,
"--install-extension",
"ms-dotnettools.vscode-dotnet-runtime",
];

// Install .NET Install Tool as a dependency.
// Install .NET Install Tool extension as a dependency.
console.log(
`Installing dotnet extension: ${cliPath} ${extensionInstallArguments.join(" ")}`,
);
let result = cp.spawnSync(cliPath, extensionInstallArguments, {
encoding: "utf-8",
stdio: "inherit",
shell: true,
});
if (result.status !== 0) {
throw new Error("Failed to install dotnet runtime extension");
throw new Error("Failed to install dotnet runtime extension: " + result.error ?? result.output?.filter((o) => !!o).join("\n") ?? "Unknown error");
}
console.log("Installed extensions:");
result = cp.spawnSync(cliPath, [
...cliArguments,
"--list-extensions",
], {
encoding: "utf-8",
stdio: "inherit",
shell: true,
});
console.log(result.error ?? result.output?.filter((o) => !!o).join("\n"));
if (result.error) {
process.exit(1);
}

result = cp.spawnSync('node', ['./out/test/runTest.js'], { encoding: "utf-8", stdio: 'inherit', env });
result = cp.spawnSync('node', ['./out/test/runTest.js'], { encoding: "utf-8", stdio: 'inherit', env, shell: true });
if (result.status !== 0) {
throw new Error("Tests failed");
}
Expand Down
Loading

0 comments on commit 1810b63

Please sign in to comment.