summaryrefslogtreecommitdiff
path: root/test/doctool/test-make-doc.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-10-18 13:39:19 -0700
committerRich Trott <rtrott@gmail.com>2017-10-19 09:07:51 -0700
commitc9d5be4af098848ebb4573d47750c4798845458d (patch)
tree84e65e8dfa4388457df6dd0f5c5108fa4f69de19 /test/doctool/test-make-doc.js
parent33b4320cf9d5b99016fe9b619a8f930f99b59c56 (diff)
downloadandroid-node-v8-c9d5be4af098848ebb4573d47750c4798845458d.tar.gz
android-node-v8-c9d5be4af098848ebb4573d47750c4798845458d.tar.bz2
android-node-v8-c9d5be4af098848ebb4573d47750c4798845458d.zip
test: fix flaky test-make-doc
`test-make-doc` fails in CI on Raspberry Pi devices where `test-ci-js` runs the test but does not build the docs. We do not want to build the docs in these cases. Move the test to the `doctool` suite and add that suite to `IGNORED_SUITES` in `test.py`. Specify `doctool` as a test suite to run with `make test` or `make test-ci` but not with the `make test-ci-js` job run on cross-compiled fanned CI tests like we do with Raspberry Pi devices in CI. PR-URL: https://github.com/nodejs/node/pull/16301 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/doctool/test-make-doc.js')
-rw-r--r--test/doctool/test-make-doc.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/doctool/test-make-doc.js b/test/doctool/test-make-doc.js
new file mode 100644
index 0000000000..06386c0c81
--- /dev/null
+++ b/test/doctool/test-make-doc.js
@@ -0,0 +1,43 @@
+'use strict';
+const common = require('../common');
+if (common.isWindows) {
+ common.skip('`make doc` does not run 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');
+
+const apiPath = path.resolve(common.projectDir, 'out', 'doc', 'api');
+const docs = fs.readdirSync(apiPath);
+assert.ok(docs.includes('_toc.html'));
+
+const toc = fs.readFileSync(path.resolve(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;
+ }
+ }
+ return true;
+});
+
+for (const html of generatedHtmls) {
+ assert.ok(linkedHtmls.includes(html), `${html} is not linked in toc`);
+}