* Waits until the Python Extension completes loading or a timeout. * When running tests within VSC, we need to wait for the Python Extension to complete loading, * this is where `initialize` comes in, we load the PVSC extension using VSC API, wait for it * to complete. * That's w
()
| 63 | * @returns |
| 64 | */ |
| 65 | function initializationScript() { |
| 66 | const ex = new Error('Failed to initialize Python Extension for tests after 3 minutes'); |
| 67 | let timer: NodeJS.Timer | undefined; |
| 68 | const failed = new Promise((_, reject) => { |
| 69 | timer = setTimeout(() => reject(ex), MAX_EXTENSION_ACTIVATION_TIME); |
| 70 | }); |
| 71 | const promise = Promise.race([initialize(), failed]); |
| 72 | promise.then(() => clearTimeout(timer! as any)).catch(() => clearTimeout(timer! as any)); |
| 73 | return promise; |
| 74 | } |
| 75 | // Run the tests. |
| 76 | const files = await glob(`**/**.${testFilesGlob}.js`, { ignore: ['**/**.unit.test.js'], cwd: testsRoot }); |
| 77 | files.forEach((file) => mocha.addFile(path.join(testsRoot, file))); |