Skip to content

Commit 0e137d0

Browse files
authored
feat: point to guidelines on failure in TAP output (#95)
If commit linting fails, include the URL to the commit message guidelines in the TAP output. Refs: nodejs/node#41697
1 parent 69435db commit 0e137d0

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/tap.js

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ module.exports = class Tap extends Readable {
112112

113113
if (this._failures) {
114114
this.write(`# fail ${this._failures}`)
115+
this.write('# Please review the commit message guidelines:')
116+
this.write('# https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines')
115117
}
116118

117119
this.push(null)

test/cli-test.js

+31
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,37 @@ test('Test cli flags', (t) => {
8282
})
8383
})
8484

85+
t.test('test tap output', (tt) => {
86+
// Use a commit from this repository that does not follow the guidelines.
87+
const ls = spawn('./bin/cmd.js', ['--no-validate-metadata', '--tap', '69435db261'])
88+
let compiledData = ''
89+
ls.stdout.on('data', (data) => {
90+
compiledData += data
91+
})
92+
93+
ls.stderr.on('data', (data) => {
94+
tt.fail(`Unexpected stderr output ${data.toString()}`)
95+
})
96+
97+
ls.on('close', (code) => {
98+
const output = compiledData.trim()
99+
tt.match(output,
100+
/# 69435db261/,
101+
'TAP output contains the sha of the commit being linted')
102+
tt.match(output,
103+
/not ok \d+ subsystem: Invalid subsystem: "chore" \(chore: update tested node release lines \(#94\)\)/,
104+
'TAP output contains failure for subsystem')
105+
tt.match(output,
106+
/# fail\s+\d+/,
107+
'TAP output contains total failures')
108+
tt.match(output,
109+
/# Please review the commit message guidelines:\s# https:\/\/github.com\/nodejs\/node\/blob\/HEAD\/doc\/contributing\/pull-requests.md#commit-message-guidelines/,
110+
'TAP output contains pointer to commit message guidelines')
111+
tt.equal(code, 1, 'CLI exits with non-zero code on failure')
112+
tt.end()
113+
})
114+
})
115+
85116
t.test('test url', (tt) => {
86117
const ls = spawn('./bin/cmd.js', ['--no-validate-metadata', 'https://api.github.com/repos/nodejs/core-validate-commit/commits/2b98d02b52'])
87118
let compiledData = ''

0 commit comments

Comments
 (0)