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

Unified Diff: test_runner.js

Issue 29354864: Issue 4223 - Migrate some more of adblockplustests (Closed)
Patch Set: Allow tests to be run from different directory Created Oct. 3, 2016, 6:01 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
« no previous file with comments | « test/subscriptionClasses.js ('k') | test_wrapper.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test_runner.js
diff --git a/lib/coreUtils.js b/test_runner.js
similarity index 50%
copy from lib/coreUtils.js
copy to test_runner.js
index b9e9a2f050252ae0ac6d4d7d1a1919ff812c1d7a..3d1455d50cbd3d6ed612cc9c1610e6602b3ac0e7 100644
--- a/lib/coreUtils.js
+++ b/test_runner.js
@@ -15,20 +15,29 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-function desc(properties)
-{
- let descriptor = {};
- let keys = Object.keys(properties);
-
- for (let key of keys)
- descriptor[key] = Object.getOwnPropertyDescriptor(properties, key);
+"use strict";
- return descriptor;
-}
-exports.desc = desc;
+let fs = require("fs");
+let path = require("path");
+let process = require("process");
+let nodeunit = require("nodeunit");
-function extend(cls, properties)
+let files = [];
+function addTestPaths(testPaths, depth)
{
- return Object.create(cls.prototype, desc(properties));
+ if (depth < 1)
+ return;
+
+ for (let testPath of testPaths)
+ {
+ let stat = fs.statSync(testPath);
+ if (stat.isDirectory())
+ addTestPaths(fs.readdirSync(testPath).map(file => path.join(testPath, file)),
+ depth -1);
+ else if (path.extname(testPath) && path.basename(testPath) != "common.js")
+ files.push(testPath);
+ }
}
-exports.extend = extend;
+addTestPaths(process.argv.length > 2 ? process.argv.slice(2) : [path.join(__dirname, "test")], 2);
+
+nodeunit.reporters.default.run(files);
« no previous file with comments | « test/subscriptionClasses.js ('k') | test_wrapper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld