Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
put the make doc part in Makefile
  • Loading branch information
joyeecheung committed Oct 17, 2017
commit 882172ff25b2e6b1b5ade311ca526c334ec21250
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ else
test: all
$(MAKE) build-addons
$(MAKE) build-addons-napi
$(MAKE) doc-only
$(MAKE) cctest
$(PYTHON) tools/test.py --mode=release -J \
$(CI_ASYNC_HOOKS) \
Expand Down Expand Up @@ -379,7 +380,7 @@ test-ci-js: | clear-stalled
fi

test-ci: LOGLEVEL := info
test-ci: | clear-stalled build-addons build-addons-napi
test-ci: | clear-stalled build-addons build-addons-napi doc-only
out/Release/cctest --gtest_output=tap:cctest.tap
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
--mode=release --flaky-tests=$(FLAKY_TESTS) \
Expand Down
74 changes: 30 additions & 44 deletions test/sequential/test-make-doc.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,46 @@
'use strict';

// This tests that `make doc` generates the documentation properly.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits: as per

'use strict'; // 1
const common = require('../common'); // 2
// This test ensures that the http-parser can handle UTF-8 characters // 4
// in the http header. // 5
const assert = require('assert'); // 7
headers should be

'use strict';
const common = require('../common');
if (common.isWindows) {
  common.skip('Do not make doc on Windows');
}

// This tests that `make doc` generates the documentation properly.
// Note that for this test to pass, `make doc` must be run first.
 
const assert = require('assert');
const fs = require('fs');
const path = require('path');

// Note that for this test to pass, `make doc` must be run first.

const common = require('../common');

const assert = require('assert');
const exec = require('child_process').exec;
const fs = require('fs');
const path = require('path');

if (common.isWindows) {
common.skip('Do not make doc on Windows');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO message should be '`make doc` doesn't run on Windows'

}

// Make sure all the relative links work and
// all the generated documents are linked in TOC
function verifyToc() {
const apiPath = path.join(common.projectDir, 'out', 'doc', 'api');
const docs = fs.readdirSync(apiPath);
assert.notStrictEqual(docs.indexOf('_toc.html'), -1);

const toc = fs.readFileSync(path.join(apiPath, '_toc.html'), 'utf8');
const re = /href="([^/]+\.html)"/;
const globalRe = new RegExp(re, 'g');
const links = toc.match(globalRe);
assert.notStrictEqual(links, null);

const linkedHtmls = links.map((link) => link.match(re)[1]);
for (const html of linkedHtmls) {
assert.notStrictEqual(docs.indexOf(html), -1, `${html} does not exist`);
}
const apiPath = path.join(common.projectDir, 'out', 'doc', 'api');
const docs = fs.readdirSync(apiPath);
assert.ok(docs.includes('_toc.html'));

const toc = fs.readFileSync(path.join(apiPath, '_toc.html'), 'utf8');
const re = /href="([^/]+\.html)"/;
const globalRe = new RegExp(re, 'g');
const links = toc.match(globalRe);
assert.notStrictEqual(links, null);

// Test that all the relative links in the TOC of the documentation
// work and all the generated documents are linked in TOC.
const linkedHtmls = links.map((link) => link.match(re)[1]);
for (const html of linkedHtmls) {
assert.ok(docs.includes(html), `${html} does not exist`);
}

const excludes = ['.json', '_toc', 'assets'];
const generatedHtmls = docs.filter(function(doc) {
for (const exclude of excludes) {
if (doc.includes(exclude)) {
return false;
}
const excludes = ['.json', '_toc', 'assets'];
const generatedHtmls = docs.filter(function(doc) {
for (const exclude of excludes) {
if (doc.includes(exclude)) {
return false;
}
return true;
});

for (const html of generatedHtmls) {
assert.notStrictEqual(
linkedHtmls.indexOf(html),
-1,
`${html} is not linked in toc`);
}
}
return true;
});

exec('make doc', {
cwd: common.projectDir
}, common.mustCall(function onExit(err, stdout, stderr) {
console.log(stdout);
if (stderr.length > 0) {
console.log('stderr is not empty: ');
console.log(stderr);
}
assert.ifError(err);
verifyToc();
}));
for (const html of generatedHtmls) {
assert.ok(linkedHtmls.includes(html), `${html} is not linked in toc`);
}