@@ -7,12 +7,13 @@ import { describe, it } from 'mocha';
77import { deepEqual , equal , ok } from 'node:assert' ;
88import * as path from 'path' ;
99import { Uri } from 'vscode' ;
10- import { CppProperties } from '../../../../src/LanguageServer/configurations' ;
11- import { extractCompilerPathAndArgs } from '../../../../src/common' ;
10+ import { extractCompilerPathAndArgs , setExtensionPath } from '../../../../src/common' ;
1211import { isWindows } from '../../../../src/constants' ;
12+ import { CppProperties } from '../../../../src/LanguageServer/configurations' ;
1313
1414const assetsFolder = Uri . file ( path . normalize ( path . join ( __dirname . replace ( / d i s t [ \/ \\ ] / , '' ) , '..' , 'assets' ) ) ) ;
1515const assetsFolderFsPath = assetsFolder . fsPath ;
16+ const extensionPath = path . normalize ( path . join ( __dirname . replace ( / d i s t [ \/ \\ ] / , '' ) , '..' , '..' , '..' , '..' ) ) ;
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
174179describe ( '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