| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 use: ["script-loader"] | 138 use: ["script-loader"] |
| 139 }] | 139 }] |
| 140 }, | 140 }, |
| 141 resolve: { | 141 resolve: { |
| 142 alias: { | 142 alias: { |
| 143 nodeunit$: nodeunitPath | 143 nodeunit$: nodeunitPath |
| 144 }, | 144 }, |
| 145 modules: [path.resolve(__dirname, "lib")] | 145 modules: [path.resolve(__dirname, "lib")] |
| 146 } | 146 } |
| 147 }).then(bundle => | 147 }).then(bundle => |
| 148 Promise.all(processes.map(currentProcess => | 148 Promise.all( |
| 149 processes.map(currentProcess => |
| 149 runnerDefinitions[currentProcess]( | 150 runnerDefinitions[currentProcess]( |
| 150 bundle, bundleFilename, | 151 bundle, bundleFilename, |
| 151 browserFiles.map( | 152 browserFiles.map( |
| 152 file => path.relative(path.join(__dirname, "test", "browser"), | 153 file => path.relative(path.join(__dirname, "test", "browser"), |
| 153 file).replace(/\.js$/, "") | 154 file).replace(/\.js$/, "") |
| 154 ) | 155 ) |
| 155 ) | 156 ) |
| 156 // We need to convert rejected promise to a resolved one | 157 // We need to convert rejected promise to a resolved one |
| 157 // or the test will not let close the webdriver. | 158 // or the test will not let close the webdriver. |
| 158 .catch(e => e) | 159 .catch(e => e) |
| 159 )).then(results => | 160 )).then(results => |
| 160 { | 161 { |
| 161 let errors = results.filter(e => typeof e != "undefined"); | 162 let errors = results.filter(e => typeof e != "undefined"); |
| 162 if (errors.length) | 163 if (errors.length) |
| 163 return Promise.reject(`Unit test failed: ${errors.join(", ")}`); | 164 throw `Browser unit test failed: ${errors.join(", ")}`; |
| 164 }) | 165 }) |
| 165 ); | 166 ); |
| 166 } | 167 } |
| 167 | 168 |
| 168 if (process.argv.length > 2) | 169 if (process.argv.length > 2) |
| 169 addTestPaths(process.argv.slice(2), true); | 170 addTestPaths(process.argv.slice(2), true); |
| 170 else | 171 else |
| 171 { | 172 { |
| 172 addTestPaths( | 173 addTestPaths( |
| 173 [path.join(__dirname, "test"), path.join(__dirname, "test", "browser")], | 174 [path.join(__dirname, "test"), path.join(__dirname, "test", "browser")], |
| 174 true | 175 true |
| 175 ); | 176 ); |
| 176 } | 177 } |
| 177 | 178 |
| 178 runBrowserTests(runnerProcesses).then(() => | 179 runBrowserTests(runnerProcesses).then(() => |
| 179 { | 180 { |
| 180 if (unitFiles.length) | 181 if (unitFiles.length) |
| 181 nodeunit.reporters.default.run(unitFiles); | 182 nodeunit.reporters.default.run(unitFiles); |
| 182 }).catch(error => | 183 }).catch(error => |
| 183 { | 184 { |
| 184 if (!error) | 185 console.error(error); |
| 185 console.error("Failed running browser tests"); | |
| 186 else | |
| 187 console.error(error); | |
| 188 process.exit(1); | 186 process.exit(1); |
| 189 }); | 187 }); |
| LEFT | RIGHT |