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

Delta Between Two Patch Sets: test/all.js

Issue 29866577: Issue 6887 - add Chrome to "npm test" (Closed)
Left Patch Set: Created Aug. 29, 2018, 9:15 a.m.
Right Patch Set: Removed unused this.platform Created Sept. 1, 2018, 3:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/.eslintrc.json ('k') | test/browsers/chromium.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 /* eslint-env mocha */
19
20 "use strict"; 18 "use strict";
21 19
22 const glob = require("glob"); 20 const glob = require("glob");
23 const path = require("path"); 21 const path = require("path");
24 const {exec} = require("child_process"); 22 const {exec} = require("child_process");
25 23
26 for (let browser of glob.sync("./test/browsers/*.js")) 24 for (let browser of glob.sync("./test/browsers/*.js"))
27 { 25 {
28 let module = require(path.resolve(browser)); 26 let module = require(path.resolve(browser));
29 27
30 describe(module.platform, function() 28 describe(module.platform, function()
31 { 29 {
32 this.timeout(0); 30 this.timeout(0);
33 31
34 let driver; 32 before(function()
35 let origin;
36
37 before(() => new Promise((resolve, reject) =>
Sebastian Noack 2018/08/30 02:02:40 I just noticed, getting the driver and setting up
tlucas 2018/09/01 09:38:31 Correct me if i'm wrong - but couldn't it then hap
Sebastian Noack 2018/09/01 10:42:47 My bad, you are right. However, what we can do, an
tlucas 2018/09/01 11:54:23 Done (almost, nodejs complained about an unexpecte
Sebastian Noack 2018/09/01 12:26:33 Right, you have to use parenthesis if you want to
tlucas 2018/09/01 14:46:44 Done.
38 { 33 {
39 exec(`python build.py devenv -t ${module.platform}`, 34 return Promise.all([
40 (error, stdout, stderr) => 35 module.ensureBrowser(),
36 new Promise((resolve, reject) =>
41 { 37 {
42 if (error) 38 exec(`python build.py devenv -t ${module.platform}`,
43 { 39 (error, stdout, stderr) =>
44 console.error(stderr); 40 {
45 reject(error); 41 if (error)
46 } 42 {
47 else resolve(stdout); 43 console.error(stderr);
48 }); 44 reject(error);
49 }).then(() => module.getDriver(path.resolve(`./devenv.${module.platform}`)) 45 }
50 .then(d => 46 else resolve(stdout);
Sebastian Noack 2018/08/29 15:22:12 Nit: The indentation seems a little inconsistent.
tlucas 2018/09/01 09:38:31 Should be resolved now.
47 });
48 })
49 ]).then(([browserBinary]) =>
51 { 50 {
52 driver = d; 51 this.driver = module.getDriver(
53 return driver.wait(() => 52 browserBinary,
54 driver.getAllWindowHandles().then(handles => handles[1]) 53 path.resolve(`./devenv.${module.platform}`)
54 );
55 return this.driver.wait(() =>
56 this.driver.getAllWindowHandles().then(handles => handles[1])
55 ); 57 );
56 }).then(handle => 58 }).then(handle =>
57 driver.switchTo().window(handle) 59 this.driver.switchTo().window(handle)
58 ).then(() => 60 ).then(() =>
59 driver.executeScript("return location.origin;") 61 this.driver.executeScript("return location.origin;")
60 ).then(o => 62 ).then(origin =>
61 { 63 {
62 origin = o; 64 this.origin = origin;
63 })) 65 });
64 ); 66 });
65 67
66 for (let file of glob.sync("./test/wrappers/*.js")) 68 for (let file of glob.sync("./test/wrappers/*.js"))
67 { 69 {
68 let testModule = require(path.resolve(file)); 70 // Reload the module(s) for every browser
69 71 let modulePath = path.resolve(file);
70 it(testModule.title, () => 72 delete require.cache[require.resolve(modulePath)];
71 { 73 require(modulePath);
72 return testModule.it(driver, origin);
73 });
74 } 74 }
75 75
76 after(() => driver.quit()); 76 after(function()
77 {
78 this.driver.quit();
79 });
77 }); 80 });
78 } 81 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld