2014-06-25 09:12:07 +04:00
|
|
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
2013-08-02 16:48:06 +04:00
|
|
|
/* vim:set ts=2 sw=2 sts=2 et: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
function parseTestManifest(testManifest, params, callback) {
|
2018-04-30 13:03:44 +03:00
|
|
|
let links = {};
|
|
|
|
let paths = [];
|
2013-08-02 16:48:06 +04:00
|
|
|
|
2016-10-06 17:05:27 +03:00
|
|
|
// Support --test-manifest format for mobile
|
2013-08-02 16:48:06 +04:00
|
|
|
if ("runtests" in testManifest || "excludetests" in testManifest) {
|
|
|
|
callback(testManifest);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-27 00:32:30 +03:00
|
|
|
// For mochitest-chrome and mochitest-browser-chrome harnesses, we
|
2013-08-02 16:48:06 +04:00
|
|
|
// define tests as links[testname] = true.
|
|
|
|
// For mochitest-plain, we define lists as an array of testnames.
|
2018-04-30 13:03:44 +03:00
|
|
|
for (let obj of testManifest.tests) {
|
|
|
|
let path = obj.path;
|
2014-03-18 19:03:51 +04:00
|
|
|
// Note that obj.disabled may be "". We still want to skip in that case.
|
|
|
|
if ("disabled" in obj) {
|
2013-11-07 03:49:41 +04:00
|
|
|
dump("TEST-SKIPPED | " + path + " | " + obj.disabled + "\n");
|
|
|
|
continue;
|
|
|
|
}
|
2018-01-27 00:32:30 +03:00
|
|
|
if (params.testRoot != "tests" && params.testRoot !== undefined) {
|
2018-04-30 13:03:44 +03:00
|
|
|
let name = params.baseurl + "/" + params.testRoot + "/" + path;
|
2018-01-27 00:32:30 +03:00
|
|
|
links[name] = {
|
|
|
|
test: {
|
|
|
|
url: name,
|
|
|
|
expected: obj.expected,
|
|
|
|
"uses-unsafe-cpows": obj["uses-unsafe-cpows"],
|
2019-07-05 12:01:24 +03:00
|
|
|
},
|
2018-01-27 00:32:30 +03:00
|
|
|
};
|
2013-08-02 16:48:06 +04:00
|
|
|
} else {
|
2018-04-30 13:03:44 +03:00
|
|
|
let name = params.testPrefix + path;
|
2018-01-27 00:32:30 +03:00
|
|
|
paths.push({
|
|
|
|
test: {
|
|
|
|
url: name,
|
|
|
|
expected: obj.expected,
|
|
|
|
"uses-unsafe-cpows": obj["uses-unsafe-cpows"],
|
2019-07-05 12:01:24 +03:00
|
|
|
},
|
2018-01-27 00:32:30 +03:00
|
|
|
});
|
2013-08-02 16:48:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (paths.length > 0) {
|
|
|
|
callback(paths);
|
|
|
|
} else {
|
|
|
|
callback(links);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTestManifest(url, params, callback) {
|
2018-04-30 13:03:44 +03:00
|
|
|
let req = new XMLHttpRequest();
|
2013-08-02 16:48:06 +04:00
|
|
|
req.open("GET", url);
|
|
|
|
req.onload = function() {
|
|
|
|
if (req.readyState == 4) {
|
|
|
|
if (req.status == 200) {
|
2014-01-17 21:11:22 +04:00
|
|
|
try {
|
|
|
|
parseTestManifest(JSON.parse(req.responseText), params, callback);
|
|
|
|
} catch (e) {
|
2017-11-07 21:57:33 +03:00
|
|
|
dump(
|
|
|
|
"TEST-UNEXPECTED-FAIL: manifestLibrary.js | error parsing " +
|
|
|
|
url +
|
|
|
|
" (" +
|
|
|
|
e +
|
|
|
|
")\n"
|
|
|
|
);
|
2014-01-17 21:11:22 +04:00
|
|
|
throw e;
|
|
|
|
}
|
2013-08-02 16:48:06 +04:00
|
|
|
} else {
|
2017-11-07 21:57:33 +03:00
|
|
|
dump(
|
|
|
|
"TEST-UNEXPECTED-FAIL: manifestLibrary.js | error loading " +
|
|
|
|
url +
|
|
|
|
" (HTTP " +
|
|
|
|
req.status +
|
|
|
|
")\n"
|
|
|
|
);
|
2013-08-02 16:48:06 +04:00
|
|
|
callback({});
|
|
|
|
}
|
|
|
|
}
|
2018-01-27 00:32:30 +03:00
|
|
|
};
|
2013-08-02 16:48:06 +04:00
|
|
|
req.send();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test Filtering Code
|
2015-03-10 16:55:30 +03:00
|
|
|
// TODO Only used by ipc tests, remove once those are implemented sanely
|
2013-08-02 16:48:06 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
Open the file referenced by runOnly|exclude and use that to compare against
|
|
|
|
testList
|
|
|
|
parameters:
|
|
|
|
filter = json object of runtests | excludetests
|
|
|
|
testList = array of test names to run
|
|
|
|
runOnly = use runtests vs excludetests in case both are defined
|
|
|
|
returns:
|
|
|
|
filtered version of testList
|
|
|
|
*/
|
|
|
|
function filterTests(filter, testList, runOnly) {
|
2018-04-30 13:03:44 +03:00
|
|
|
let filteredTests = [];
|
|
|
|
let runtests = {};
|
|
|
|
let excludetests = {};
|
2013-08-02 16:48:06 +04:00
|
|
|
|
|
|
|
if (filter == null) {
|
|
|
|
return testList;
|
|
|
|
}
|
|
|
|
|
2018-01-27 00:32:30 +03:00
|
|
|
if ("runtests" in filter) {
|
2013-08-02 16:48:06 +04:00
|
|
|
runtests = filter.runtests;
|
|
|
|
}
|
2018-01-27 00:32:30 +03:00
|
|
|
if ("excludetests" in filter) {
|
2013-08-02 16:48:06 +04:00
|
|
|
excludetests = filter.excludetests;
|
|
|
|
}
|
2018-01-27 00:32:30 +03:00
|
|
|
if (!("runtests" in filter) && !("excludetests" in filter)) {
|
|
|
|
if (runOnly == "true") {
|
2013-08-02 16:48:06 +04:00
|
|
|
runtests = filter;
|
|
|
|
} else {
|
|
|
|
excludetests = filter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-30 13:03:44 +03:00
|
|
|
// eslint-disable-next-line no-undef
|
|
|
|
let testRoot = config.testRoot || "tests";
|
2013-08-02 16:48:06 +04:00
|
|
|
// Start with testList, and put everything that's in 'runtests' in
|
|
|
|
// filteredTests.
|
|
|
|
if (Object.keys(runtests).length) {
|
2018-04-30 13:03:44 +03:00
|
|
|
for (let i = 0; i < testList.length; i++) {
|
|
|
|
let testpath;
|
2018-01-27 00:32:30 +03:00
|
|
|
if (testList[i] instanceof Object && "test" in testList[i]) {
|
2018-04-30 13:03:44 +03:00
|
|
|
testpath = testList[i].test.url;
|
2014-10-17 18:01:15 +04:00
|
|
|
} else {
|
2018-04-30 13:03:44 +03:00
|
|
|
testpath = testList[i];
|
2014-10-17 18:01:15 +04:00
|
|
|
}
|
2018-04-30 13:03:44 +03:00
|
|
|
let tmppath = testpath.replace(/^\//, "");
|
|
|
|
for (let f in runtests) {
|
2013-08-02 16:48:06 +04:00
|
|
|
// Remove leading /tests/ if exists
|
2018-04-30 13:03:44 +03:00
|
|
|
let file = f.replace(/^\//, "");
|
2018-01-27 00:32:30 +03:00
|
|
|
file = file.replace(/^tests\//, "");
|
2013-08-02 16:48:06 +04:00
|
|
|
|
|
|
|
// Match directory or filename, testList has <testroot>/<path>
|
|
|
|
if (tmppath.match(testRoot + "/" + file) != null) {
|
|
|
|
filteredTests.push(testpath);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
filteredTests = testList.slice(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Continue with filteredTests, and deselect everything that's in
|
|
|
|
// excludedtests.
|
|
|
|
if (!Object.keys(excludetests).length) {
|
|
|
|
return filteredTests;
|
|
|
|
}
|
|
|
|
|
2018-04-30 13:03:44 +03:00
|
|
|
let refilteredTests = [];
|
|
|
|
for (let i = 0; i < filteredTests.length; i++) {
|
|
|
|
let found = false;
|
|
|
|
let testpath;
|
2018-01-27 00:32:30 +03:00
|
|
|
if (filteredTests[i] instanceof Object && "test" in filteredTests[i]) {
|
2018-04-30 13:03:44 +03:00
|
|
|
testpath = filteredTests[i].test.url;
|
2014-10-17 18:01:15 +04:00
|
|
|
} else {
|
2018-04-30 13:03:44 +03:00
|
|
|
testpath = filteredTests[i];
|
2014-10-17 18:01:15 +04:00
|
|
|
}
|
2018-04-30 13:03:44 +03:00
|
|
|
let tmppath = testpath.replace(/^\//, "");
|
|
|
|
for (let f in excludetests) {
|
2013-08-02 16:48:06 +04:00
|
|
|
// Remove leading /tests/ if exists
|
2018-04-30 13:03:44 +03:00
|
|
|
let file = f.replace(/^\//, "");
|
2018-01-27 00:32:30 +03:00
|
|
|
file = file.replace(/^tests\//, "");
|
2013-08-02 16:48:06 +04:00
|
|
|
|
|
|
|
// Match directory or filename, testList has <testroot>/<path>
|
|
|
|
if (tmppath.match(testRoot + "/" + file) != null) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
refilteredTests.push(testpath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return refilteredTests;
|
|
|
|
}
|