Skip to content

Commit 76c577e

Browse files
committed
Merge branch 'bobbrow/devEnvironment' of https://github.com/microsoft/vscode-cpptools into bobbrow/devEnvironment
2 parents facd749 + 8075e84 commit 76c577e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Extension/src/LanguageServer/extension.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { TargetPopulation } from 'vscode-tas-client';
1717
import * as which from 'which';
1818
import { logAndReturn } from '../Utility/Async/returns';
1919
import * as util from '../common';
20-
import { modelSelector } from '../constants';
20+
import { isWindows, modelSelector } from '../constants';
2121
import { instrument } from '../instrumentation';
2222
import { getCrashCallStacksChannel } from '../logger';
2323
import { PlatformInformation } from '../platform';
@@ -1570,6 +1570,9 @@ async function onSetDevEnvironment(sender?: any): Promise<void> {
15701570
void vscode.window.showInformationMessage(`${util.extensionContext?.environmentVariableCollection.description} successfully set.`);
15711571
} catch (error: any) {
15721572
success = false;
1573+
if (!isWindows) {
1574+
throw error;
1575+
}
15731576
void vscode.window.showErrorMessage(`Developer environment not set: ${error.message}`);
15741577
}
15751578
telemetry.logLanguageServerEvent("SetDevEnvironment", { "sender": util.getSenderType(sender), success: success.toString() });

Extension/test/scenarios/SimpleCppProject/tests/devEnvironment.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ suite("set developer environment", () => {
2020
equal(util.hasMsvcEnvironment(), true, "MSVC environment not set correctly.");
2121
});
2222
} else {
23-
test("set developer environment (Linux/macOS)", () => {
23+
test("set developer environment (Linux/macOS)", async () => {
24+
try {
25+
await vscode.commands.executeCommand('C_Cpp.SetDevEnvironment', 'test');
26+
equal(false, true, "Should not be able to set developer environment on non-Windows platform.");
27+
}
28+
catch (e) {
29+
equal((e as Error).message, 'This command is only available on Windows', "Should throw error when trying to set developer environment on non-Windows platform.");
30+
}
31+
equal(util.hasMsvcEnvironment(), false, "MSVC environment should not be set on non-Windows platforms.");
2432
});
2533
}
2634
});

0 commit comments

Comments
 (0)