Skip to content

Commit

Permalink
test: provide better message for orphan output documentation
Browse files Browse the repository at this point in the history
PR-URL: #21913
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
rubys authored and targos committed Jul 24, 2018
1 parent c3d9000 commit 3213c09
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/doctool/test-make-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand All @@ -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');
Expand All @@ -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,
Expand Down

0 comments on commit 3213c09

Please sign in to comment.