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

Unified Diff: test_runner.js

Issue 29720661: Issue 6391 - Allow running the browser unit tests with Firefox (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created March 12, 2018, 8:23 p.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
« firefox_process.js ('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
@@ -22,20 +22,42 @@
const fs = require("fs");
const path = require("path");
const MemoryFS = require("memory-fs");
const nodeunit = require("nodeunit");
const webpack = require("webpack");
const chromiumProcess = require("./chromium_process");
+const firefoxProcess = require("./firefox_process");
let unitFiles = [];
let browserFiles = [];
+let runnerDefinitions = {
+ chromium: chromiumProcess,
+ firefox: firefoxProcess
+};
+
+function configureRunners()
+{
+ let runners = "BROWSER_TEST_RUNNERS" in process.env ?
+ process.env.BROWSER_TEST_RUNNERS.split(",") : [];
+
+ // default is chromium only, for now.
+ if (runners.length == 0)
+ return ["chromium", "firefox"];
+
+ runners.filter(runner => runner in runnerDefinitions);
+
+ return runners;
+}
+
+let runnerProcesses = configureRunners();
+
function addTestPaths(testPaths, recurse)
{
for (let testPath of testPaths)
{
let stat = fs.statSync(testPath);
if (stat.isDirectory())
{
if (recurse)
@@ -88,17 +110,17 @@
let bundle = memoryFS.readFileSync("/" + bundleFilename, "utf-8");
memoryFS.unlinkSync("/" + bundleFilename);
resolve(bundle);
}
});
});
}
-function runBrowserTests()
+function runBrowserTests(processes)
{
if (!browserFiles.length)
return;
let nodeunitPath = path.join(__dirname, "node_modules", "nodeunit",
"examples", "browser", "nodeunit.js");
let bundleFilename = "bundle.js";
@@ -117,38 +139,41 @@
},
resolve: {
alias: {
nodeunit$: nodeunitPath
},
modules: [path.resolve(__dirname, "lib")]
}
}).then(bundle =>
- {
- return chromiumProcess(
- bundle, bundleFilename,
- browserFiles.map(
- file => path.relative(path.join(__dirname, "test", "browser"),
- file).replace(/\.js$/, "")
+ Promise.all(
+ processes.map(currentProcess =>
+ runnerDefinitions[currentProcess](
+ bundle, bundleFilename,
+ browserFiles.map(
+ file => path.relative(path.join(__dirname, "test", "browser"),
+ file).replace(/\.js$/, "")
+ )
+ )
)
- );
- });
+ )
+ );
}
if (process.argv.length > 2)
addTestPaths(process.argv.slice(2), true);
else
{
addTestPaths(
[path.join(__dirname, "test"), path.join(__dirname, "test", "browser")],
true
);
}
-Promise.resolve(runBrowserTests()).catch(error =>
+Promise.resolve(runBrowserTests(runnerProcesses)).catch(error =>
{
console.error("Failed running browser tests");
console.error(error);
}).then(() =>
{
if (unitFiles.length)
nodeunit.reporters.default.run(unitFiles);
});
« firefox_process.js ('K') | « test/browser/index.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld