Fix running unit tests on Win and Mac
Change-Id: Ie87490a21cc0af5188d31a1a89c567895f925372
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1908568
Reviewed-by: Jan Scheffler <janscheffler@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Auto-Submit: Yang Guo <yangguo@chromium.org>
diff --git a/DEPS b/DEPS
index 8eb146d..d41bf73 100644
--- a/DEPS
+++ b/DEPS
@@ -23,7 +23,11 @@
# Chromium build number for unit tests. It should be regularly updated to
# the content of https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/LAST_CHANGE
- 'chromium_build': '709754',
+ 'chromium_linux': '714183',
+ # the content of https://commondatastorage.googleapis.com/chromium-browser-snapshots/Win_x64/LAST_CHANGE
+ 'chromium_win': '714183',
+ # the content of https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/LAST_CHANGE
+ 'chromium_mac': '714182',
}
# Only these hosts are allowed for dependencies in this DEPS file.
@@ -174,18 +178,42 @@
'-s', 'devtools-frontend/buildtools/linux64/clang-format.sha1',
],
},
-
# Pull chromium from common storage
{
- 'name': 'chromium_linux',
+ 'name': 'download_chromium_win',
+ 'pattern': '.',
+ 'condition': 'host_os == "win"',
+ 'action': [ 'python',
+ 'devtools-frontend/scripts/deps/download_chromium.py',
+ 'https://commondatastorage.googleapis.com/chromium-browser-snapshots/Win_x64/' + Var('chromium_win') + '/chrome-win.zip',
+ 'devtools-frontend/third_party/chrome',
+ 'chrome-win/chrome.exe',
+ Var('chromium_win'),
+ ],
+ },
+ {
+ 'name': 'download_chromium_mac',
+ 'pattern': '.',
+ 'condition': 'host_os == "mac"',
+ 'action': [ 'python',
+ 'devtools-frontend/scripts/deps/download_chromium.py',
+ 'https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/' + Var('chromium_mac') + '/chrome-mac.zip',
+ 'devtools-frontend/third_party/chrome',
+ 'chrome-mac/Chromium.app/Contents',
+ Var('chromium_mac'),
+ ],
+ },
+ {
+ 'name': 'download_chromium_linux',
'pattern': '.',
'condition': 'host_os == "linux"',
'action': [ 'python',
'devtools-frontend/scripts/deps/download_chromium.py',
- 'https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/' + Var('chromium_build') + '/chrome-linux.zip',
+ 'https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/' + Var('chromium_linux') + '/chrome-linux.zip',
'devtools-frontend/third_party/chrome',
'chrome-linux/chrome',
- Var('chromium_build'),
+ Var('chromium_linux'),
],
},
+
]
diff --git a/scripts/deps/download_chromium.py b/scripts/deps/download_chromium.py
index 5c8b7e5..0c7364c 100644
--- a/scripts/deps/download_chromium.py
+++ b/scripts/deps/download_chromium.py
@@ -43,7 +43,13 @@
filehandle, headers = urllib.urlretrieve(options.url)
zip_file = zipfile.ZipFile(filehandle, 'r')
zip_file.extractall(path=options.target)
- os.chmod(EXPECTED_BINARY, 0o555)
+ # Fix permissions. Do this recursively is necessary for MacOS bundles.
+ if os.path.isfile(EXPECTED_BINARY):
+ os.chmod(EXPECTED_BINARY, 0o555)
+ else:
+ for root, dirs, files in os.walk(EXPECTED_BINARY):
+ for f in files:
+ os.chmod(os.path.join(root, f), 0o555)
with open(BUILD_NUMBER_FILE, 'w') as file:
file.write(options.build_number)
diff --git a/scripts/test/run_unittests.py b/scripts/test/run_unittests.py
index 6aa0cc2..2747c0c 100755
--- a/scripts/test/run_unittests.py
+++ b/scripts/test/run_unittests.py
@@ -8,6 +8,7 @@
"""
import os
+import platform
import re
import subprocess
import sys
@@ -38,8 +39,8 @@
karma_errors_found = False
karmaconfig_path = os.path.join(devtools_path, 'karma.conf.js')
exec_command = [devtools_paths.node_path(), devtools_paths.karma_path(), 'start', to_platform_path_exact(karmaconfig_path)]
-
- env = {'NODE_PATH': devtools_paths.node_modules_path()}
+ env = os.environ.copy()
+ env['NODE_PATH'] = devtools_paths.node_path()
if (chrome_binary is not None):
env['CHROME_BIN'] = chrome_binary
@@ -58,10 +59,15 @@
devtools_path = devtools_paths.devtools_root_path()
is_cygwin = sys.platform == 'cygwin'
chrome_binary = None
-DOWNLOADED_CHROME_BINARY = os.path.abspath(os.path.join(devtools_path, 'third_party', 'chrome', 'chrome-linux', 'chrome'))
+downloaded_chrome_binary = os.path.abspath(os.path.join(
+ *{
+ 'Linux': (devtools_path, 'third_party', 'chrome', 'chrome-linux', 'chrome'),
+ 'Darwin': (devtools_path, 'third_party', 'chrome', 'chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium'),
+ 'Windows': (devtools_path, 'third_party', 'chrome', 'chrome-win', 'chrome.exe'),
+ }[platform.system()]))
-if check_chrome_binary(DOWNLOADED_CHROME_BINARY):
- chrome_binary = DOWNLOADED_CHROME_BINARY
+if check_chrome_binary(downloaded_chrome_binary):
+ chrome_binary = downloaded_chrome_binary
if len(sys.argv) >= 2:
chrome_binary = re.sub(r'^\-\-chrome-binary=(.*)', '\\1', sys.argv[1])