Skip to content

test: test make doc and verify toc #16208

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

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions 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
$(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
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 Expand Up @@ -518,7 +519,7 @@ doc: $(NODE_EXE) doc-only
$(apidoc_dirs):
mkdir -p $@

out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets
cp $< $@

out/doc/%: doc/%
Expand Down
5 changes: 5 additions & 0 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ original state after calling [`common.hijackStdOut()`][].

Path to the 'root' directory. either `/` or `c:\\` (windows)

### projectDir
* return [&lt;String>]

Path to the project directory.

### skip(msg)
* `msg` [&lt;String>]

Expand Down
2 changes: 2 additions & 0 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ exports.enoughTestCpu = Array.isArray(cpus) &&
(cpus.length > 1 || cpus[0].speed > 999);

exports.rootDir = exports.isWindows ? 'c:\\' : '/';
exports.projectDir = path.resolve(__dirname, '..', '..');
Copy link
Member

Choose a reason for hiding this comment

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

I think this won't work on our cross-compiling Raspberry Pi devices in CI. @nodejs/build ?

Copy link
Member

Choose a reason for hiding this comment

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

Hmmmm...but it did pass in the CI, so...hmmm....

Copy link
Member

@Trott Trott Oct 18, 2017

Choose a reason for hiding this comment

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

Oh, perhaps CI was run before that specific feature was added? I'm certainly seeing it fail 100% of the time in CI right now as in https://ci.nodejs.org/job/node-test-binary-arm/11032/.

not ok 272 sequential/test-make-doc
  ---
  duration_ms: 2.153
  severity: fail
  stack: |-
    fs.js:926
      return binding.readdir(pathModule.toNamespacedPath(path), options.encoding);
                     ^
    
    Error: ENOENT: no such file or directory, scandir '/home/iojs/build/workspace/node-test-binary-arm/out/doc/api'
        at Object.fs.readdirSync (fs.js:926:18)
        at Object.<anonymous> (/home/iojs/build/workspace/node-test-binary-arm/test/sequential/test-make-doc.js:15:17)
        at Module._compile (module.js:607:30)
        at Object.Module._extensions..js (module.js:618:10)
        at Module.load (module.js:526:32)
        at tryModuleLoad (module.js:489:12)
        at Function.Module._load (module.js:481:3)
        at Function.Module.runMain (module.js:648:10)
        at startup (bootstrap_node.js:191:16)
        at bootstrap_node.js:609:3
  ...

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if the problem isn't common.projectDir at all but instead that the Pi devices run make test-ci-js and not make test or make test-ci?

Copy link
Member

Choose a reason for hiding this comment

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

(...and so it skips the make doc....which we probably want it to skip because who knows how long it would take to run on a Pi and we'd be running it on all of them just for a test that only one of them runs...)

Copy link
Member

Choose a reason for hiding this comment

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

I think I've got a fix in #16301 but we'll see if CI agrees....

Copy link
Member Author

@joyeecheung joyeecheung Oct 19, 2017

Choose a reason for hiding this comment

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

Hmm, I wonder why this passed the CI before...anyway thanks for the fix!

Copy link
Member

Choose a reason for hiding this comment

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

@joyeecheung I think it passed CI because this change wasn't in the branch when CI ran. It was run before a5262f1 landed.


exports.buildType = process.config.target_defaults.default_configuration;

// If env var is set then enable async_hook hooks for all tests.
Expand Down
43 changes: 43 additions & 0 deletions test/sequential/test-make-doc.js
Original file line number Diff line number Diff line change
@@ -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`);
}