Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test_runner.js

Issue 29367181: Issue 4726 - Add tests for the element hiding emulation content script (Closed) Base URL: https://bitbucket.org/fhd/adblockpluscore
Patch Set: Add license header Created Jan. 10, 2017, 9:16 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« README.md ('K') | « test/browser/index.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test_runner.js
===================================================================
--- a/test_runner.js
+++ b/test_runner.js
@@ -16,36 +16,47 @@
*/
"use strict";
let fs = require("fs");
let path = require("path");
let process = require("process");
let nodeunit = require("nodeunit");
+let qunit = require("node-qunit-phantomjs");
-let files = [];
+let nodeunitFiles = [];
+let qunitFiles = [];
function addTestPaths(testPaths, recurse)
{
for (let testPath of testPaths)
{
let stat = fs.statSync(testPath);
if (stat.isDirectory())
{
if (recurse)
{
addTestPaths(fs.readdirSync(testPath).map(
file => path.join(testPath, file)));
}
+ continue;
}
- else if (path.extname(testPath) == ".js" &&
- !path.basename(testPath).startsWith("_"))
+ if (path.basename(testPath).startsWith("_"))
+ continue;
+ if (testPath.split(path.sep).includes("browser"))
{
- files.push(testPath);
+ if (path.extname(testPath) == ".html")
+ qunitFiles.push(testPath);
}
+ else if (path.extname(testPath) == ".js")
+ nodeunitFiles.push(testPath);
}
}
if (process.argv.length > 2)
addTestPaths(process.argv.slice(2), true);
else
kzar 2017/01/10 11:05:33 Nit: Since the addTestPaths call goes over multipl
Felix Dahlke 2017/01/17 19:41:08 Done.
- addTestPaths([path.join(__dirname, "test")], true);
+ addTestPaths(
+ [path.join(__dirname, "test"), path.join(__dirname, "test", "browser")],
+ true);
kzar 2017/01/10 11:05:34 Nit: We would normally put the closing parenthesis
Felix Dahlke 2017/01/17 19:41:08 We use the style above a lot, last time I checked
-nodeunit.reporters.default.run(files);
+if (nodeunitFiles.length)
+ nodeunit.reporters.default.run(nodeunitFiles);
+qunitFiles.forEach(file => qunit(path.resolve(file)));
kzar 2017/01/10 11:05:34 Nit: We usually use "for of" loops instead of forE
Felix Dahlke 2017/01/17 19:41:08 I prefer forEach when it comes down to actually in
« README.md ('K') | « test/browser/index.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld