Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Revert "Merge pull request #1562 from erikvold/1042967"
Browse files Browse the repository at this point in the history
This reverts commit 4b3868f, reversing
changes made to 80391cd.
  • Loading branch information
erikvold committed Jul 30, 2014
1 parent 4b3868f commit 74687d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
32 changes: 16 additions & 16 deletions lib/sdk/deprecated/unit-test-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ const removeDups = (array) => array.reduce((result, value) => {
return result;
}, []);

const getSuites = function getSuites({ id, filter }) {
const getSuites = function getSuites({ id }) {
return getAddon(id).then(addon => {
let fileURI = addon.getResourceURI("tests/");
let isPacked = fileURI.scheme == "jar";
let xpiURI = addon.getResourceURI();
let file = xpiURI.QueryInterface(Ci.nsIFileURL).file;
let suites = [];
let addEntry = (entry) => {
let pass = filter(entry) && TEST_REGEX.test(entry);
let pass = TEST_REGEX.test(entry);
if (pass) {
let suite = (isNative ? "./" : "") + RegExp.$2 + RegExp.$3;
suites.push(suite);
Expand Down Expand Up @@ -90,7 +90,7 @@ const getSuites = function getSuites({ id, filter }) {
}
exports.getSuites = getSuites;

const makeFilters = function makeFilters(options) {
const makeFilter = function makeFilter(options) {
// A filter string is {fileNameRegex}[:{testNameRegex}] - ie, a colon
// optionally separates a regex for the test fileName from a regex for the
// testName.
Expand All @@ -104,18 +104,19 @@ const makeFilters = function makeFilters(options) {
filterFileRegex = new RegExp(options.filter.substr(0, colonPos));
filterNameRegex = new RegExp(options.filter.substr(colonPos + 1));
}

return {
fileFilter: (name) => filterFileRegex.test(name),
testFilter: (name) => filterNameRegex.test(name)
}
// This function will first be called with just the filename; if
// it returns true the module will be loaded then the function
// called again with both the filename and the testname.
return (filename, testname) => {
return filterFileRegex.test(filename) &&
((testname && filterNameRegex) ? filterNameRegex.test(testname)
: true);
};
}

return {
fileFilter: () => true,
testFilter: () => true
};
return () => true;
}
exports.makeFilter = makeFilter;

let loader = Loader(module);
const NOT_TESTS = ['setup', 'teardown'];
Expand All @@ -129,9 +130,8 @@ var TestFinder = exports.TestFinder = function TestFinder(options) {

TestFinder.prototype = {
findTests: function findTests() {
let { fileFilter, testFilter } = makeFilters({ filter: this.filter });

return getSuites({ id: id, filter: fileFilter }).then(suites => {
return getSuites({ id: id }).then(suites => {
let filter = makeFilter({ filter: this.filter });
let tests = [];

suites.forEach(suite => {
Expand All @@ -158,7 +158,7 @@ TestFinder.prototype = {

if (this.testInProcess) {
for (let name of Object.keys(suiteModule).sort()) {
if (NOT_TESTS.indexOf(name) === -1 && testFilter(name)) {
if (NOT_TESTS.indexOf(name) === -1 && filter(suite, name)) {
tests.push({
setup: suiteModule.setup,
teardown: suiteModule.teardown,
Expand Down
8 changes: 6 additions & 2 deletions python-lib/cuddlefish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,14 @@ def run(arguments=sys.argv[1:], target_cfg=None, pkg_cfg=None,
"lib", "sdk", "loader", "cuddlefish.js")
loader_modules = [("addon-sdk", "lib", "sdk/loader/cuddlefish", cuddlefish_js_path)]
scan_tests = command == "test"

test_filter_re = None
if scan_tests and options.filter:
test_filter_re = options.filter
if ":" in options.filter:
test_filter_re = options.filter.split(":")[0]
try:
manifest = build_manifest(target_cfg, pkg_cfg, deps, scan_tests,
None, loader_modules,
test_filter_re, loader_modules,
abort_on_missing=options.abort_on_missing)
except ModuleNotFoundError, e:
print str(e)
Expand Down

0 comments on commit 74687d1

Please sign in to comment.