mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40: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
|
|
@ -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