@@ -51,9 +51,8 @@ async function process_chunks (path) {
51
51
const scored_chunk = process_raw_results ( chunk_run )
52
52
if ( ! result . run_info ) {
53
53
const raw_run_info = scored_chunk . run_info
54
- const matches = raw_run_info
55
- . browser_version . match ( / ^ S e r v o ( [ 0 - 9 . ] + - [ a - f 0 - 9 ] + ) ? ( - d i r t y ) ? $ / )
56
- const browser_version = matches . length === 3 ? matches [ 1 ] : 'Unknown'
54
+ const matches = raw_run_info ?. browser_version ?. match ( / ^ S e r v o ( [ 0 - 9 . ] + - [ a - f 0 - 9 ] + ) ? ( - d i r t y ) ? $ / )
55
+ const browser_version = matches ?. length === 3 ? matches [ 1 ] : 'Unknown'
57
56
result . run_info = Object . assign ( raw_run_info , { browser_version } )
58
57
}
59
58
delete scored_chunk . run_info
@@ -67,6 +66,23 @@ async function add_run (runs_dir, chunks_dir, date) {
67
66
await write_compressed ( `./${ runs_dir } /${ date } .xz` , new_run )
68
67
}
69
68
69
+ async function score_single_run ( chunks_dir ) {
70
+ const run = await process_chunks ( chunks_dir )
71
+ const test_to_areas = focus_areas_map ( run )
72
+ const { area_keys } = get_focus_areas ( )
73
+ const score = score_run ( run , run , test_to_areas )
74
+ const row = [
75
+ [ 'revision' , run . run_info . revision . substring ( 0 , 9 ) ] ,
76
+ [ 'browser version' , run . run_info . browser_version ]
77
+ ]
78
+
79
+ for ( const area of area_keys ) {
80
+ row . push ( [ area , score [ area ] ] )
81
+ }
82
+
83
+ return row
84
+ }
85
+
70
86
async function recalc_scores ( runs_dir ) {
71
87
console . log ( `Calculating scores for ${ runs_dir } directory...` )
72
88
@@ -102,10 +118,17 @@ async function recalc_scores (runs_dir) {
102
118
103
119
async function main ( ) {
104
120
const mode = process . argv [ 2 ]
105
- if ( ! [ '--add' , '--recalc' ] . includes ( mode ) ) {
121
+ if ( ! [ '--add' , '--recalc' , '--score' ] . includes ( mode ) ) {
106
122
throw new Error ( `invalid mode specified: ${ mode } ` )
107
123
}
108
124
125
+ if ( mode === '--score' ) {
126
+ const input_dir = process . argv [ 3 ]
127
+ const result = await score_single_run ( input_dir )
128
+ console . log ( result )
129
+ return
130
+ }
131
+
109
132
if ( mode === '--add' ) {
110
133
const chunks_2013 = process . argv [ 3 ]
111
134
const chunks_2020 = process . argv [ 4 ]
0 commit comments