Skip to content

Commit 0f15a61

Browse files
committed
Log individual test results when scoring a single local run
1 parent f374018 commit 0f15a61

File tree

4 files changed

+195
-49
lines changed

4 files changed

+195
-49
lines changed

index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ async function add_run (runs_dir, chunks_dir, date) {
6666
await write_compressed(`./${runs_dir}/${date}.xz`, new_run)
6767
}
6868

69-
async function score_single_run (chunks_dir) {
69+
async function score_single_run (chunks_dir, print_filter) {
7070
const run = await process_chunks(chunks_dir)
7171
const test_to_areas = focus_areas_map(run)
7272
const { area_keys } = get_focus_areas()
73-
const score = score_run(run, run, test_to_areas)
73+
const score = score_run(run, run, test_to_areas, print_filter)
7474
const row = [
7575
['revision', run.run_info.revision.substring(0, 9)],
7676
['browser version', run.run_info.browser_version]
@@ -100,7 +100,7 @@ async function recalc_scores (runs_dir) {
100100
console.log(`Reading run ${runs_dir}/${r} (${i}/${run_count})`)
101101
const run = await read_compressed(`./${runs_dir}/${r}`)
102102
console.log(`Calculating score for run ${runs_dir}/${r} (${i}/${run_count})`)
103-
const score = score_run(run, new_run, test_to_areas)
103+
const score = score_run(run, new_run, test_to_areas, () => false)
104104
const row = [
105105
date,
106106
run.run_info.revision.substring(0, 9),
@@ -124,7 +124,12 @@ async function main () {
124124

125125
if (mode === '--score') {
126126
const input_dir = process.argv[3]
127-
const result = await score_single_run(input_dir)
127+
128+
let filterStr = undefined
129+
if (process.argv[4] === '--filter') {
130+
filterStr = process.argv[5]
131+
}
132+
const result = await score_single_run(input_dir, filterStr ? name => name.includes(filterStr) : () => true)
128133
console.log(result)
129134
return
130135
}

package-lock.json

Lines changed: 160 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"mocha": "^10.2.0"
2828
},
2929
"dependencies": {
30+
"chalk": "^5.3.0",
3031
"lzma-native": "^8.0.6"
3132
}
3233
}

process-wpt-results.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assert from 'node:assert/strict'
2+
import chalk from 'chalk';
23

34
function is_object (val) {
45
return (
@@ -179,7 +180,7 @@ export function get_focus_areas () {
179180
return { area_keys, area_names }
180181
}
181182

182-
export function score_run (run, against_run, focus_areas_map) {
183+
export function score_run (run, against_run, focus_areas_map, print_filter) {
183184
const scores = {}
184185
for (const area of Object.keys(FOCUS_AREAS)) {
185186
scores[area] = {
@@ -188,7 +189,10 @@ export function score_run (run, against_run, focus_areas_map) {
188189
}
189190
}
190191

191-
for (const [test, { subtests }] of Object.entries(against_run.test_scores)) {
192+
let testNames = Object.keys(against_run.test_scores);
193+
testNames.sort();
194+
for (const test of testNames) {
195+
const { subtests } = against_run.test_scores[test];
192196
const areas = focus_areas_map[test]
193197

194198
for (const area of areas) {
@@ -205,17 +209,33 @@ export function score_run (run, against_run, focus_areas_map) {
205209
for (const area of areas) {
206210
scores[area].total_score += run_test.score
207211
}
212+
if (print_filter(test)) {
213+
const passes = run_test.score == 1;
214+
if (passes) {
215+
console.log(chalk.green(`PASS ${test}`))
216+
} else {
217+
console.log(chalk.red(`FAIL ${test}`))
218+
}
219+
}
208220
} else {
209-
let test_score = 0
221+
let passed_test_count = 0
210222
for (const subtest of subtest_names) {
211223
if (Object.hasOwn(run_test.subtests, subtest)) {
212-
test_score += run_test.subtests[subtest].score
224+
passed_test_count += run_test.subtests[subtest].score
213225
}
214226
}
215-
test_score /= subtest_names.length
227+
const test_score = passed_test_count / subtest_names.length
216228
for (const area of areas) {
217229
scores[area].total_score += test_score
218230
}
231+
if (print_filter(test)) {
232+
const passes = test_score == 1;
233+
if (passes) {
234+
console.log(chalk.green(`PASS ${test} (${passed_test_count}/${subtest_names.length})`))
235+
} else {
236+
console.log(chalk.red(`FAIL ${test} (${passed_test_count}/${subtest_names.length})`))
237+
}
238+
}
219239
}
220240
}
221241

0 commit comments

Comments
 (0)