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

Unified Diff: test_runner.js

Issue 29373596: Issue 4838 - Use nodeunit framework for integration tests running in browser (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Isolate module scopes to avoid naming conflicts Created Jan. 25, 2017, 9:53 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
« test/browser/elemHideEmulation.js ('K') | « test/browser/elemHideEmulation.js ('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
@@ -12,57 +12,76 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
+let childProcess = require("child_process");
let fs = require("fs");
+let nodeunit = require("nodeunit");
let path = require("path");
+let phantomjs = require("phantomjs2");
let process = require("process");
-let nodeunit = require("nodeunit");
-let qunit = require("node-qunit-phantomjs");
+let url = require("url");
let nodeunitFiles = [];
Felix Dahlke 2017/01/30 14:37:59 Since the browser tests are using nodeunit as well
Wladimir Palant 2017/02/24 09:18:55 Done.
-let qunitFiles = [];
+let browserFiles = [];
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;
}
if (path.basename(testPath).startsWith("_"))
continue;
- if (testPath.split(path.sep).includes("browser"))
+ if (path.extname(testPath) == ".js")
{
- if (path.extname(testPath) == ".html")
- qunitFiles.push(testPath);
+ if (testPath.split(path.sep).includes("browser"))
+ browserFiles.push(testPath);
+ else
+ nodeunitFiles.push(testPath);
}
- else if (path.extname(testPath) == ".js")
- nodeunitFiles.push(testPath);
}
}
if (process.argv.length > 2)
{
addTestPaths(process.argv.slice(2), true);
}
else
{
addTestPaths(
[path.join(__dirname, "test"), path.join(__dirname, "test", "browser")],
true
);
}
+if (browserFiles.length)
+{
+ let nodeunitPath = path.join(
+ path.dirname(require.resolve("nodeunit")),
+ "examples", "browser", "nodeunit.js"
+ );
+ browserFiles.unshift(nodeunitPath);
+
+ let urls = browserFiles.map(file =>
+ {
+ return url.format({
+ protocol: "file",
+ slashes: "true",
+ pathname: path.resolve(process.cwd, file).split(path.sep).join("/")
+ });
+ });
+ let args = [path.join(__dirname, "browsertests.js")].concat(urls);
+ childProcess.execFileSync(phantomjs.path, args, {stdio: "inherit"});
+}
if (nodeunitFiles.length)
Felix Dahlke 2017/01/30 14:37:59 IMO we should run the unit tests first - should fa
Wladimir Palant 2017/02/24 09:18:55 This is not so easy, unit tests are async and we w
Felix Dahlke 2017/02/24 10:43:39 Acknowledged.
nodeunit.reporters.default.run(nodeunitFiles);
-for (let file of qunitFiles)
- qunit(file);
« test/browser/elemHideEmulation.js ('K') | « test/browser/elemHideEmulation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld