Commit 56eaa15e authored by adoneria's avatar adoneria Committed by Commit Bot

[updater] populate version info from chrome version file.

Uses a template to dynamically generate updater version_info.py.
This is required to install correct updater version during testing.
Also copy over the generated file to test package so that python
can read it as a package and successfully import it.

Bug: 1140211
Change-Id: I10da968690f47fccd35bddb6c5d9f77f89bbce83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2510877Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Commit-Queue: Anjali Doneria <adoneria@google.com>
Cr-Commit-Position: refs/heads/master@{#824940}
parent 9e939314
...@@ -344,6 +344,32 @@ if (is_win || is_mac) { ...@@ -344,6 +344,32 @@ if (is_win || is_mac) {
} }
} }
process_version("version_header_py") {
process_only = true
sources = [ "//chrome/VERSION" ]
extra_args = [
"-e",
"COMPANY_FULLNAME=\"$updater_company_full_name\"",
"-e",
"COMPANY_SHORTNAME=\"$updater_company_short_name\"",
"-e",
"PRODUCT_FULLNAME=\"$updater_product_full_name\"",
"-e",
"COPYRIGHT=\"updater_copyright\"",
"-e",
"MAC_BUNDLE_IDENTIFIER=\"$mac_updater_bundle_identifier\"",
"-e",
"BROWSER_NAME=\"$browser_name\"",
"-e",
"MAC_BROWSER_BUNDLE_IDENTIFIER=\"$mac_browser_bundle_identifier\"",
]
template_file = "test/integration_tests/updater/version_info.py.in"
output = "$target_gen_dir/version_info.py"
}
script_test("updater_integration_tests") { script_test("updater_integration_tests") {
script = "//testing/scripts/run_isolated_script_test.py" script = "//testing/scripts/run_isolated_script_test.py"
...@@ -353,16 +379,20 @@ if (is_win || is_mac) { ...@@ -353,16 +379,20 @@ if (is_win || is_mac) {
")", ")",
"--build-dir", "--build-dir",
"@WrappedPath(" + rebase_path(root_build_dir, root_build_dir) + ")", "@WrappedPath(" + rebase_path(root_build_dir, root_build_dir) + ")",
"--target-gen-dir",
"@WrappedPath(" + rebase_path(target_gen_dir, target_gen_dir) + ")",
] ]
data = [ data = [
"//chrome/updater/run_updater_tests.py", "//chrome/updater/run_updater_tests.py",
"//chrome/updater/test/", "//chrome/updater/test/",
"//third_party/catapult/third_party/typ/", "//third_party/catapult/third_party/typ/",
"$target_gen_dir/version_info.py",
] ]
if (is_win) { if (is_win) {
data_deps = [ data_deps = [
":version_header_py",
"//chrome/updater/win:updater", "//chrome/updater/win:updater",
"//chrome/updater/win/installer", "//chrome/updater/win/installer",
] ]
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
import argparse import argparse
import logging import logging
import os
import shutil
import sys import sys
from test.integration_tests.common import path_finder from test.integration_tests.common import path_finder
...@@ -15,11 +17,14 @@ class Context(object): ...@@ -15,11 +17,14 @@ class Context(object):
def __init__(self, build_dir): def __init__(self, build_dir):
self.build_dir = build_dir self.build_dir = build_dir
def copy_file(source, destination):
shutil.copyfile(source, destination)
def main(): def main():
parser = typ.ArgumentParser() parser = typ.ArgumentParser()
parser.add_argument('--build-dir', parser.add_argument('--build-dir',
help='Specifies chromium build directory.') help='Specifies chromium build directory.')
parser.add_argument('--target-gen-dir')
runner = typ.Runner() runner = typ.Runner()
...@@ -37,6 +42,21 @@ def main(): ...@@ -37,6 +42,21 @@ def main():
level = logging.INFO level = logging.INFO
logging.basicConfig(level=level) logging.basicConfig(level=level)
# copy dynamically generated updater version_info.py from
# target gen directory to
# //chrome/updater/test/integration_tests/updater so that
# it can be imported as a module during test runs.
target_gen_dir_abs_path = os.path.abspath(runner.args.target_gen_dir)
version_file_path = os.path.join(target_gen_dir_abs_path, 'gen',
'chrome', 'updater', 'version_info.py')
if os.path.exists(version_file_path):
dest = os.path.join(path_finder.get_integration_tests_dir(),
'updater', 'version_info.py')
copy_file(version_file_path, dest)
else:
logging.info('File not found: %s' % version_file_path)
return -1
runner.context = Context(runner.args.build_dir) runner.context = Context(runner.args.build_dir)
return runner.run()[0] return runner.run()[0]
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Tests generated updater version details."""
import typ
from test.integration_tests.updater import version_info
class UpdaterVersionInfoTest(typ.TestCase):
def test_get_updater_version(self):
self.assertIsNotNone(version_info.UPDATER_VERSION_STRING)
def test_company_info(self):
(self.assertIsNotNone(version_info.COMPANY_FULLNAME_STRING)
and self.assertIsNotNone(version_info.COMPANY_SHORTNAME_STRING))
def test_product_info(self):
self.assertIsNotNone(version_info.PRODUCT_FULLNAME_STRING)
def test_official_build_str(self):
self.assertIsNotNone(version_info.OFFICIAL_BUILD_STRING)
def test_browser_name_str(self):
self.assertIsNotNone(version_info.BROWSER_NAME_STRING)
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Version Information
UPDATER_VERSION = (@MAJOR@,@MINOR@,@BUILD@,@PATCH@)
UPDATER_VERSION_STRING = "@MAJOR@.@MINOR@.@BUILD@.@PATCH@"
# Branding Information
COMPANY_FULLNAME_STRING = "@COMPANY_FULLNAME@"
COMPANY_SHORTNAME_STRING = "@COMPANY_SHORTNAME@"
PRODUCT_FULLNAME_STRING = "@PRODUCT_FULLNAME@"
OFFICIAL_BUILD_STRING = "@OFFICIAL_BUILD@"
MAC_BUNDLE_IDENTIFIER_STRING = "@MAC_BUNDLE_IDENTIFIER@"
BROWSER_NAME_STRING = "@BROWSER_NAME@"
MAC_BROWSER_BUNDLE_IDENTIFIER_STRING = "@MAC_BROWSER_BUNDLE_IDENTIFIER@"
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