Skip to content

Commit 017f8a2

Browse files
authored
Consistent naming: use step instead of test (#537)
We use step and test interchangeably which is rathe confusing. This PR changes the runner code to use step eclusively.
1 parent a1f4c0b commit 017f8a2

6 files changed

Lines changed: 46 additions & 46 deletions

File tree

experimental/javascript-wc-indexeddb/scripts/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const filesToMove = [
9898
{ src: "node_modules/todomvc-css/dist/todo-item.constructable.js", dest: "./dist/styles/todo-item.constructable.js" },
9999
{ src: "node_modules/dexie/dist/modern/dexie.mjs", dest: "./dist/libs/dexie.mjs" },
100100
{ src: "node_modules/speedometer-utils/test-invoker.mjs", dest: "./dist/src/speedometer-utils/test-invoker.mjs" },
101-
{ src: "node_modules/speedometer-utils/test-runner.mjs", dest: "./dist/src/speedometer-utils/test-runner.mjs" },
101+
{ src: "node_modules/speedometer-utils/step-runner.mjs", dest: "./dist/src/speedometer-utils/step-runner.mjs" },
102102
{ src: "node_modules/speedometer-utils/params.mjs", dest: "./dist/src/speedometer-utils/params.mjs" },
103103
{ src: "src/speedometer-utils/benchmark.mjs", dest: "./dist/src/speedometer-utils/benchmark.mjs" },
104104
{ src: "node_modules/speedometer-utils/helpers.mjs", dest: "./dist/src/speedometer-utils/helpers.mjs" },

resources/shared/benchmark.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-case-declarations */
2-
import { TestRunner } from "./test-runner.mjs";
2+
import { StepRunner } from "./step-runner.mjs";
33
import { Params } from "./params.mjs";
44

55
/**
@@ -13,9 +13,9 @@ export class BenchmarkStep {
1313
this.run = run;
1414
}
1515

16-
async runAndRecordStep(params, suite, test, callback) {
17-
const testRunner = new TestRunner(null, null, params, suite, test, callback);
18-
const result = await testRunner.runTest();
16+
async runAndRecordStep(params, suite, step, callback) {
17+
const stepRunner = new StepRunner(null, null, params, suite, step, callback);
18+
const result = await stepRunner.runStep();
1919
return result;
2020
}
2121
}
@@ -31,7 +31,7 @@ export class BenchmarkSuite {
3131
this.steps = steps;
3232
}
3333

34-
record(_test, syncTime, asyncTime) {
34+
record(_step, syncTime, asyncTime) {
3535
const total = syncTime + asyncTime;
3636
const results = {
3737
tests: { Sync: syncTime, Async: asyncTime },
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { TEST_INVOKER_LOOKUP } from "./test-invoker.mjs";
22
import { forceLayout } from "./helpers.mjs";
33

4-
export class TestRunner {
4+
export class StepRunner {
55
#frame;
66
#page;
77
#params;
88
#suite;
9-
#test;
9+
#step;
1010
#callback;
1111
#type;
1212

13-
constructor(frame, page, params, suite, test, callback, type) {
13+
constructor(frame, page, params, suite, step, callback, type) {
1414
this.#suite = suite;
15-
this.#test = test;
15+
this.#step = step;
1616
this.#params = params;
1717
this.#callback = callback;
1818
this.#page = page;
@@ -24,21 +24,21 @@ export class TestRunner {
2424
return this.#page;
2525
}
2626

27-
get test() {
28-
return this.#test;
27+
get step() {
28+
return this.#step;
2929
}
3030

31-
_runSyncStep(test, page) {
32-
test.run(page);
31+
_runSyncStep(step, page) {
32+
step.run(page);
3333
}
3434

35-
async runTest() {
35+
async runStep() {
3636
// Prepare all mark labels outside the measuring loop.
3737
const suiteName = this.#suite.name;
38-
const testName = this.#test.name;
39-
const syncStartLabel = `${suiteName}.${testName}-start`;
40-
const syncEndLabel = `${suiteName}.${testName}-sync-end`;
41-
const asyncEndLabel = `${suiteName}.${testName}-async-end`;
38+
const stepName = this.#step.name;
39+
const syncStartLabel = `${suiteName}.${stepName}-start`;
40+
const syncEndLabel = `${suiteName}.${stepName}-sync-end`;
41+
const asyncEndLabel = `${suiteName}.${stepName}-async-end`;
4242

4343
let syncTime;
4444
let asyncStartTime;
@@ -57,9 +57,9 @@ export class TestRunner {
5757
const syncStartTime = performance.now();
5858

5959
if (this.#type === "async")
60-
await this._runSyncStep(this.test, this.page);
60+
await this._runSyncStep(this.step, this.page);
6161
else
62-
this._runSyncStep(this.test, this.page);
62+
this._runSyncStep(this.step, this.page);
6363

6464
const mark = performance.mark(syncEndLabel);
6565
const syncEndTime = mark.startTime;
@@ -85,11 +85,11 @@ export class TestRunner {
8585

8686
if (this.#params.warmupBeforeSync)
8787
performance.measure("warmup", "warmup-start", "warmup-end");
88-
performance.measure(`${suiteName}.${testName}-sync`, syncStartLabel, syncEndLabel);
89-
performance.measure(`${suiteName}.${testName}-async`, syncEndLabel, asyncEndLabel);
88+
performance.measure(`${suiteName}.${stepName}-sync`, syncStartLabel, syncEndLabel);
89+
performance.measure(`${suiteName}.${stepName}-async`, syncEndLabel, asyncEndLabel);
9090
};
9191

92-
const report = () => this.#callback(this.#test, syncTime, asyncTime);
92+
const report = () => this.#callback(this.#step, syncTime, asyncTime);
9393
const invokerType = this.#suite.type === "async" || this.#params.useAsyncSteps ? "async" : this.#params.measurementMethod;
9494
const invokerClass = TEST_INVOKER_LOOKUP[invokerType];
9595
const invoker = new invokerClass(runSync, measureAsync, report, this.#params);
@@ -98,19 +98,19 @@ export class TestRunner {
9898
}
9999
}
100100

101-
export class AsyncTestRunner extends TestRunner {
102-
constructor(frame, page, params, suite, test, callback, type) {
103-
super(frame, page, params, suite, test, callback, type);
101+
export class AsyncStepRunner extends StepRunner {
102+
constructor(frame, page, params, suite, step, callback, type) {
103+
super(frame, page, params, suite, step, callback, type);
104104
}
105105

106-
async _runSyncStep(test, page) {
107-
await test.run(page);
106+
async _runSyncStep(step, page) {
107+
await step.run(page);
108108
}
109109
}
110110

111-
export const TEST_RUNNER_LOOKUP = {
111+
export const STEP_RUNNER_LOOKUP = {
112112
__proto__: null,
113-
default: TestRunner,
114-
async: AsyncTestRunner,
115-
remote: TestRunner,
113+
default: StepRunner,
114+
async: AsyncStepRunner,
115+
remote: StepRunner,
116116
};

resources/suite-runner.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TEST_RUNNER_LOOKUP } from "./shared/test-runner.mjs";
1+
import { STEP_RUNNER_LOOKUP } from "./shared/step-runner.mjs";
22
import { WarmupSuite } from "./benchmark-runner.mjs";
33

44
export class SuiteRunner {
@@ -73,14 +73,14 @@ export class SuiteRunner {
7373
const suiteEndLabel = `suite-${suiteName}-end`;
7474

7575
performance.mark(suiteStartLabel);
76-
for (const test of this.#suite.tests) {
76+
for (const step of this.#suite.tests) {
7777
if (this.#client?.willRunTest)
78-
await this.#client.willRunTest(this.#suite, test);
78+
await this.#client.willRunTest(this.#suite, step);
7979

80-
const testRunnerType = this.#suite.type ?? this.params.useAsyncSteps ? "async" : "default";
81-
const testRunnerClass = TEST_RUNNER_LOOKUP[testRunnerType];
82-
const testRunner = new testRunnerClass(this.#frame, this.#page, this.#params, this.#suite, test, this._recordTestResults, testRunnerType);
83-
await testRunner.runTest();
80+
const stepRunnerType = this.#suite.type ?? this.params.useAsyncSteps ? "async" : "default";
81+
const stepRunnerClass = STEP_RUNNER_LOOKUP[stepRunnerType];
82+
const stepRunner = new stepRunnerClass(this.#frame, this.#page, this.#params, this.#suite, step, this._recordTestResults, stepRunnerType);
83+
await stepRunner.runStep();
8484
}
8585
performance.mark(suiteEndLabel);
8686

@@ -110,13 +110,13 @@ export class SuiteRunner {
110110
});
111111
}
112112

113-
_recordTestResults = async (test, syncTime, asyncTime) => {
113+
_recordTestResults = async (step, syncTime, asyncTime) => {
114114
// Skip reporting updates for the warmup suite.
115115
if (this.#suite === WarmupSuite)
116116
return;
117117

118118
let total = syncTime + asyncTime;
119-
this.#suiteResults.tests[test.name] = {
119+
this.#suiteResults.tests[step.name] = {
120120
tests: { Sync: syncTime, Async: asyncTime },
121121
total: total,
122122
};

resources/todomvc/vanilla-examples/javascript-web-components/scripts/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const filesToMove = [
9797
{ src: "node_modules/todomvc-css/dist/todo-list.constructable.js", dest: "./dist/styles/todo-list.constructable.js" },
9898
{ src: "node_modules/todomvc-css/dist/todo-item.constructable.js", dest: "./dist/styles/todo-item.constructable.js" },
9999
{ src: "node_modules/speedometer-utils/test-invoker.mjs", dest: "./dist/src/speedometer-utils/test-invoker.mjs" },
100-
{ src: "node_modules/speedometer-utils/test-runner.mjs", dest: "./dist/src/speedometer-utils/test-runner.mjs" },
100+
{ src: "node_modules/speedometer-utils/step-runner.mjs", dest: "./dist/src/speedometer-utils/step-runner.mjs" },
101101
{ src: "node_modules/speedometer-utils/params.mjs", dest: "./dist/src/speedometer-utils/params.mjs" },
102102
{ src: "node_modules/speedometer-utils/benchmark.mjs", dest: "./dist/src/speedometer-utils/benchmark.mjs" },
103103
{ src: "node_modules/speedometer-utils/helpers.mjs", dest: "./dist/src/speedometer-utils//helpers.mjs" },

tests/unittests/benchmark-runner.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BenchmarkRunner } from "../../resources/benchmark-runner.mjs";
22
import { SuiteRunner } from "../../resources/suite-runner.mjs";
3-
import { TestRunner } from "../../resources/shared/test-runner.mjs";
3+
import { StepRunner } from "../../resources/shared/step-runner.mjs";
44
import { defaultParams } from "../../resources/shared/params.mjs";
55

66
function TEST_FIXTURE(name) {
@@ -147,7 +147,7 @@ describe("BenchmarkRunner", () => {
147147
before(async () => {
148148
_prepareSuiteSpy = spy(SuiteRunner.prototype, "_prepareSuite");
149149
_loadFrameStub = stub(SuiteRunner.prototype, "_loadFrame").callsFake(async () => null);
150-
_runTestStub = stub(TestRunner.prototype, "runTest").callsFake(async () => null);
150+
_runTestStub = stub(StepRunner.prototype, "runStep").callsFake(async () => null);
151151
_validateSuiteResultsStub = stub(SuiteRunner.prototype, "_validateSuiteResults").callsFake(async () => null);
152152
performanceMarkSpy = spy(window.performance, "mark");
153153
_suitePrepareSpy = spy(suite, "prepare");
@@ -200,7 +200,7 @@ describe("BenchmarkRunner", () => {
200200

201201
// SuiteRunner adds 2 marks.
202202
// Suite used here contains 3 tests.
203-
// Each TestRunner adds 3 marks.
203+
// Each StepRunner adds 3 marks.
204204
expect(performanceMarkSpy.callCount).to.equal(11);
205205
});
206206
});

0 commit comments

Comments
 (0)