Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: provide better message for orphan output documentation #21913

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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