-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update all extensions to use the same new test methods
- Loading branch information
Jason Rogers
committed
Jun 25, 2021
1 parent
c9f0739
commit cc8a083
Showing
15 changed files
with
2,160 additions
and
96 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 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 |
---|---|---|
@@ -1,23 +1,27 @@ | ||
// | ||
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING | ||
// | ||
// This file is providing the test runner to use when running extension tests. | ||
// By default the test runner in use is Mocha based. | ||
// | ||
// You can provide your own test runner if you want to override it by exporting | ||
// a function run(testRoot: string, clb: (error:Error) => void) that the extension | ||
// host can call to run the tests. The test runner is expected to use console.log | ||
// to report the results back to the caller. When the tests are finished, return | ||
// a possible error to the callback or null if none. | ||
import * as path from "path"; | ||
import * as Mocha from "mocha"; | ||
|
||
import * as testRunner from "vscode/lib/testrunner"; | ||
export function run(): Promise<void> { | ||
const mocha = new Mocha({ | ||
// @ts-ignore: Mocha types are missing `color` | ||
color: true, | ||
ui: "bdd", | ||
timeout: 5000, | ||
}); | ||
|
||
// You can directly control Mocha options by uncommenting the following lines | ||
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info | ||
testRunner.configure({ | ||
ui: "bdd", | ||
useColors: true, // colored output from test results | ||
timeout: 10000 // allow VSCode and server time to start | ||
}); | ||
return new Promise((c, e) => { | ||
mocha.addFile(path.resolve(__dirname, "extension.test.js")); | ||
|
||
module.exports = testRunner; | ||
try { | ||
mocha.run((failures) => { | ||
if (failures > 0) { | ||
e(new Error(`${failures} tests failed.`)); | ||
} else { | ||
c(); | ||
} | ||
}); | ||
} catch (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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as cp from "child_process"; | ||
import * as path from "path"; | ||
import { | ||
downloadAndUnzipVSCode, | ||
runTests, | ||
resolveCliPathFromVSCodeExecutablePath, | ||
} from "vscode-test"; | ||
|
||
async function main() { | ||
try { | ||
const extensionDevelopmentPath = path.resolve(__dirname, "../../"); | ||
const extensionTestsPath = path.resolve(__dirname, "./index"); | ||
const vscodeExecutablePath = await downloadAndUnzipVSCode(); | ||
const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath); | ||
|
||
// Use cp.spawn / cp.exec for custom setup | ||
cp.spawnSync(cliPath, ["--disable-gpu", "--disable-extensions"], { | ||
encoding: "utf-8", | ||
stdio: "inherit", | ||
}); | ||
|
||
// Run the extension test | ||
await runTests({ | ||
// Use the specified `code` executable | ||
vscodeExecutablePath, | ||
// @ts-ignore: vscode-test types aren't right | ||
extensionDevelopmentPath, | ||
extensionTestsPath, | ||
}); | ||
} catch (err) { | ||
console.error("Failed to run tests"); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
Oops, something went wrong.