test: provide better message for orphan output documentation
PR-URL: https://github.com/nodejs/node/pull/21913 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
0e4cbde13b
commit
c57e11c2f6
@ -12,6 +12,8 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const apiPath = path.resolve(__dirname, '..', '..', 'out', 'doc', 'api');
|
||||
const mdPath = path.resolve(__dirname, '..', '..', 'doc', 'api');
|
||||
const allMD = fs.readdirSync(mdPath);
|
||||
const allDocs = fs.readdirSync(apiPath);
|
||||
assert.ok(allDocs.includes('index.html'));
|
||||
|
||||
@ -22,6 +24,15 @@ const actualDocs = allDocs.filter(
|
||||
}
|
||||
);
|
||||
|
||||
for (const name of actualDocs) {
|
||||
if (name.startsWith('all.')) continue;
|
||||
|
||||
assert.ok(
|
||||
allMD.includes(name.replace(/\.\w+$/, '.md')),
|
||||
`Unexpected output: out/doc/api/${name}, remove and rerun.`
|
||||
);
|
||||
}
|
||||
|
||||
const toc = fs.readFileSync(path.resolve(apiPath, 'index.html'), 'utf8');
|
||||
const re = /href="([^/]+\.html)"/;
|
||||
const globalRe = new RegExp(re, 'g');
|
||||
@ -43,7 +54,7 @@ for (const expectedDoc of expectedDocs) {
|
||||
// and that they are not empty files.
|
||||
for (const actualDoc of actualDocs) {
|
||||
assert.ok(
|
||||
expectedDocs.includes(actualDoc), `${actualDoc} does not not match TOC`);
|
||||
expectedDocs.includes(actualDoc), `${actualDoc} does not match TOC`);
|
||||
|
||||
assert.ok(
|
||||
fs.statSync(path.join(apiPath, actualDoc)).size !== 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user