diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-14 00:14:38 +0800 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-12-18 05:14:24 +0100 |
commit | 9190e4ecdf891892e479b0ef4b691252d4084806 (patch) | |
tree | 28a76c6a2959131c8a1ac1988ee3fe2a7c95894f /test/doctool | |
parent | 3edc1c917b6f678b9146b99daf91cc478cd0e8c3 (diff) | |
download | android-node-v8-9190e4ecdf891892e479b0ef4b691252d4084806.tar.gz android-node-v8-9190e4ecdf891892e479b0ef4b691252d4084806.tar.bz2 android-node-v8-9190e4ecdf891892e479b0ef4b691252d4084806.zip |
tools: make apilinks building more robust
1. Move the apilinks.json file into out/doc so it gets cleaned when
running `make docclean`
2. When the apilinks.json generated is empty, throw a specific error
so it's easier to understand what's wrong
3. Write to a file passed through CLI arguments instead writing to
stdout in apilinks.js so the build process is more robust in
the case of a bad binary
PR-URL: https://github.com/nodejs/node/pull/25019
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/doctool')
-rw-r--r-- | test/doctool/test-apilinks.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/test/doctool/test-apilinks.js b/test/doctool/test-apilinks.js index e53c81a08a..91de4b79f8 100644 --- a/test/doctool/test-apilinks.js +++ b/test/doctool/test-apilinks.js @@ -2,28 +2,31 @@ require('../common'); const fixtures = require('../common/fixtures'); +const tmpdir = require('../common/tmpdir'); const fs = require('fs'); const assert = require('assert'); const path = require('path'); const { execFileSync } = require('child_process'); const script = path.join(__dirname, '..', '..', 'tools', 'doc', 'apilinks.js'); - const apilinks = fixtures.path('apilinks'); + +tmpdir.refresh(); + fs.readdirSync(apilinks).forEach((fixture) => { if (!fixture.endsWith('.js')) return; - const file = path.join(apilinks, fixture); - - const expectedContent = fs.readFileSync(file + 'on', 'utf8'); + const input = path.join(apilinks, fixture); - const output = execFileSync( + const expectedContent = fs.readFileSync(`${input}on`, 'utf8'); + const outputPath = path.join(tmpdir.path, `${fixture}on`); + execFileSync( process.execPath, - [script, file], + [script, outputPath, input], { encoding: 'utf-8' } ); const expectedLinks = JSON.parse(expectedContent); - const actualLinks = JSON.parse(output); + const actualLinks = JSON.parse(fs.readFileSync(outputPath)); for (const [k, v] of Object.entries(expectedLinks)) { assert.ok(k in actualLinks, `link not found: ${k}`); |