-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP: fix tests * More test fixes * Add glob types * equal -> strictEqual * Remove "Extension Tests From Server" This is already tested. * Add integration tests to CI * Remove test-compile * Remove unnecessary npx * Start xvfb * Export display * Set env var correctly * Pass the workspace * Pass in the src path * Increase sleeps * Base tests off of VS Code samples * Fix path * Install azure-account * Pin azure-pipelines-language-server * Format * More format
- Loading branch information
Showing
16 changed files
with
3,583 additions
and
3,089 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
// From https://github.com/microsoft/vscode-extension-samples/blob/main/lsp-sample/client/src/test/helper.ts | ||
|
||
import * as vscode from 'vscode'; | ||
import * as path from 'path'; | ||
|
||
export let doc: vscode.TextDocument; | ||
export let editor: vscode.TextEditor; | ||
export let documentEol: string; | ||
export let platformEol: string; | ||
|
||
/** | ||
* Activates the vscode.lsp-sample extension | ||
*/ | ||
export async function activate(docUri: vscode.Uri) { | ||
// The extensionId is `publisher.name` from package.json | ||
const ext = vscode.extensions.getExtension('ms-azure-devops.azure-pipelines')!; | ||
await ext.activate(); | ||
try { | ||
doc = await vscode.workspace.openTextDocument(docUri); | ||
editor = await vscode.window.showTextDocument(doc); | ||
await sleep(5000); // Wait for server activation | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
|
||
async function sleep(ms: number) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
|
||
export const getDocPath = (p: string) => { | ||
return path.resolve(__dirname, '../../src/test/workspace', p); | ||
}; | ||
|
||
export const getDocUri = (p: string) => { | ||
return vscode.Uri.file(getDocPath(p)); | ||
}; | ||
|
||
export async function setTestContent(content: string): Promise<boolean> { | ||
const all = new vscode.Range( | ||
doc.positionAt(0), | ||
doc.positionAt(doc.getText().length) | ||
); | ||
return editor.edit(eb => eb.replace(all, content)); | ||
} |
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,39 @@ | ||
import * as path from 'path'; | ||
import * as Mocha from 'mocha'; | ||
import * as glob from 'glob'; | ||
|
||
export function run(): Promise<void> { | ||
// Create the mocha test | ||
const mocha = new Mocha({ | ||
ui: 'tdd', | ||
color: true, | ||
}); | ||
mocha.timeout(100000); | ||
|
||
const testsRoot = __dirname; | ||
|
||
return new Promise((c, e) => { | ||
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { | ||
if (err) { | ||
return e(err); | ||
} | ||
|
||
// Add files to the test suite | ||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); | ||
|
||
try { | ||
// Run the mocha test | ||
mocha.run(failures => { | ||
if (failures > 0) { | ||
e(new Error(`${failures} tests failed.`)); | ||
} else { | ||
c(); | ||
} | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
e(err); | ||
} | ||
}); | ||
}); | ||
} |
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 |
---|---|---|
@@ -1,23 +1,47 @@ | ||
import * as cp from 'child_process'; | ||
import * as path from 'path'; | ||
|
||
import { runTests } from 'vscode-test'; | ||
import { | ||
downloadAndUnzipVSCode, | ||
resolveCliPathFromVSCodeExecutablePath, | ||
runTests | ||
} from '@vscode/test-electron'; | ||
|
||
async function main() { | ||
try { | ||
// The folder containing the Extension Manifest package.json | ||
// Passed to `--extensionDevelopmentPath` | ||
const extensionDevelopmentPath = path.resolve(__dirname, '../../'); | ||
|
||
// The path to the extension test script | ||
// Passed to --extensionTestsPath | ||
const extensionTestsPath = path.resolve(__dirname, './suite/index'); | ||
|
||
// Download VS Code, unzip it and run the integration test | ||
await runTests({ extensionDevelopmentPath, extensionTestsPath }); | ||
} catch (err) { | ||
console.error('Failed to run tests'); | ||
process.exit(1); | ||
} | ||
try { | ||
// The folder containing the Extension Manifest package.json | ||
// Passed to `--extensionDevelopmentPath` | ||
const extensionDevelopmentPath = path.resolve(__dirname, '../../'); | ||
|
||
// The path to the extension test runner script | ||
// Passed to --extensionTestsPath | ||
const extensionTestsPath = path.resolve(__dirname, './index'); | ||
|
||
// If the first argument is a path to a file/folder/workspace, | ||
// the launched VS Code instance will open it. | ||
// workspace isn't copied to out because it's all YAML files. | ||
const launchArgs = [path.resolve(__dirname, '../../src/test/workspace')]; | ||
|
||
const vscodeExecutablePath = await downloadAndUnzipVSCode(); | ||
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath); | ||
|
||
cp.spawnSync(cliPath, ['--install-extension', 'ms-vscode.azure-account'], { | ||
encoding: 'utf-8', | ||
stdio: 'inherit' | ||
}); | ||
|
||
// Download VS Code, unzip it and run the integration test | ||
await runTests({ | ||
vscodeExecutablePath, | ||
extensionDevelopmentPath, | ||
extensionTestsPath, | ||
launchArgs | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
console.error('Failed to run tests'); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); | ||
main(); |
Oops, something went wrong.