Skip to content

Commit c41345e

Browse files
mscdexphillipj
authored andcommitted
labels: more specific benchmark, test, and tools labels (nodejs#131)
1 parent 83ad95c commit c41345e

2 files changed

Lines changed: 166 additions & 38 deletions

File tree

‎lib/node-labels.js‎

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const subSystemLabelsMap = new Map([
3535

3636
// properly label changes to v8 inspector integration-related files
3737
[/^src\/inspector_/, ['c++', 'v8_inspector', 'dont-land-on-v4.x']],
38+
[/^test\/(?:cctest|inspector)\//, ['test', 'v8_inspector',
39+
'dont-land-on-v4.x']],
3840
// don't want to label it a c++ update when we're "only" bumping the Node.js version
3941
[/^src\/(?!node_version\.h)/, 'c++'],
4042
// BUILDING.md should be marked as 'build' in addition to 'doc'
@@ -46,9 +48,23 @@ const subSystemLabelsMap = new Map([
4648
// different variants of *Makefile and build files
4749
[/^(tools\/)?(Makefile|BSDmakefile|create_android_makefiles)$/, 'build'],
4850
[/^tools\/(install\.py|genv8constants\.py|getnodeversion\.py|js2c\.py|utils\.py|configure\.d\/.*)$/, 'build'],
49-
[/^(configure|node\.gyp|common\.gypi|vcbuild\.bat)$/, 'build'],
50-
// all other tools/ changes should be marked as such
51+
[/^vcbuild\.bat$/, ['build', 'windows']],
52+
[/^configure|node\.gyp|common\.gypi$/, 'build'],
53+
// more specific tools
54+
[/^tools\/gyp/, ['tools', 'build']],
55+
[/^tools\/doc\//, ['tools', 'doc']],
56+
[/^tools\/icu\//, ['tools', 'intl']],
57+
[/^tools\/(?:osx-pkg\.pmdoc|pkgsrc)\//, ['tools', 'macos', 'install']],
58+
[/^tools\/(?:(?:mac)?osx-)/, ['tools', 'macos']],
59+
[/^tools\/test-npm/, ['tools', 'test', 'npm']],
60+
[/^tools\/test/, ['tools', 'test']],
61+
[/^tools\/(?:certdata|mkssldef|mk-ca-bundle)/, ['tools', 'openssl', 'tls']],
62+
[/^tools\/msvs\//, ['tools', 'windows', 'install']],
63+
[/^tools\/[^/]+\.bat$/, ['tools', 'windows']],
64+
[/^tools\/make-v8/, ['tools', 'V8']],
65+
// all other tool changes should be marked as such
5166
[/^tools\//, 'tools'],
67+
[/^\.eslint|\.remark|\.editorconfig/, 'tools'],
5268

5369
/* Dependencies */
5470
// libuv needs an explicit mapping, as the ordinary /deps/ mapping below would
@@ -82,12 +98,30 @@ const jsSubsystemList = [
8298
]
8399

84100
const exclusiveLabelsMap = new Map([
101+
// more specific tests
102+
[/^test\/addons\//, ['test', 'addons']],
103+
[/^test\/debugger\//, ['test', 'debugger']],
104+
[/^test\/doctool\//, ['test', 'doc', 'tools']],
105+
[/^test\/timers\//, ['test', 'timers']],
106+
[/^test\/pseudo-tty\//, ['test', 'tty']],
107+
85108
[/^test\//, 'test'],
109+
86110
// specific map for modules.md as it should be labeled 'module' not 'modules'
87111
[/^doc\/api\/modules.md$/, ['doc', 'module']],
88112
// automatically tag subsystem-specific API doc changes
89113
[/^doc\/api\/(\w+)\.md$/, ['doc', '$1']],
114+
90115
[/^doc\//, 'doc'],
116+
117+
// more specific benchmarks
118+
[/^benchmark\/buffers\//, ['benchmark', 'buffer']],
119+
[/^benchmark\/(?:arrays|es)\//, ['benchmark', 'V8']],
120+
[/^benchmark\/_http/, ['benchmark', 'http']],
121+
[/^benchmark\/(?:misc|fixtures)\//, 'benchmark'],
122+
[/^benchmark\/streams\//, ['benchmark', 'stream']],
123+
[/^benchmark\/([^/]+)\//, ['benchmark', '$1']],
124+
91125
[/^benchmark\//, 'benchmark']
92126
])
93127

@@ -129,14 +163,21 @@ function hasAllDocChanges (arr) {
129163
})
130164
}
131165

166+
function hasAllTestChanges (arr) {
167+
return arr.every((val) => {
168+
return /^test\//.test(val)
169+
})
170+
}
171+
132172
function matchExclusiveSubSystem (filepathsChanged) {
133173
const isExclusive = filepathsChanged.every(matchesAnExclusiveLabel)
134174
var labels = matchSubSystemsByRegex(exclusiveLabelsMap, filepathsChanged)
135175

136176
// if there are multiple API doc changes, do not apply subsystem tags for now
137177
if (isExclusive &&
138178
labels.includes('doc') &&
139-
labels.length > 2) {
179+
labels.length > 2 &&
180+
!hasAllTestChanges(filepathsChanged)) {
140181
const nonDocLabels = labels.filter((val) => {
141182
return val !== 'doc'
142183
})

‎test/unit/node-labels.test.js‎

Lines changed: 122 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@ const tap = require('tap')
44

55
const nodeLabels = require('../../lib/node-labels')
66

7-
tap.test('label: "test" when only ./test/ files has been changed', (t) => {
8-
const labels = nodeLabels.resolveLabels([
9-
'test/debugger/test-debugger-pid.js',
10-
'test/debugger/test-debugger-repl-break-in-module.js',
11-
'test/debugger/test-debugger-repl-term.js'
12-
])
13-
14-
t.same(labels, ['test'])
15-
16-
t.end()
17-
})
18-
197
tap.test('no labels: when ./test/ and ./doc/ files has been changed', (t) => {
208
const labels = nodeLabels.resolveLabels([
219
'test/debugger/test-debugger-pid.js',
@@ -53,17 +41,6 @@ tap.test('label: "doc" when only ./doc/ files has been changed', (t) => {
5341
t.end()
5442
})
5543

56-
tap.test('label: "benchmark" when only ./benchmark/ files has been changed', (t) => {
57-
const labels = nodeLabels.resolveLabels([
58-
'benchmark/http_server_lag.js',
59-
'benchmark/http/check_is_http_token.js'
60-
])
61-
62-
t.same(labels, ['benchmark'])
63-
64-
t.end()
65-
})
66-
6744
tap.test('label: "c++" when ./src/* has been changed', (t) => {
6845
const labels = nodeLabels.resolveLabels([
6946
'src/node.cc'
@@ -148,7 +125,7 @@ const srcCases = [
148125
[ 'zlib', ['node_zlib.cc'] ]
149126
]
150127
for (const info of srcCases) {
151-
var labels = info[0]
128+
let labels = info[0]
152129
if (!Array.isArray(labels)) {
153130
labels = [labels]
154131
}
@@ -399,22 +376,12 @@ tap.test('label: no version labels (master)', (t) => {
399376
t.end()
400377
})
401378

402-
tap.test('label: tools label', (t) => {
403-
const labels = nodeLabels.resolveLabels([
404-
'tools/doc/json.js'
405-
])
406-
407-
t.same(labels, ['tools'])
408-
409-
t.end()
410-
})
411-
412379
tap.test('label: build label (windows)', (t) => {
413380
const labels = nodeLabels.resolveLabels([
414381
'vcbuild.bat'
415382
])
416383

417-
t.same(labels, ['build'])
384+
t.same(labels, ['build', 'windows'])
418385

419386
t.end()
420387
})
@@ -439,3 +406,123 @@ tap.test('label: doc label for non-subsystem API doc changes', (t) => {
439406

440407
t.end()
441408
})
409+
410+
const specificBenchmarks = [
411+
[ [], ['fixtures/alice.html', 'misc/freelist.js'] ],
412+
[ 'assert', ['assert/deepequal-buffer.js'] ],
413+
[ 'buffer', ['buffers/buffer-base64-decode.js'] ],
414+
[ 'child_process', ['child_process/child-process-exec-stdout.js'] ],
415+
[ 'crypto', ['crypto/aes-gcm-throughput.js'] ],
416+
[ 'dgram', ['dgram/bind-params.js'] ],
417+
[ 'domain', ['domain/domain-fn-args.js'] ],
418+
[ 'events', ['events/ee-emit.js'] ],
419+
[ 'fs', ['fs/readfile.js'] ],
420+
[ 'http', ['_http-benchmarkers.js', 'http/simple.js'] ],
421+
[ 'module', ['module/module-loader.js'] ],
422+
[ 'net', ['net/net-c2s.js'] ],
423+
[ 'os', ['os/loadavg.js'] ],
424+
[ 'path', ['path/basename-posix.js'] ],
425+
[ 'process', ['process/memoryUsage.js'] ],
426+
[ 'querystring', ['querystring/querystring-parse.js'] ],
427+
[ 'stream', ['streams/readable-readall.js'] ],
428+
[ 'string_decoder', ['string_decoder/string-decoder.js'] ],
429+
[ 'timers', ['timers/set-immediate-depth.js'] ],
430+
[ 'tls', ['tls/throughput.js'] ],
431+
[ 'url', ['url/url-resolve.js'] ],
432+
[ 'util', ['util/format.js'] ],
433+
[ 'V8', ['arrays/var-int.js', 'es/defaultparams-bench.js'] ],
434+
[ 'vm', ['vm/run-in-context.js'] ]
435+
]
436+
for (const info of specificBenchmarks) {
437+
let labels = info[0]
438+
if (!Array.isArray(labels)) {
439+
labels = ['benchmark', labels]
440+
} else {
441+
labels = ['benchmark'].concat(labels)
442+
}
443+
const files = info[1]
444+
for (const file of files) {
445+
tap.test(`label: "${labels.join('","')}" when ./benchmark/${file} has been changed`, (t) => {
446+
const resolved = nodeLabels.resolveLabels([`benchmark/${file}`])
447+
448+
t.same(resolved, labels)
449+
450+
t.end()
451+
})
452+
}
453+
}
454+
455+
const moreTools = [
456+
'.eslintignore', '.editorconfig', '.eslintrc.yaml', '.remarkrc'
457+
]
458+
for (const file of moreTools) {
459+
tap.test(`label: "tools" when ${file} has been changed`, (t) => {
460+
const resolved = nodeLabels.resolveLabels([`${file}`])
461+
462+
t.same(resolved, ['tools'])
463+
464+
t.end()
465+
})
466+
}
467+
468+
const specificTests = [
469+
[ 'addons', ['addons/async-hello-world/binding.cc'] ],
470+
[ 'debugger', ['debugger/test-debugger-repl.js'] ],
471+
[ ['doc', 'tools'], ['doctool/test-doctool-html.js'] ],
472+
[ 'timers', ['timers/test-timers-reliability.js'] ],
473+
[ 'tty', ['pseudo-tty/stdin-setrawmode.js'] ]
474+
]
475+
for (const info of specificTests) {
476+
let labels = info[0]
477+
if (!Array.isArray(labels)) {
478+
labels = ['test', labels]
479+
} else {
480+
labels = ['test'].concat(labels)
481+
}
482+
const files = info[1]
483+
for (const file of files) {
484+
tap.test(`label: "${labels.join('","')}" when ./test/${file} has been changed`, (t) => {
485+
const resolved = nodeLabels.resolveLabels([`test/${file}`])
486+
487+
t.same(resolved, labels)
488+
489+
t.end()
490+
})
491+
}
492+
}
493+
494+
const specificTools = [
495+
[ 'build', ['gyp/gyp_main.py', 'gyp_node.py'] ],
496+
[ 'doc', ['doc/generate.js'] ],
497+
[ 'intl', ['icu/icu-generate.gyp'] ],
498+
[ 'macos',
499+
['macosx-firewall.sh',
500+
'osx-codesign.sh' ] ],
501+
[ ['macos', 'install'],
502+
['osx-pkg.pmdoc/index.xml.tmpl',
503+
'pkgsrc/description' ] ],
504+
[ ['test', 'npm'], ['test-npm.sh', 'test-npm-package.js'] ],
505+
[ ['test'], ['test.py'] ],
506+
[ ['openssl', 'tls'], ['certdata.txt', 'mkssldef.py', 'mk-ca-bundle.pl'] ],
507+
[ ['windows'], ['sign.bat'] ],
508+
[ ['windows', 'install'], ['msvs/msi/product.wxs'] ],
509+
[ ['V8'], ['make-v8.sh'] ]
510+
]
511+
for (const info of specificTools) {
512+
let labels = info[0]
513+
if (!Array.isArray(labels)) {
514+
labels = ['tools', labels]
515+
} else {
516+
labels = ['tools'].concat(labels)
517+
}
518+
const files = info[1]
519+
for (const file of files) {
520+
tap.test(`label: "${labels.join('","')}" when ./tools/${file} has been changed`, (t) => {
521+
const resolved = nodeLabels.resolveLabels([`tools/${file}`])
522+
523+
t.same(resolved, labels)
524+
525+
t.end()
526+
})
527+
}
528+
}

0 commit comments

Comments
 (0)