Skip to content

Commit

Permalink
labels: prevent deps from getting "lib / src" label
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipj committed Jul 6, 2016
1 parent 4faa9b5 commit 24aeedd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/node-labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged, limitLib) {

for (var i = 0; i < mappedSubSystems.length; ++i) {
const mappedSubSystem = mappedSubSystems[i]
if (limitLib && jsSubsystemList.includes(mappedSubSystem)) {
if (limitLib && hasJsSubsystemChanges(filepathsChanged, mappedSubSystem)) {
if (jsLabelCount.length >= 4) {
for (const jsLabel of jsLabelCount) {
delete map[jsLabel]
Expand All @@ -126,6 +126,11 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged, limitLib) {
return Object.keys(labelsMap)
}

function hasJsSubsystemChanges (filepathsChanged, mappedSubSystem) {
const hasLibChanges = filepathsChanged.some((filepath) => filepath.startsWith('lib/'))
return hasLibChanges && jsSubsystemList.includes(mappedSubSystem)
}

function mappedSubSystemsForFile (labelsMap, filepath) {
for (const [regex, label] of labelsMap) {
const matches = regex.exec(filepath)
Expand Down
15 changes: 15 additions & 0 deletions test/node-labels.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ tap.test('label: "lib / src" when 5 or more JS sub-systems have been changed', (
t.end()
})

// https://github.com/nodejs/node/pull/7488 wrongfully labelled with "lib / src"
tap.test('label: not "lib / src" when only deps have been changed', (t) => {
const labels = nodeLabels.resolveLabels([
'deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden',
'deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiteralsWide.golden',
'deps/v8/test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden',
'deps/v8/test/cctest/interpreter/bytecode_expectations/BasicBlockToBoolean.golden',
'deps/v8/test/cctest/interpreter/bytecode_expectations/BasicLoops.golden'
])

t.same(labels, ['v8'])

t.end()
})

tap.test('label: "JS sub-systems when less than 5 sub-systems have changed', (t) => {
const labels = nodeLabels.resolveLabels([
'lib/assert.js',
Expand Down

0 comments on commit 24aeedd

Please sign in to comment.