Skip to content

Commit 912848e

Browse files
committed
Fix tests for linux/mac
1 parent c6e515a commit 912848e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Extension/test/scenarios/SingleRootProject/tests/compilerPath.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import { describe, it } from 'mocha';
77
import { deepEqual, equal, ok } from 'node:assert';
88
import * as path from 'path';
99
import { Uri } from 'vscode';
10-
import { CppProperties } from '../../../../src/LanguageServer/configurations';
11-
import { extractCompilerPathAndArgs } from '../../../../src/common';
10+
import { extractCompilerPathAndArgs, setExtensionPath } from '../../../../src/common';
1211
import { isWindows } from '../../../../src/constants';
12+
import { CppProperties } from '../../../../src/LanguageServer/configurations';
1313

1414
const assetsFolder = Uri.file(path.normalize(path.join(__dirname.replace(/dist[\/\\]/, ''), '..', 'assets')));
1515
const assetsFolderFsPath = assetsFolder.fsPath;
16+
const extensionPath = path.normalize(path.join(__dirname.replace(/dist[\/\\]/, ''), '..', '..', '..', '..'));
1617

1718
// A simple test counter for the tests that loop over several cases.
1819
// This is to make it easier to see which test failed in the output.
@@ -109,6 +110,10 @@ if (isWindows) {
109110
});
110111
} else {
111112
describe('extractCompilerPathAndArgs', () => {
113+
// The extension is not initialized the same way during tests, so this needs to be set manually
114+
// so the tests can find `cpptools-wordexp`.
115+
setExtensionPath(extensionPath);
116+
112117
// [compilerPath, useLegacyBehavior, additionalArgs, result.compilerName, result.allCompilerArgs]
113118
const tests: [string, boolean, string[] | undefined, string, string[]][] = [
114119
['clang', false, undefined, 'clang', []],
@@ -172,6 +177,12 @@ if (isWindows) {
172177
}
173178

174179
describe('validateCompilerPath', () => {
180+
if (!isWindows) {
181+
// The extension is not initialized the same way during tests, so this needs to be set manually
182+
// so the tests can find `cpptools-wordexp`.
183+
setExtensionPath(extensionPath);
184+
}
185+
175186
// [compilerPath, cwd, result.compilerName, result.allCompilerArgs, result.error, result.telemetry]
176187
const tests: [string, Uri, string, string[]][] = [
177188
['cl.exe', assetsFolder, 'cl.exe', []],

0 commit comments

Comments
 (0)