| 288 | } |
| 289 | |
| 290 | public assertOutputContains(category: string | undefined, text: string): Promise<DebugProtocol.OutputEvent> { |
| 291 | let output = ""; |
| 292 | let cleanup = () => { }; |
| 293 | const textLF = text.replace(/\r/g, ""); |
| 294 | const textCRLF = textLF.replace(/\n/g, "\r\n"); |
| 295 | return withTimeout( |
| 296 | new Promise<DebugProtocol.OutputEvent>((resolve) => { |
| 297 | function handleOutput(event: DebugProtocol.OutputEvent) { |
| 298 | if (!category || (event.body.category ?? "console") === category) { |
| 299 | output += event.body.output; |
| 300 | if (output.includes(textLF) || output.includes(textCRLF)) { |
| 301 | resolve(event); |
| 302 | } |
| 303 | } |
| 304 | } |
| 305 | cleanup = () => this.removeListener("output", handleOutput); |
| 306 | this.on("output", handleOutput); |
| 307 | }), |
| 308 | () => `Didn't find text "${text}" in ${category}\nGot: ${output}`, |
| 309 | ).finally(() => cleanup()); |
| 310 | } |
| 311 | |
| 312 | public async debuggerReady(): Promise<void> { |
| 313 | await this.waitForCustomEvent("dart.debuggerUris"); |