tools: fix tools/addon-verify.js
The current implementation of addon-verify.js is including the code for the "Function arguments" section in test/addons/01_callbacks and there is no directory generated or the "Function arguments section". This continues and leads to the last section, "AtExit", code to be excluded. There is an test/addons/07_atexit_hooks but it contains code from the "Passing wrapped objects around" section. This commit modifies addon-verify to associate headers with code and then iterates over the set and generates the files as a separate step. PR-URL: https://github.com/nodejs/node/pull/14048 Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
a439cf4354
commit
7f81400723
@ -1125,7 +1125,7 @@ Test in JavaScript by running:
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
// test.js
|
// test.js
|
||||||
const addon = require('./build/Release/addon');
|
require('./build/Release/addon');
|
||||||
```
|
```
|
||||||
|
|
||||||
[Embedder's Guide]: https://github.com/v8/v8/wiki/Embedder's%20Guide
|
[Embedder's Guide]: https://github.com/v8/v8/wiki/Embedder's%20Guide
|
||||||
|
@ -11,30 +11,30 @@ const verifyDir = path.resolve(rootDir, 'test', 'addons');
|
|||||||
const contents = fs.readFileSync(doc).toString();
|
const contents = fs.readFileSync(doc).toString();
|
||||||
|
|
||||||
const tokens = marked.lexer(contents);
|
const tokens = marked.lexer(contents);
|
||||||
let files = null;
|
|
||||||
let id = 0;
|
let id = 0;
|
||||||
|
|
||||||
// Just to make sure that all examples will be processed
|
let currentHeader;
|
||||||
tokens.push({ type: 'heading' });
|
const addons = {};
|
||||||
|
tokens.forEach((token) => {
|
||||||
for (var i = 0; i < tokens.length; i++) {
|
|
||||||
var token = tokens[i];
|
|
||||||
if (token.type === 'heading' && token.text) {
|
if (token.type === 'heading' && token.text) {
|
||||||
const blockName = token.text;
|
currentHeader = token.text;
|
||||||
if (files && Object.keys(files).length !== 0) {
|
addons[currentHeader] = {
|
||||||
verifyFiles(files,
|
files: {}
|
||||||
blockName,
|
};
|
||||||
|
}
|
||||||
|
if (token.type === 'code') {
|
||||||
|
var match = token.text.match(/^\/\/\s+(.*\.(?:cc|h|js))[\r\n]/);
|
||||||
|
if (match !== null) {
|
||||||
|
addons[currentHeader].files[match[1]] = token.text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (var header in addons) {
|
||||||
|
verifyFiles(addons[header].files,
|
||||||
|
header,
|
||||||
console.log.bind(null, 'wrote'),
|
console.log.bind(null, 'wrote'),
|
||||||
function(err) { if (err) throw err; });
|
function(err) { if (err) throw err; });
|
||||||
}
|
}
|
||||||
files = {};
|
|
||||||
} else if (token.type === 'code') {
|
|
||||||
var match = token.text.match(/^\/\/\s+(.*\.(?:cc|h|js))[\r\n]/);
|
|
||||||
if (match === null)
|
|
||||||
continue;
|
|
||||||
files[match[1]] = token.text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function once(fn) {
|
function once(fn) {
|
||||||
var once = false;
|
var once = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user