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: Added firefox download Created March 19, 2018, 8:37 p.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 | « package.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 /* eslint-env node */
19 /* eslint no-console: "off" */
20
21 "use strict";
22
23 const fs = require("fs");
24 const path = require("path");
25
26 const {download, unzipArchive} = require("./download");
27
28 function getChromiumExecutable(chromiumDir)
29 {
30 switch (process.platform)
31 {
32 case "win32":
33 return path.join(chromiumDir, "chrome-win32", "chrome.exe");
34 case "linux":
35 return path.join(chromiumDir, "chrome-linux", "chrome");
36 case "darwin":
37 return path.join(chromiumDir, "chrome-mac", "Chromium.app", "Contents",
38 "MacOS", "Chromium");
39 default:
40 throw new Error("Unexpected platform");
41 }
42 }
43
44 function ensureChromium(chromiumRevision)
45 {
46 let {platform} = process;
47 if (platform == "win32")
48 platform += "-" + process.arch;
49 let buildTypes = {
50 "win32-ia32": ["Win", "chrome-win32.zip"],
51 "win32-x64": ["Win_x64", "chrome-win32.zip"],
52 "linux": ["Linux_x64", "chrome-linux.zip"],
53 "darwin": ["Mac", "chrome-mac.zip"]
54 };
55
56 if (!buildTypes.hasOwnProperty(platform))
57 {
58 let err = new Error(`Cannot run browser tests, ${platform} is unsupported`);
59 return Promise.reject(err);
60 }
61
62 return Promise.resolve().then(() =>
63 {
64 let snapshotsDir = path.join(__dirname, "..", "..", "chromium-snapshots");
65 let chromiumDir = path.join(snapshotsDir,
66 `chromium-${platform}-${chromiumRevision}`);
67 if (fs.existsSync(chromiumDir))
68 return chromiumDir;
69
70 if (!fs.existsSync(path.dirname(chromiumDir)))
71 fs.mkdirSync(path.dirname(chromiumDir));
72
73 let [dir, fileName] = buildTypes[platform];
74 let archive = path.join(snapshotsDir, "download-cache",
75 `${chromiumRevision}-${fileName}`);
76
77 return Promise.resolve()
78 .then(() =>
79 {
80 if (!fs.existsSync(archive))
81 {
82 let url = `https://www.googleapis.com/download/storage/v1/b/chromium-b rowser-snapshots/o/${dir}%2F${chromiumRevision}%2F${fileName}?alt=media`;
83 console.info("Downloading Chromium...");
84 return download(url, archive);
85 }
86 console.info(`Reusing cached archive ${archive}`);
87 })
88 .then(() => unzipArchive(archive, chromiumDir))
89 .then(() => chromiumDir);
90 }).then(dir => getChromiumExecutable(dir));
91 }
92
93 module.exports.ensureChromium = ensureChromium;
OLDNEW
« no previous file with comments | « package.json ('k') | test/runners/chromium_process.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld