| Index: test/run.js | 
| diff --git a/test/run.js b/test/run.js | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..4991b22cdc86bce4211793803fe667fb4a14ec21 | 
| --- /dev/null | 
| +++ b/test/run.js | 
| @@ -0,0 +1,79 @@ | 
| +/* | 
| 
Sebastian Noack
2018/08/27 19:56:16
FWIW, I think all.js is a slightly better name for
 
tlucas
2018/08/28 08:18:14
Done.
 | 
| + * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| + * Copyright (C) 2006-present eyeo GmbH | 
| + * | 
| + * Adblock Plus is free software: you can redistribute it and/or modify | 
| + * it under the terms of the GNU General Public License version 3 as | 
| + * published by the Free Software Foundation. | 
| + * | 
| + * Adblock Plus is distributed in the hope that it will be useful, | 
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| + * 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/>. | 
| + */ | 
| + | 
| +/* eslint-env mocha */ | 
| + | 
| +"use strict"; | 
| + | 
| +const glob = require("glob"); | 
| +const path = require("path"); | 
| +const {exec} = require("child_process"); | 
| + | 
| +let testFiles = glob.sync("./test/cases/*.js"); | 
| 
Sebastian Noack
2018/08/27 19:56:16
Nit: IMO, the code reads better if we inline this
 
tlucas
2018/08/28 08:18:14
Done.
 | 
| + | 
| +for (let browser of glob.sync("./test/browser/*.js")) | 
| +{ | 
| + let module = require(path.resolve(browser)); | 
| 
Sebastian Noack
2018/08/27 19:56:16
Is path.resolve() necessary here?
 
tlucas
2018/08/28 08:18:14
Well, "./test/browsers/firefox.js" can't be implic
 
Sebastian Noack
2018/08/28 14:44:57
Right, require() expects a path, relative to the c
 | 
| + let buildCommand = `python build.py devenv -t ${module.platform}`; | 
| 
Sebastian Noack
2018/08/27 19:56:16
Nit: Since this variable is only used once, inline
 
tlucas
2018/08/28 08:18:14
Done.
 | 
| + | 
| + | 
| + describe(module.platform, function() | 
| + { | 
| + this.timeout(0); | 
| + | 
| + let driver; | 
| + let origin; | 
| + | 
| + let buildDevenv = new Promise((resolve, reject) => | 
| 
Sebastian Noack
2018/08/27 19:56:16
This should happen within before().
 
tlucas
2018/08/28 08:18:14
Moved it.
To clarify, fmi - doesn't the line below
 
Sebastian Noack
2018/08/28 14:44:58
Nope. This is not a function (that is called). You
 | 
| + { | 
| + exec(buildCommand, (error, stdout, stderr) => | 
| + { | 
| + if (error) reject(stderr); | 
| 
Sebastian Noack
2018/08/27 19:56:15
In case of an error, we might rather want to forwa
 
tlucas
2018/08/28 08:18:14
Done.
 | 
| + else resolve(stdout); | 
| + }); | 
| + }); | 
| + | 
| + before(() => buildDevenv.then(() => | 
| + module.getDriver().then(d => | 
| + { | 
| + driver = d; | 
| + return driver.wait(() => | 
| + driver.getAllWindowHandles().then(handles => handles[1]) | 
| + ); | 
| + }).then(handle => | 
| + driver.switchTo().window(handle) | 
| + ).then(() => | 
| + driver.executeScript("return location.origin;") | 
| + ).then(o => | 
| + { | 
| + origin = o; | 
| + }) | 
| + )); | 
| + | 
| + for (let file of testFiles) | 
| + { | 
| + let testModule = require(path.resolve(file)); | 
| + | 
| + it(testModule.title, () => | 
| 
Sebastian Noack
2018/08/27 19:56:15
I wonder, would it work if we call it() on the top
 
tlucas
2018/08/28 08:18:14
In theory yes - How would you pass "driver" and "o
 
Sebastian Noack
2018/08/28 14:44:58
From looking at other examples using Mocha, it see
 
tlucas
2018/08/29 09:16:53
Thanks for clarifying. But i don't see, how we'd c
 
Sebastian Noack
2018/08/29 15:22:12
Well, it would be less code here, less boilerplate
 
tlucas
2018/09/01 09:38:30
This actually works pretty nicely. After finding o
 | 
| + { | 
| + return testModule.it(driver, origin); | 
| + }); | 
| + } | 
| + | 
| + after(() => driver.quit()); | 
| + }); | 
| +} |