Commit 11d47c81 authored by Yuke Liao's avatar Yuke Liao Committed by Commit Bot

[lacros] Support user provided ash-chrome

This CL supports user provided ash-chrome to make it easy to test
crosapi tests that depend on changes made in ash-chrome side.

Bug: 1129223
Change-Id: I1be43c760222ed25f0423e7ca05c5e6965441ae0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2415220
Commit-Queue: Yuke Liao <liaoyuke@chromium.org>
Reviewed-by: default avatarSven Zheng <svenzheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808633}
parent 1d960fb8
...@@ -274,12 +274,16 @@ def _RunTestWithAshChrome(args, forward_args): ...@@ -274,12 +274,16 @@ def _RunTestWithAshChrome(args, forward_args):
args (dict): Args for this script. args (dict): Args for this script.
forward_args (dict): Args to be forwarded to the test command. forward_args (dict): Args to be forwarded to the test command.
""" """
ash_chrome_version = args.ash_chrome_version or _GetLatestVersionOfAshChrome() if args.ash_chrome_path:
_DownloadAshChromeIfNecessary(ash_chrome_version) ash_chrome_file = args.ash_chrome_path
logging.info('Ash-chrome version: %s', ash_chrome_version) else:
ash_chrome_version = (args.ash_chrome_version
ash_chrome_file = os.path.join(_GetAshChromeDirPath(ash_chrome_version), or _GetLatestVersionOfAshChrome())
'chrome') _DownloadAshChromeIfNecessary(ash_chrome_version)
logging.info('Ash-chrome version: %s', ash_chrome_version)
ash_chrome_file = os.path.join(_GetAshChromeDirPath(ash_chrome_version),
'chrome')
try: try:
# Starts Ash-Chrome. # Starts Ash-Chrome.
tmp_xdg_dir_name = tempfile.mkdtemp() tmp_xdg_dir_name = tempfile.mkdtemp()
...@@ -451,13 +455,18 @@ def Main(): ...@@ -451,13 +455,18 @@ def Main():
'"./url_unittests". Any argument unknown to this test runner script will ' '"./url_unittests". Any argument unknown to this test runner script will '
'be forwarded to the command, for example: "--gtest_filter=Suite.Test"') 'be forwarded to the command, for example: "--gtest_filter=Suite.Test"')
test_parser.add_argument( version_group = test_parser.add_mutually_exclusive_group()
'-a', version_group.add_argument(
'--ash-chrome-version', '--ash-chrome-version',
type=str, type=str,
help='Version of ash_chrome to use for testing, for example: "793554", ' help='Version of an prebuilt ash-chrome to use for testing, for example: '
'and the version corresponds to the commit position of commits on the ' '"793554", and the version corresponds to the commit position of commits '
'master branch. If not specified, will use the latest version available') 'on the main branch. If not specified, will use the latest version '
'available')
version_group.add_argument(
'--ash-chrome-path',
type=str,
help='Path to an locally built ash-chrome to use for testing.')
args = arg_parser.parse_known_args() args = arg_parser.parse_known_args()
return args[0].func(args[0], args[1]) return args[0].func(args[0], args[1])
......
...@@ -158,6 +158,30 @@ class TestRunnerTest(unittest.TestCase): ...@@ -158,6 +158,30 @@ class TestRunnerTest(unittest.TestCase):
mock_download.assert_called_with('793554') mock_download.assert_called_with('793554')
self.assertEqual(2, mock_popen.call_count) self.assertEqual(2, mock_popen.call_count)
@mock.patch.object(os,
'listdir',
return_value=['wayland-0', 'wayland-0.lock'])
@mock.patch.object(os.path, 'exists', return_value=True)
@mock.patch.object(os.path, 'isfile', return_value=True)
@mock.patch.object(test_runner, '_GetLatestVersionOfAshChrome')
@mock.patch.object(test_runner, '_DownloadAshChromeIfNecessary')
@mock.patch.object(subprocess, 'Popen', return_value=mock.Mock())
# Tests that when an ash-chrome path is specified, the test runner doesn't try
# to download prebuilt ash-chrome.
def test_specify_ash_chrome_path(self, mock_popen, mock_download,
mock_get_latest_version, *_):
args = [
'script_name',
'test',
'browser_tests',
'--ash-chrome-path',
'/ash/chrome',
]
with mock.patch.object(sys, 'argv', args):
test_runner.Main()
self.assertFalse(mock_get_latest_version.called)
self.assertFalse(mock_download.called)
@mock.patch.object(os.path, 'isfile', return_value=True) @mock.patch.object(os.path, 'isfile', return_value=True)
@mock.patch.object(test_runner, '_DownloadAshChromeIfNecessary') @mock.patch.object(test_runner, '_DownloadAshChromeIfNecessary')
@mock.patch.object(subprocess, 'Popen', return_value=mock.Mock()) @mock.patch.object(subprocess, 'Popen', return_value=mock.Mock())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment