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

Side by Side Diff: test/runners/chromium_download.js

Issue 29720661: Issue 6391 - Allow running the browser unit tests with Firefox (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Review comments addressed. Created May 18, 2018, 12:02 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/runners/.eslintrc.json ('k') | test/runners/chromium_process.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 "use strict";
19
20 const fs = require("fs");
21 const path = require("path");
22
23 const {download, unzipArchive} = require("./download");
24
25 function getChromiumExecutable(chromiumDir)
26 {
27 switch (process.platform)
28 {
29 case "win32":
30 return path.join(chromiumDir, "chrome-win32", "chrome.exe");
31 case "linux":
32 return path.join(chromiumDir, "chrome-linux", "chrome");
33 case "darwin":
34 return path.join(chromiumDir, "chrome-mac", "Chromium.app", "Contents",
35 "MacOS", "Chromium");
36 default:
37 throw new Error("Unexpected platform");
38 }
39 }
40
41 function ensureChromium(chromiumRevision)
42 {
43 let {platform} = process;
44 if (platform == "win32")
45 platform += "-" + process.arch;
46 let buildTypes = {
47 "win32-ia32": ["Win", "chrome-win32.zip"],
48 "win32-x64": ["Win_x64", "chrome-win32.zip"],
49 "linux": ["Linux_x64", "chrome-linux.zip"],
50 "darwin": ["Mac", "chrome-mac.zip"]
51 };
52
53 if (!buildTypes.hasOwnProperty(platform))
54 {
55 let err = new Error(`Cannot run browser tests, ${platform} is unsupported`);
56 return Promise.reject(err);
57 }
58
59 return Promise.resolve().then(() =>
60 {
61 let snapshotsDir = path.join(__dirname, "..", "..", "chromium-snapshots");
62 let chromiumDir = path.join(snapshotsDir,
63 `chromium-${platform}-${chromiumRevision}`);
64 if (fs.existsSync(chromiumDir))
65 return chromiumDir;
66
67 if (!fs.existsSync(path.dirname(chromiumDir)))
68 fs.mkdirSync(path.dirname(chromiumDir));
69
70 let [dir, fileName] = buildTypes[platform];
71 let archive = path.join(snapshotsDir, "download-cache",
72 `${chromiumRevision}-${fileName}`);
73
74 return Promise.resolve()
75 .then(() =>
76 {
77 if (!fs.existsSync(archive))
78 {
79 let url = `https://www.googleapis.com/download/storage/v1/b/chromium-b rowser-snapshots/o/${dir}%2F${chromiumRevision}%2F${fileName}?alt=media`;
80 console.info("Downloading Chromium...");
81 return download(url, archive);
82 }
83 console.info(`Reusing cached archive ${archive}`);
84 })
85 .then(() => unzipArchive(archive, chromiumDir))
86 .then(() => chromiumDir);
87 }).then(dir => getChromiumExecutable(dir));
88 }
89
90 module.exports.ensureChromium = ensureChromium;
OLDNEW
« no previous file with comments | « test/runners/.eslintrc.json ('k') | test/runners/chromium_process.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld