Skip to content

Commit 1483633

Browse files
committed
Log individual test results when scoring a single local run
1 parent 621c28e commit 1483633

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 (
@@ -189,7 +190,7 @@ export function get_focus_areas () {
189190
return { area_keys, area_names }
190191
}
191192

192-
export function score_run (run, against_run, focus_areas_map) {
193+
export function score_run (run, against_run, focus_areas_map, print_filter) {
193194
const scores = {}
194195
for (const area of Object.keys(FOCUS_AREAS)) {
195196
scores[area] = {
@@ -198,7 +199,10 @@ export function score_run (run, against_run, focus_areas_map) {
198199
}
199200
}
200201

201-
for (const [test, { subtests }] of Object.entries(against_run.test_scores)) {
202+
let testNames = Object.keys(against_run.test_scores);
203+
testNames.sort();
204+
for (const test of testNames) {
205+
const { subtests } = against_run.test_scores[test];
202206
const areas = focus_areas_map[test]
203207

204208
for (const area of areas) {
@@ -215,17 +219,33 @@ export function score_run (run, against_run, focus_areas_map) {
215219
for (const area of areas) {
216220
scores[area].total_score += run_test.score
217221
}
222+
if (print_filter(test)) {
223+
const passes = run_test.score == 1;
224+
if (passes) {
225+
console.log(chalk.green(`PASS ${test}`))
226+
} else {
227+
console.log(chalk.red(`FAIL ${test}`))
228+
}
229+
}
218230
} else {
219-
let test_score = 0
231+
let passed_test_count = 0
220232
for (const subtest of subtest_names) {
221233
if (Object.hasOwn(run_test.subtests, subtest)) {
222-
test_score += run_test.subtests[subtest].score
234+
passed_test_count += run_test.subtests[subtest].score
223235
}
224236
}
225-
test_score /= subtest_names.length
237+
const test_score = passed_test_count / subtest_names.length
226238
for (const area of areas) {
227239
scores[area].total_score += test_score
228240
}
241+
if (print_filter(test)) {
242+
const passes = test_score == 1;
243+
if (passes) {
244+
console.log(chalk.green(`PASS ${test} (${passed_test_count}/${subtest_names.length})`))
245+
} else {
246+
console.log(chalk.red(`FAIL ${test} (${passed_test_count}/${subtest_names.length})`))
247+
}
248+
}
229249
}
230250
}
231251

0 commit comments

Comments
 (0)