Skip to content

Commit e6448aa

Browse files
rvaggMyles Borins
authored and
Myles Borins
committed
test: use addon.md block headings as test dir names
instead of doc-* PR-URL: #4412 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Johan Bergström <[email protected]>
1 parent 305d340 commit e6448aa

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
lib/punycode.js
2-
test/addons/doc-*/
2+
test/addons/??_*/
33
test/fixtures
44
test/**/node_modules
55
test/disabled

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ipch/
5050
/npm.wxs
5151
/tools/msvs/npm.wixobj
5252
/tools/osx-pkg.pmdoc/index.xml
53-
/test/addons/doc-*/
53+
/test/addons/??_*/
5454
email.md
5555
deps/v8-*
5656
deps/icu

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ test/gc/node_modules/weak/build/Release/weakref.node: $(NODE_EXE)
105105

106106
# Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale.
107107
test/addons/.docbuildstamp: doc/api/addons.markdown
108-
$(RM) -r test/addons/doc-*/
108+
$(RM) -r test/addons/??_*/
109109
$(NODE) tools/doc/addon-verify.js
110110
touch $@
111111

112112
ADDONS_BINDING_GYPS := \
113-
$(filter-out test/addons/doc-*/binding.gyp, \
113+
$(filter-out test/addons/??_*/binding.gyp, \
114114
$(wildcard test/addons/*/binding.gyp))
115115

116116
# Implicitly depends on $(NODE_EXE), see the build-addons rule for rationale.
@@ -520,7 +520,7 @@ CPPLINT_EXCLUDE += src/node_win32_perfctr_provider.cc
520520
CPPLINT_EXCLUDE += src/queue.h
521521
CPPLINT_EXCLUDE += src/tree.h
522522
CPPLINT_EXCLUDE += src/v8abbr.h
523-
CPPLINT_EXCLUDE += $(wildcard test/addons/doc-*/*.cc test/addons/doc-*/*.h)
523+
CPPLINT_EXCLUDE += $(wildcard test/addons/??_*/*.cc test/addons/??_*/*.h)
524524

525525
CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \
526526
deps/debugger-agent/include/* \

tools/doc/addon-verify.js

+20-14
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
1-
var fs = require('fs');
2-
var path = require('path');
3-
var marked = require('marked');
1+
'use strict';
42

5-
var doc = path.resolve(__dirname, '..', '..', 'doc', 'api', 'addons.markdown');
6-
var verifyDir = path.resolve(__dirname, '..', '..', 'test', 'addons');
3+
const fs = require('fs');
4+
const path = require('path');
5+
const marked = require('marked');
76

8-
var contents = fs.readFileSync(doc).toString();
7+
const doc = path.resolve(__dirname, '..', '..', 'doc', 'api', 'addons.markdown');
8+
const verifyDir = path.resolve(__dirname, '..', '..', 'test', 'addons');
99

10-
var tokens = marked.lexer(contents, {});
11-
var files = null;
12-
var id = 0;
10+
const contents = fs.readFileSync(doc).toString();
11+
12+
let tokens = marked.lexer(contents, {});
13+
let files = null;
14+
let blockName;
15+
let id = 0;
1316

1417
// Just to make sure that all examples will be processed
1518
tokens.push({ type: 'heading' });
1619

1720
var oldDirs = fs.readdirSync(verifyDir);
1821
oldDirs = oldDirs.filter(function(dir) {
19-
return /^doc-/.test(dir);
22+
return /^\d{2}_/.test(dir);
2023
}).map(function(dir) {
2124
return path.resolve(verifyDir, dir);
2225
});
2326

2427
for (var i = 0; i < tokens.length; i++) {
2528
var token = tokens[i];
26-
if (token.type === 'heading') {
29+
if (token.type === 'heading' && token.text) {
30+
blockName = token.text
2731
if (files && Object.keys(files).length !== 0) {
2832
verifyFiles(files,
33+
blockName,
2934
console.log.bind(null, 'wrote'),
3035
function(err) { if (err) throw err; });
3136
}
@@ -48,15 +53,16 @@ function once(fn) {
4853
};
4954
}
5055

51-
function verifyFiles(files, onprogress, ondone) {
52-
var dir = path.resolve(verifyDir, 'doc-' + id++);
53-
56+
function verifyFiles(files, blockName, onprogress, ondone) {
5457
// must have a .cc and a .js to be a valid test
5558
if (!Object.keys(files).some((name) => /\.cc$/.test(name)) ||
5659
!Object.keys(files).some((name) => /\.js$/.test(name))) {
5760
return;
5861
}
5962

63+
blockName = blockName.toLowerCase().replace(/\s/g, '_').replace(/[^a-z\d_]/g, '')
64+
let dir = path.resolve(verifyDir, `${(++id < 10 ? '0' : '') + id}_${blockName}`);
65+
6066
files = Object.keys(files).map(function(name) {
6167
return {
6268
path: path.resolve(dir, name),

0 commit comments

Comments
 (0)