* 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 when we know out
()
| 144 | * @returns |
| 145 | */ |
| 146 | function activateExtensionScript() { |
| 147 | const ex = new Error('Failed to initialize Python Extension for tests after 3 minutes'); |
| 148 | let timer: NodeJS.Timer | undefined; |
| 149 | const failed = new Promise((_, reject) => { |
| 150 | timer = setTimeout(() => reject(ex), MAX_EXTENSION_ACTIVATION_TIME); |
| 151 | }); |
| 152 | const initializationPromise = initialize(); |
| 153 | const promise = Promise.race([initializationPromise, failed]); |
| 154 | // eslint-disable-next-line no-console |
| 155 | promise.finally(() => clearTimeout(timer! as any)).catch((e) => console.error(e)); |
| 156 | return initializationPromise; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Runner, invoked by VS Code. |
no test coverage detected