| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 /* globals nodeunit */ | 20 /* globals nodeunit */ |
| 21 require("nodeunit"); | 21 require("nodeunit"); |
| 22 | 22 |
| 23 let browserTestModuleContext = require.context("./", true, /^[^_].*\.js$/); | 23 function runTests(moduleNames) |
| 24 | |
| 25 function runTests(browserTestModules) | |
|
Wladimir Palant
2017/08/17 10:05:38
Nit: Frankly, I'm a bit annoyed by the frequent re
kzar
2017/08/17 12:40:22
Done.
| |
| 26 { | 24 { |
| 27 function bold(str) | 25 function bold(str) |
| 28 { | 26 { |
| 29 return "\u001B[1m" + str + "\u001B[22m"; | 27 return "\u001B[1m" + str + "\u001B[22m"; |
| 30 } | 28 } |
| 31 | 29 |
| 32 function ok(str) | 30 function ok(str) |
| 33 { | 31 { |
| 34 return "\u001B[32m" + str + "\u001B[39m"; | 32 return "\u001B[32m" + str + "\u001B[39m"; |
| 35 } | 33 } |
| 36 | 34 |
| 37 function error(str) | 35 function error(str) |
| 38 { | 36 { |
| 39 return "\u001B[31m" + str + "\u001B[39m"; | 37 return "\u001B[31m" + str + "\u001B[39m"; |
| 40 } | 38 } |
| 41 | 39 |
| 42 if (browserTestModules.length == 0) | 40 let tests = {}; |
| 43 browserTestModules = browserTestModuleContext.keys(); | 41 for (let module of moduleNames) |
|
Wladimir Palant
2017/08/17 10:05:38
Why do we need this? test_runner.js is where we ar
kzar
2017/08/17 12:40:22
Done.
| |
| 44 | 42 tests[module] = nodeunit.testCase(require("./" + module + ".js")); |
| 45 // We don't know which browser test modules are required at the point we | |
| 46 // bundle everything together using webpack, so we bundle them all but | |
| 47 // only use the necessary ones here. | |
|
Wladimir Palant
2017/08/17 10:05:38
Why is this comment here? That's not where the bun
kzar
2017/08/17 12:40:22
Done.
| |
| 48 let testModules = {}; | |
|
Wladimir Palant
2017/08/17 10:05:38
Nit: tests should be unambiguous enough as a name
kzar
2017/08/17 12:40:21
Done.
| |
| 49 for (let module of browserTestModules) | |
| 50 testModules[module] = nodeunit.testCase(browserTestModuleContext(module)); | |
|
Wladimir Palant
2017/08/17 10:05:38
As mentioned in comment on chrome_process.js, requ
kzar
2017/08/17 12:40:22
Done.
| |
| 51 | 43 |
| 52 return new Promise((resolve, reject) => | 44 return new Promise((resolve, reject) => |
| 53 { | 45 { |
| 54 nodeunit.runModules(testModules, { | 46 nodeunit.runModules(tests, { |
| 55 moduleStart(name) | 47 moduleStart(name) |
| 56 { | 48 { |
| 57 console.log(bold(name)); | 49 console.log(bold(name)); |
| 58 }, | 50 }, |
| 59 testDone(name, assertions) | 51 testDone(name, assertions) |
| 60 { | 52 { |
| 61 let errors = assertions.filter(assertion => assertion.failed()) | 53 let errors = assertions.filter(assertion => assertion.failed()) |
| 62 .map(assertion => assertion.error); | 54 .map(assertion => assertion.error); |
| 63 | 55 |
| 64 if (errors.length == 0) | 56 if (errors.length == 0) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 95 ); | 87 ); |
| 96 } | 88 } |
| 97 | 89 |
| 98 resolve(); | 90 resolve(); |
| 99 } | 91 } |
| 100 }); | 92 }); |
| 101 }); | 93 }); |
| 102 } | 94 } |
| 103 | 95 |
| 104 module.exports = runTests; | 96 module.exports = runTests; |
| LEFT | RIGHT |