mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-19 07:20:13 +01:00
Extract long-running "stress" tests from core test suite (no loss of coverage).
This commit is contained in:
parent
76cee28a26
commit
557c5942ea
3 changed files with 59 additions and 51 deletions
|
|
@ -12,8 +12,9 @@
|
|||
},
|
||||
"bugs": "https://github.com/DavidAnson/markdownlint/issues",
|
||||
"scripts": {
|
||||
"test": "nodeunit",
|
||||
"test-cover": "istanbul cover node_modules/nodeunit/bin/nodeunit",
|
||||
"test": "nodeunit test/markdownlint-test.js",
|
||||
"test-cover": "istanbul cover node_modules/nodeunit/bin/nodeunit test/markdownlint-test.js",
|
||||
"test-extra": "nodeunit test/markdownlint-test-extra.js",
|
||||
"debug": "node debug node_modules/nodeunit/bin/nodeunit",
|
||||
"lint": "eslint lib test schema && eslint --env browser --global markdownit --global markdownlint --rule \"no-unused-vars: 0, no-extend-native: 0, max-statements: 0, no-console: 0\" demo && eslint --rule \"no-console: 0, no-shadow: 0\" example",
|
||||
"build-config-schema": "node schema/build-config-schema.js",
|
||||
|
|
|
|||
56
test/markdownlint-test-extra.js
Normal file
56
test/markdownlint-test-extra.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
"use strict";
|
||||
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var glob = require("glob");
|
||||
var markdownlint = require("../lib/markdownlint");
|
||||
var shared = require("../lib/shared");
|
||||
|
||||
module.exports.typeTestFiles = function typeTestFiles(test) {
|
||||
// Simulates typing each test file to validate handling of partial input
|
||||
function validate(file, content) {
|
||||
var results = markdownlint.sync({
|
||||
"strings": {
|
||||
"content": content
|
||||
}
|
||||
});
|
||||
var contentLineCount = content.split(shared.newLineRe).length;
|
||||
Object.keys(results.content).forEach(function forKey(ruleName) {
|
||||
results.content[ruleName].forEach(function forLine(line) {
|
||||
test.ok((line >= 1) && (line <= contentLineCount),
|
||||
"Line number out of range: " + line +
|
||||
" (" + file + ", " + content.length + ", " + ruleName + ")");
|
||||
});
|
||||
});
|
||||
}
|
||||
var files = fs.readdirSync("./test");
|
||||
files.forEach(function forFile(file) {
|
||||
if (/\.md$/.test(file)) {
|
||||
var content = fs.readFileSync(
|
||||
path.join("./test", file), shared.utf8Encoding);
|
||||
while (content) {
|
||||
validate(file, content);
|
||||
content = content.slice(0, -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
module.exports.parseAllFiles = function parseAllFiles(test) {
|
||||
// Parses all Markdown files in all dependencies
|
||||
var globOptions = {
|
||||
// "cwd": "/",
|
||||
"realpath": true
|
||||
};
|
||||
glob("**/*.{md,markdown}", globOptions, function globCallback(err, matches) {
|
||||
test.ifError(err);
|
||||
var markdownlintOptions = {
|
||||
"files": matches
|
||||
};
|
||||
markdownlint(markdownlintOptions, function markdownlintCallback(errr) {
|
||||
test.ifError(errr);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
@ -4,7 +4,6 @@ var fs = require("fs");
|
|||
var path = require("path");
|
||||
var md = require("markdown-it")();
|
||||
var Q = require("q");
|
||||
var glob = require("glob");
|
||||
var tv4 = require("tv4");
|
||||
var markdownlint = require("../lib/markdownlint");
|
||||
var shared = require("../lib/shared");
|
||||
|
|
@ -933,54 +932,6 @@ module.exports.doc = function doc(test) {
|
|||
});
|
||||
};
|
||||
|
||||
module.exports.typeTestFiles = function typeTestFiles(test) {
|
||||
// Simulates typing each test file to validate handling of partial input
|
||||
function validate(file, content) {
|
||||
var results = markdownlint.sync({
|
||||
"strings": {
|
||||
"content": content
|
||||
}
|
||||
});
|
||||
var contentLineCount = content.split(shared.newLineRe).length;
|
||||
Object.keys(results.content).forEach(function forKey(ruleName) {
|
||||
results.content[ruleName].forEach(function forLine(line) {
|
||||
test.ok((line >= 1) && (line <= contentLineCount),
|
||||
"Line number out of range: " + line +
|
||||
" (" + file + ", " + content.length + ", " + ruleName + ")");
|
||||
});
|
||||
});
|
||||
}
|
||||
var files = fs.readdirSync("./test");
|
||||
files.forEach(function forFile(file) {
|
||||
if (/\.md$/.test(file)) {
|
||||
var content = fs.readFileSync(
|
||||
path.join("./test", file), shared.utf8Encoding);
|
||||
while (content) {
|
||||
validate(file, content);
|
||||
content = content.slice(0, -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
module.exports.parseAllFiles = function parseAllFiles(test) {
|
||||
var globOptions = {
|
||||
// "cwd": "/",
|
||||
"realpath": true
|
||||
};
|
||||
glob("**/*.{md,markdown}", globOptions, function globCallback(err, matches) {
|
||||
test.ifError(err);
|
||||
var markdownlintOptions = {
|
||||
"files": matches
|
||||
};
|
||||
markdownlint(markdownlintOptions, function markdownlintCallback(errr) {
|
||||
test.ifError(errr);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.validateConfigSchema = function validateConfigSchema(test) {
|
||||
var jsonFileRe = /\.json$/i;
|
||||
var testDirectory = __dirname;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue