Skip to content

Commit 2a8c40b

Browse files
committed
test: fix terminal tests on Windows
This fixes two issues with the terminal tests that caused failures on Windows runners: 1. Replaced hardcoded '/' with path.join() for R_PROFILE_USER check. 2. Stubbed util.getRterm to resolve to process.execPath instead of 'R' to ensure the path exists when checked by fs.existsSync().
1 parent 0fafbab commit 2a8c40b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/test/suite/terminal.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ suite('R Terminal', () => {
4242
}
4343
};
4444
sandbox.stub(util, 'config').returns(configStub as unknown as vscode.WorkspaceConfiguration);
45-
sandbox.stub(util, 'getRterm').resolves('R');
45+
sandbox.stub(util, 'getRterm').resolves(process.execPath);
4646
sandbox.stub(util, 'promptToInstallSessPackage').resolves();
4747

4848
const options = await rTerminal.makeTerminalOptions();
@@ -54,7 +54,7 @@ suite('R Terminal', () => {
5454
assert.strictEqual(options.env['SESS_RSTUDIOAPI'], 'TRUE');
5555
assert.strictEqual(options.env['SESS_USE_HTTPGD'], 'TRUE');
5656
assert.ok(options.env['R_PROFILE_USER']);
57-
assert.ok(options.env['R_PROFILE_USER'].endsWith('R/profile.R'));
57+
assert.ok(options.env['R_PROFILE_USER'].endsWith(path.join('R', 'profile.R')));
5858
});
5959

6060
test('makeTerminalOptions does not set session watcher env if disabled', async () => {
@@ -67,7 +67,7 @@ suite('R Terminal', () => {
6767
}
6868
};
6969
sandbox.stub(util, 'config').returns(configStub as unknown as vscode.WorkspaceConfiguration);
70-
sandbox.stub(util, 'getRterm').resolves('R');
70+
sandbox.stub(util, 'getRterm').resolves(process.execPath);
7171
sandbox.stub(util, 'promptToInstallSessPackage').resolves();
7272

7373
const options = await rTerminal.makeTerminalOptions();
@@ -85,7 +85,7 @@ suite('R Terminal', () => {
8585
}
8686
};
8787
sandbox.stub(util, 'config').returns(configStub as unknown as vscode.WorkspaceConfiguration);
88-
sandbox.stub(util, 'getRterm').resolves('R');
88+
sandbox.stub(util, 'getRterm').resolves(process.execPath);
8989
sandbox.stub(util, 'promptToInstallSessPackage').resolves();
9090

9191
// Spy on startSessionWatcher
@@ -126,7 +126,7 @@ suite('R Terminal', () => {
126126
}
127127
};
128128
sandbox.stub(util, 'config').returns(configStub as unknown as vscode.WorkspaceConfiguration);
129-
sandbox.stub(util, 'getRterm').resolves('R');
129+
sandbox.stub(util, 'getRterm').resolves(process.execPath);
130130
sandbox.stub(util, 'promptToInstallSessPackage').resolves();
131131

132132
// We need to mock the terminal and its processId

0 commit comments

Comments
 (0)