mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
stop getting logs on test timeout
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
624b7b50ee
commit
401908f4e5
16 files changed
+4152
-37
No files matched your search
@@ -5,13 +5,14 @@ import fse, { writeFile } from "fs-extra";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import { delay } from "../../src/common/utils";
|
||||
import { AbortController } from "abort-controller";
|
||||
|
||||
interface AppTestingPaths {
|
||||
testingPath: string,
|
||||
libraryPath: string,
|
||||
}
|
||||
|
||||
export function getAppTestingPaths(): AppTestingPaths {
|
||||
function getAppTestingPaths(): AppTestingPaths {
|
||||
switch (process.platform) {
|
||||
case "win32":
|
||||
return {
|
||||
@@ -62,7 +63,7 @@ export const keys = {
|
||||
};
|
||||
|
||||
export async function appStart() {
|
||||
const app = setup();
|
||||
const app = new Application(setup());
|
||||
|
||||
await app.start();
|
||||
// Wait for splash screen to be closed
|
||||
@@ -149,15 +150,13 @@ interface LogLines {
|
||||
main: string[];
|
||||
}
|
||||
|
||||
async function* splitLogs(app: Application): AsyncGenerator<LogLines, void, void> {
|
||||
async function* splitLogs(app: Application, signal: AbortController): AsyncGenerator<LogLines, void, void> {
|
||||
let lastLogLineCount = 0;
|
||||
|
||||
for(;;) { // infinite loop
|
||||
while (!signal.signal.aborted) { // infinite loop
|
||||
const curLogs: string[] = (app as any).chromeDriver.getLogs();
|
||||
const newLogs = curLogs.slice(lastLogLineCount);
|
||||
|
||||
console.log(curLogs);
|
||||
|
||||
lastLogLineCount = curLogs.length;
|
||||
|
||||
const item: LogLines = {
|
||||
@@ -176,7 +175,7 @@ async function* splitLogs(app: Application): AsyncGenerator<LogLines, void, void
|
||||
}
|
||||
|
||||
yield item;
|
||||
await delay(500); // only delay after the first attempt
|
||||
await delay(500, signal); // only delay after the first attempt and fail fast if the signal has occured
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,13 +189,13 @@ async function* splitLogs(app: Application): AsyncGenerator<LogLines, void, void
|
||||
* @param source Whether to wait for renderer or main logs
|
||||
* @param values The list of strings that should all be contained in the logs
|
||||
*/
|
||||
export async function waitForLogsToContain(app: Application, matches: LogMatches): Promise<void> {
|
||||
export async function waitForLogsToContain(app: Application, signal: AbortController, matches: LogMatches): Promise<void> {
|
||||
const notYetFound = {
|
||||
main: new Set(matches.main ?? []),
|
||||
renderer: new Set(matches.renderer ?? []),
|
||||
};
|
||||
|
||||
for await (const logs of splitLogs(app)) {
|
||||
for await (const logs of splitLogs(app, signal)) {
|
||||
mainMatch: for (const logPart of notYetFound.main) {
|
||||
for (const logLine of logs.main) {
|
||||
if (logLine.includes(logPart)) {
|
||||
|
||||
Reference in new issue
Block a user