forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable experiments for all tests (#22194)
Closes: #22193 Enables to opt into experiments for tests such as single workspace, multi workspace, debugger, venv, etc.
- Loading branch information
1 parent
ed155af
commit 1310bd6
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import * as vscode from 'vscode'; | ||
import * as path from 'path'; | ||
import * as fs from 'fs-extra'; | ||
import { assert } from 'chai'; | ||
import { EXTENSION_ROOT_DIR_FOR_TESTS, IS_SMOKE_TEST } from '../constants'; | ||
import { closeActiveWindows, initialize, initializeTest } from '../initialize'; | ||
import { openFile, waitForCondition } from '../common'; | ||
|
||
suite('Smoke Test: Run Smart Selection and Advance Cursor', () => { | ||
suiteSetup(async function () { | ||
if (!IS_SMOKE_TEST) { | ||
return this.skip(); | ||
} | ||
await initialize(); | ||
return undefined; | ||
}); | ||
|
||
setup(initializeTest); | ||
suiteTeardown(closeActiveWindows); | ||
teardown(closeActiveWindows); | ||
|
||
test('Smart Send', async () => { | ||
const file = path.join( | ||
EXTENSION_ROOT_DIR_FOR_TESTS, | ||
'src', | ||
'testMultiRootWkspc', | ||
'smokeTests', | ||
'create_delete_file.py', | ||
); | ||
const outputFile = path.join( | ||
EXTENSION_ROOT_DIR_FOR_TESTS, | ||
'src', | ||
'testMultiRootWkspc', | ||
'smokeTests', | ||
'smart_send_smoke.txt', | ||
); | ||
|
||
await fs.remove(outputFile); | ||
|
||
const textDocument = await openFile(file); | ||
|
||
if (vscode.window.activeTextEditor) { | ||
const myPos = new vscode.Position(0, 0); | ||
vscode.window.activeTextEditor!.selections = [new vscode.Selection(myPos, myPos)]; | ||
} | ||
await vscode.commands | ||
.executeCommand<void>('python.execSelectionInTerminal', textDocument.uri) | ||
.then(undefined, (err) => { | ||
assert.fail(`Something went wrong running the Python file in the terminal: ${err}`); | ||
}); | ||
|
||
const checkIfFileHasBeenCreated = () => fs.pathExists(outputFile); | ||
await waitForCondition(checkIfFileHasBeenCreated, 10_000, `"${outputFile}" file not created`); | ||
|
||
await vscode.commands | ||
.executeCommand<void>('python.execSelectionInTerminal', textDocument.uri) | ||
.then(undefined, (err) => { | ||
assert.fail(`Something went wrong running the Python file in the terminal: ${err}`); | ||
}); | ||
await vscode.commands | ||
.executeCommand<void>('python.execSelectionInTerminal', textDocument.uri) | ||
.then(undefined, (err) => { | ||
assert.fail(`Something went wrong running the Python file in the terminal: ${err}`); | ||
}); | ||
|
||
async function wait() { | ||
return new Promise<void>((resolve) => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, 10000); | ||
}); | ||
} | ||
|
||
await wait(); | ||
|
||
const deletedFile = !(await fs.pathExists(outputFile)); | ||
if (deletedFile) { | ||
assert.ok(true, `"${outputFile}" file has been deleted`); | ||
} else { | ||
assert.fail(`"${outputFile}" file still exists`); | ||
} | ||
}); | ||
}); |