Skip to content

Commit e73a9fa

Browse files
committed
detect xania glitch
1 parent 5ff1d9d commit e73a9fa

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

webdriver-ts/src/benchmarkRunner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ async function runBenchmakLoop(
135135
let res = await forkAndCallBenchmark(framework, benchmarkInfo, benchmarkOptions);
136136
if (Array.isArray(res.result)) {
137137
results = results.concat(res.result as number[]|CPUBenchmarkResult[]);
138-
} else results.push(res.result);
138+
} else if (res.result !==undefined) {
139+
results.push(res.result);
140+
}
139141
warnings = warnings.concat(res.warnings);
140142
if (res.error) {
141143
if (res.error.indexOf("Server terminated early with status 1") > -1) {

webdriver-ts/src/benchmarksPlaywright.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Browser, Page } from "playwright-core";
44
import * as benchmarksCommon from "./benchmarksCommon.js";
55
import { BenchmarkType } from "./benchmarksCommon.js";
66
import { BenchmarkOptions, config, FrameworkData } from "./common.js";
7-
import { checkElementContainsText, checkElementExists, checkElementHasClass, checkElementNotExists, clickElement } from "./playwrightAccess.js";
7+
import { checkCountForSelector, checkElementContainsText, checkElementExists, checkElementHasClass, checkElementNotExists, clickElement } from "./playwrightAccess.js";
88

99

1010
export abstract class CPUBenchmarkPlaywright implements benchmarksCommon.BenchmarkImpl {
@@ -91,6 +91,7 @@ export const benchSelect = new class extends CPUBenchmarkPlaywright {
9191
for (let i = 0; i <= config.WARMUP_COUNT; i++) {
9292
await clickElement(page, `tbody>tr:nth-of-type(${i+5})>td:nth-of-type(2)>a`);
9393
await checkElementHasClass(page, `tbody>tr:nth-of-type(${i+5})`, "danger");
94+
await checkCountForSelector(page, "tbody>tr.danger", 1);
9495
}
9596
}
9697
async run(browser: Browser,page: Page) {

webdriver-ts/src/benchmarksPuppeteer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Page } from "puppeteer-core";
44
import * as benchmarksCommon from "./benchmarksCommon.js";
55
import { BenchmarkType } from "./benchmarksCommon.js";
66
import { BenchmarkOptions, config, FrameworkData } from "./common.js";
7-
import { checkElementContainsText, checkElementExists, checkElementHasClass, checkElementNotExists, clickElement } from "./puppeteerAccess.js";
7+
import { checkCountForSelector, checkElementContainsText, checkElementExists, checkElementHasClass, checkElementNotExists, clickElement } from "./puppeteerAccess.js";
88

99

1010
export abstract class CPUBenchmarkPuppeteer implements benchmarksCommon.BenchmarkImpl {
@@ -92,6 +92,7 @@ export const benchSelect = new class extends CPUBenchmarkPuppeteer {
9292
for (let i = 0; i <= config.WARMUP_COUNT; i++) {
9393
await clickElement(page, `pierce/tbody>tr:nth-of-type(${i+5})>td:nth-of-type(2)>a`);
9494
await checkElementHasClass(page, `pierce/tbody>tr:nth-of-type(${i+5})`, "danger");
95+
await checkCountForSelector(page, "pierce/tbody>tr.danger", 1);
9596
}
9697
}
9798
async run(page: Page) {

webdriver-ts/src/forkedBenchmarkRunnerPuppeteer.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ async function runCPUBenchmark(framework: FrameworkData, benchmark: CPUBenchmark
8585
// uploadThroughput: 330 * 1024 / 8, // 330 kb/s
8686
// });
8787
console.log("initBenchmark");
88-
try {
89-
await initBenchmark(page, benchmark, framework);
90-
} catch (ex) {
91-
console.log("**** initBenchmark failed, retrying");
92-
await initBenchmark(page, benchmark, framework);
93-
}
88+
await initBenchmark(page, benchmark, framework);
9489

9590
let categories = [
9691
"blink.user_timing",

webdriver-ts/src/playwrightAccess.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ export async function checkElementHasClass(page: Page, selector: string, classNa
7979
throw `checkElementHasClass ${selector} failed. expected ${className}, but was ${clazzes}`;
8080
}
8181

82+
export async function checkCountForSelector(page: Page, selector: string, expectedCount: number): Promise<void> {
83+
let elems = await page.$$(selector);
84+
if (elems) {
85+
if (expectedCount!==elems.length) {
86+
throw `checkCountForSelector ${selector} failed. expected ${expectedCount}, but ${elems.length} were found`;
87+
}
88+
} else {
89+
if (expectedCount!==0) {
90+
throw `checkCountForSelector ${selector} failed. expected ${expectedCount}, but selector was not found`;
91+
}
92+
}
93+
}
94+
8295
function browserPath(benchmarkOptions: BenchmarkOptions) {
8396
if (benchmarkOptions.chromeBinaryPath) return benchmarkOptions.chromeBinaryPath;
8497
if (process.platform == "darwin") {

webdriver-ts/src/puppeteerAccess.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ export async function checkElementHasClass(page: Page, selector: string, classNa
7979
throw `checkElementHasClass ${selector} failed. expected ${className}, but was ${clazzes}`;
8080
}
8181

82+
export async function checkCountForSelector(page: Page, selector: string, expectedCount: number): Promise<void> {
83+
let elems = await page.$$(selector);
84+
if (elems) {
85+
if (expectedCount!==elems.length) {
86+
throw `checkCountForSelector ${selector} failed. expected ${expectedCount}, but ${elems.length} were found`;
87+
}
88+
} else {
89+
if (expectedCount!==0) {
90+
throw `checkCountForSelector ${selector} failed. expected ${expectedCount}, but selector was not found`;
91+
}
92+
}
93+
}
94+
8295
function browserPath(benchmarkOptions: BenchmarkOptions) {
8396
if (benchmarkOptions.chromeBinaryPath) return benchmarkOptions.chromeBinaryPath;
8497
if (process.platform == "darwin") {

0 commit comments

Comments
 (0)