Support running tests with automate-git.py --run-tests (issue #2435)

This commit is contained in:
Marshall Greenblatt 2018-05-14 13:41:22 +03:00
parent d1d4f7a3ef
commit 67708d07f2
1 changed files with 117 additions and 26 deletions

View File

@ -480,6 +480,25 @@ def get_chromium_target_version(os='win', channel='canary', target_distance=0):
return target_version return target_version
def get_build_directory_name(is_debug):
build_dir = ('Debug' if is_debug else 'Release') + '_'
if use_gn:
# CEF uses a consistent directory naming scheme for GN via
# GetAllPlatformConfigs in tools/gn_args.py.
if options.x64build:
build_dir += 'GN_x64'
elif options.armbuild:
build_dir += 'GN_arm'
else:
build_dir += 'GN_x86'
else:
# GYP outputs both x86 and x64 builds to the same directory on Linux and
# Mac OS X. On Windows it suffixes the directory name for x64 builds.
if platform == 'windows' and options.x64build:
build_dir += 'x64'
return build_dir
## ##
# Program entry point. # Program entry point.
## ##
@ -628,7 +647,7 @@ parser.add_option(
action='store_true', action='store_true',
dest='buildtests', dest='buildtests',
default=False, default=False,
help='Also build the ceftests target.') help='Also build the test target specified via --test-target.')
parser.add_option( parser.add_option(
'--no-debug-build', '--no-debug-build',
action='store_true', action='store_true',
@ -647,6 +666,12 @@ parser.add_option(
dest='verbosebuild', dest='verbosebuild',
default=False, default=False,
help='Show all command lines while building.') help='Show all command lines while building.')
parser.add_option(
'--build-failure-limit',
dest='buildfailurelimit',
default=1,
type="int",
help='Keep going until N jobs fail.')
parser.add_option('--build-log-file', parser.add_option('--build-log-file',
action='store_true', dest='buildlogfile', default=False, action='store_true', dest='buildlogfile', default=False,
help='Write build logs to file. The file will be named '+\ help='Write build logs to file. The file will be named '+\
@ -665,6 +690,41 @@ parser.add_option(
default=False, default=False,
help='Create an ARM build.') help='Create an ARM build.')
# Test-related options.
parser.add_option(
'--run-tests',
action='store_true',
dest='runtests',
default=False,
help='Run the ceftests target.')
parser.add_option(
'--no-debug-tests',
action='store_true',
dest='nodebugtests',
default=False,
help="Don't run debug build tests.")
parser.add_option(
'--no-release-tests',
action='store_true',
dest='noreleasetests',
default=False,
help="Don't run release build tests.")
parser.add_option(
'--test-target',
dest='testtarget',
default='ceftests',
help='Test target name to build (defaults to "ceftests").')
parser.add_option(
'--test-prefix',
dest='testprefix',
default='',
help='Prefix for running the test executable (e.g. `xvfb-run` on Linux).')
parser.add_option(
'--test-args',
dest='testargs',
default='',
help='Arguments that will be passed to the test executable.')
# Distribution-related options. # Distribution-related options.
parser.add_option( parser.add_option(
'--force-distrib', '--force-distrib',
@ -750,6 +810,9 @@ if options.noupdate:
options.nochromiumupdate = True options.nochromiumupdate = True
options.nodepottoolsupdate = True options.nodepottoolsupdate = True
if options.runtests:
options.buildtests = True
if (options.nochromiumupdate and options.forceupdate) or \ if (options.nochromiumupdate and options.forceupdate) or \
(options.nocefupdate and options.forceupdate) or \ (options.nocefupdate and options.forceupdate) or \
(options.nobuild and options.forcebuild) or \ (options.nobuild and options.forcebuild) or \
@ -773,6 +836,11 @@ if options.x64build and options.armbuild:
parser.print_help(sys.stderr) parser.print_help(sys.stderr)
sys.exit() sys.exit()
if (options.buildtests or options.runtests) and len(options.testtarget) == 0:
print "A test target must be specified via --test-target."
parser.print_help(sys.stderr)
sys.exit()
# Operating system. # Operating system.
if options.dryrun and options.dryrunplatform is not None: if options.dryrun and options.dryrunplatform is not None:
platform = options.dryrunplatform platform = options.dryrunplatform
@ -1261,34 +1329,21 @@ if not options.nobuild and (chromium_checkout_changed or \
run(path, cef_src_dir, depot_tools_dir) run(path, cef_src_dir, depot_tools_dir)
# Build using Ninja. # Build using Ninja.
command = 'ninja -C ' command = 'ninja '
if options.verbosebuild: if options.verbosebuild:
command = 'ninja -v -C ' command += '-v '
if options.buildfailurelimit != 1:
command += '-k %d ' % options.buildfailurelimit
command += '-C '
target = ' ' + options.buildtarget target = ' ' + options.buildtarget
if options.buildtests: if options.buildtests:
target = target + ' ceftests' target += ' ' + options.testtarget
if platform == 'linux': if platform == 'linux':
target = target + ' chrome_sandbox' target += ' chrome_sandbox'
build_dir_suffix = ''
if use_gn:
# CEF uses a consistent directory naming scheme for GN via
# GetAllPlatformConfigs in tools/gn_args.py.
if options.x64build:
build_dir_suffix = '_GN_x64'
elif options.armbuild:
build_dir_suffix = '_GN_arm'
else:
build_dir_suffix = '_GN_x86'
else:
# GYP outputs both x86 and x64 builds to the same directory on Linux and
# Mac OS X. On Windows it suffixes the directory name for x64 builds.
if platform == 'windows' and options.x64build:
build_dir_suffix = '_x64'
# Make a CEF Debug build. # Make a CEF Debug build.
if not options.nodebugbuild: if not options.nodebugbuild:
build_path = os.path.join('out', 'Debug' + build_dir_suffix) build_path = os.path.join('out', get_build_directory_name(True))
if use_gn: if use_gn:
args_path = os.path.join(chromium_src_dir, build_path, 'args.gn') args_path = os.path.join(chromium_src_dir, build_path, 'args.gn')
msg(args_path + ' contents:\n' + read_file(args_path)) msg(args_path + ' contents:\n' + read_file(args_path))
@ -1299,7 +1354,7 @@ if not options.nobuild and (chromium_checkout_changed or \
if use_gn and platform == 'windows': if use_gn and platform == 'windows':
# Make the separate cef_sandbox.lib build when GN is_official_build=true. # Make the separate cef_sandbox.lib build when GN is_official_build=true.
build_path = os.path.join('out', 'Debug' + build_dir_suffix + '_sandbox') build_path += '_sandbox'
if os.path.exists(os.path.join(chromium_src_dir, build_path)): if os.path.exists(os.path.join(chromium_src_dir, build_path)):
args_path = os.path.join(chromium_src_dir, build_path, 'args.gn') args_path = os.path.join(chromium_src_dir, build_path, 'args.gn')
msg(args_path + ' contents:\n' + read_file(args_path)) msg(args_path + ' contents:\n' + read_file(args_path))
@ -1310,7 +1365,7 @@ if not options.nobuild and (chromium_checkout_changed or \
# Make a CEF Release build. # Make a CEF Release build.
if not options.noreleasebuild: if not options.noreleasebuild:
build_path = os.path.join('out', 'Release' + build_dir_suffix) build_path = os.path.join('out', get_build_directory_name(False))
if use_gn: if use_gn:
args_path = os.path.join(chromium_src_dir, build_path, 'args.gn') args_path = os.path.join(chromium_src_dir, build_path, 'args.gn')
msg(args_path + ' contents:\n' + read_file(args_path)) msg(args_path + ' contents:\n' + read_file(args_path))
@ -1321,8 +1376,7 @@ if not options.nobuild and (chromium_checkout_changed or \
if use_gn and platform == 'windows': if use_gn and platform == 'windows':
# Make the separate cef_sandbox.lib build when GN is_official_build=true. # Make the separate cef_sandbox.lib build when GN is_official_build=true.
build_path = os.path.join('out', build_path += '_sandbox'
'Release' + build_dir_suffix + '_sandbox')
if os.path.exists(os.path.join(chromium_src_dir, build_path)): if os.path.exists(os.path.join(chromium_src_dir, build_path)):
args_path = os.path.join(chromium_src_dir, build_path, 'args.gn') args_path = os.path.join(chromium_src_dir, build_path, 'args.gn')
msg(args_path + ' contents:\n' + read_file(args_path)) msg(args_path + ' contents:\n' + read_file(args_path))
@ -1335,6 +1389,43 @@ elif not options.nobuild:
msg('Not building. The source hashes have not changed and ' + msg('Not building. The source hashes have not changed and ' +
'the output folder "%s" already exists' % (out_src_dir)) 'the output folder "%s" already exists' % (out_src_dir))
##
# Run CEF tests.
##
if options.runtests:
if platform == 'windows':
test_exe = '%s.exe' % options.testtarget
elif platform == 'macosx':
test_exe = '%s.app/Contents/MacOS/%s' % (options.testtarget,
options.testtarget)
elif platform == 'linux':
test_exe = options.testtarget
test_prefix = options.testprefix
if len(test_prefix) > 0:
test_prefix += ' '
test_args = options.testargs
if len(test_args) > 0:
test_args = ' ' + test_args
if not options.nodebugtests:
build_path = os.path.join(out_src_dir, get_build_directory_name(True))
test_path = os.path.join(build_path, test_exe)
if os.path.exists(test_path):
run(test_prefix + test_exe + test_args, build_path, depot_tools_dir)
else:
msg('Not running debug tests. Missing executable: %s' % test_path)
if not options.noreleasetests:
build_path = os.path.join(out_src_dir, get_build_directory_name(False))
test_path = os.path.join(build_path, test_exe)
if os.path.exists(test_path):
run(test_prefix + test_exe + test_args, build_path, depot_tools_dir)
else:
msg('Not running release tests. Missing executable: %s' % test_path)
## ##
# Create the CEF binary distribution. # Create the CEF binary distribution.
## ##