Skip to content

Commit 1310bd6

Browse files
authored
Enable experiments for all tests (microsoft#22194)
Closes: microsoft#22193 Enables to opt into experiments for tests such as single workspace, multi workspace, debugger, venv, etc.
1 parent ed155af commit 1310bd6

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

src/test/initialize.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export async function initializePython() {
3131

3232
export async function initialize(): Promise<IExtensionTestApi> {
3333
await initializePython();
34+
35+
const pythonConfig = vscode.workspace.getConfiguration('python');
36+
await pythonConfig.update('experiments.optInto', ['All'], vscode.ConfigurationTarget.Global);
37+
await pythonConfig.update('experiments.optOutFrom', [], vscode.ConfigurationTarget.Global);
3438
const api = await activateExtension();
3539
if (!IS_SMOKE_TEST) {
3640
// When running smoke tests, we won't have access to these.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import * as vscode from 'vscode';
2+
import * as path from 'path';
3+
import * as fs from 'fs-extra';
4+
import { assert } from 'chai';
5+
import { EXTENSION_ROOT_DIR_FOR_TESTS, IS_SMOKE_TEST } from '../constants';
6+
import { closeActiveWindows, initialize, initializeTest } from '../initialize';
7+
import { openFile, waitForCondition } from '../common';
8+
9+
suite('Smoke Test: Run Smart Selection and Advance Cursor', () => {
10+
suiteSetup(async function () {
11+
if (!IS_SMOKE_TEST) {
12+
return this.skip();
13+
}
14+
await initialize();
15+
return undefined;
16+
});
17+
18+
setup(initializeTest);
19+
suiteTeardown(closeActiveWindows);
20+
teardown(closeActiveWindows);
21+
22+
test('Smart Send', async () => {
23+
const file = path.join(
24+
EXTENSION_ROOT_DIR_FOR_TESTS,
25+
'src',
26+
'testMultiRootWkspc',
27+
'smokeTests',
28+
'create_delete_file.py',
29+
);
30+
const outputFile = path.join(
31+
EXTENSION_ROOT_DIR_FOR_TESTS,
32+
'src',
33+
'testMultiRootWkspc',
34+
'smokeTests',
35+
'smart_send_smoke.txt',
36+
);
37+
38+
await fs.remove(outputFile);
39+
40+
const textDocument = await openFile(file);
41+
42+
if (vscode.window.activeTextEditor) {
43+
const myPos = new vscode.Position(0, 0);
44+
vscode.window.activeTextEditor!.selections = [new vscode.Selection(myPos, myPos)];
45+
}
46+
await vscode.commands
47+
.executeCommand<void>('python.execSelectionInTerminal', textDocument.uri)
48+
.then(undefined, (err) => {
49+
assert.fail(`Something went wrong running the Python file in the terminal: ${err}`);
50+
});
51+
52+
const checkIfFileHasBeenCreated = () => fs.pathExists(outputFile);
53+
await waitForCondition(checkIfFileHasBeenCreated, 10_000, `"${outputFile}" file not created`);
54+
55+
await vscode.commands
56+
.executeCommand<void>('python.execSelectionInTerminal', textDocument.uri)
57+
.then(undefined, (err) => {
58+
assert.fail(`Something went wrong running the Python file in the terminal: ${err}`);
59+
});
60+
await vscode.commands
61+
.executeCommand<void>('python.execSelectionInTerminal', textDocument.uri)
62+
.then(undefined, (err) => {
63+
assert.fail(`Something went wrong running the Python file in the terminal: ${err}`);
64+
});
65+
66+
async function wait() {
67+
return new Promise<void>((resolve) => {
68+
setTimeout(() => {
69+
resolve();
70+
}, 10000);
71+
});
72+
}
73+
74+
await wait();
75+
76+
const deletedFile = !(await fs.pathExists(outputFile));
77+
if (deletedFile) {
78+
assert.ok(true, `"${outputFile}" file has been deleted`);
79+
} else {
80+
assert.fail(`"${outputFile}" file still exists`);
81+
}
82+
});
83+
});

0 commit comments

Comments
 (0)