tools_webrtc dir converted to py3 + top level PRESUBMIT script
Bug: webrtc:13607 Change-Id: Ib018e43ea977cc24dd71048e68e3343741f7f31b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249083 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Jeremy Leconte <jleconte@google.com> Commit-Queue: Christoffer Jansson <jansson@google.com> Cr-Commit-Position: refs/heads/main@{#35953}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
b5cba85c2f
commit
4e8a773b4b
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env vpython3
|
||||
|
||||
# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
@ -46,7 +47,6 @@ if os.path.exists(binary_path):
|
||||
========== ENDING OF PATCH ==========
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
DIRECTORY = 'out/coverage'
|
||||
@ -77,89 +77,89 @@ XC_TESTS = [
|
||||
|
||||
|
||||
def FormatIossimTest(test_name, is_xctest=False):
|
||||
args = ['%s/%s.app' % (DIRECTORY, test_name)]
|
||||
if is_xctest:
|
||||
args += ['%s/%s_module.xctest' % (DIRECTORY, test_name)]
|
||||
args = ['%s/%s.app' % (DIRECTORY, test_name)]
|
||||
if is_xctest:
|
||||
args += ['%s/%s_module.xctest' % (DIRECTORY, test_name)]
|
||||
|
||||
return '-c \'%s/iossim %s\'' % (DIRECTORY, ' '.join(args))
|
||||
return '-c \'%s/iossim %s\'' % (DIRECTORY, ' '.join(args))
|
||||
|
||||
|
||||
def GetGNArgs(is_simulator):
|
||||
target_cpu = 'x64' if is_simulator else 'arm64'
|
||||
return ([] + ['target_os="ios"'] + ['target_cpu="%s"' % target_cpu] +
|
||||
['use_clang_coverage=true'] + ['is_component_build=false'] +
|
||||
['dcheck_always_on=true'])
|
||||
target_cpu = 'x64' if is_simulator else 'arm64'
|
||||
return ([] + ['target_os="ios"'] + ['target_cpu="%s"' % target_cpu] +
|
||||
['use_clang_coverage=true'] + ['is_component_build=false'] +
|
||||
['dcheck_always_on=true'])
|
||||
|
||||
|
||||
def GenerateIOSSimulatorCommand():
|
||||
gn_args_string = ' '.join(GetGNArgs(is_simulator=True))
|
||||
gn_cmd = ['gn', 'gen', DIRECTORY, '--args=\'%s\'' % gn_args_string]
|
||||
gn_args_string = ' '.join(GetGNArgs(is_simulator=True))
|
||||
gn_cmd = ['gn', 'gen', DIRECTORY, '--args=\'%s\'' % gn_args_string]
|
||||
|
||||
coverage_cmd = ([sys.executable, 'tools/code_coverage/coverage.py'] +
|
||||
["%s.app" % t for t in XC_TESTS + TESTS] +
|
||||
['-b %s' % DIRECTORY, '-o out/report'] +
|
||||
['-i=\'.*/out/.*|.*/third_party/.*|.*test.*\''] +
|
||||
[FormatIossimTest(t, is_xctest=True) for t in XC_TESTS] +
|
||||
[FormatIossimTest(t, is_xctest=False) for t in TESTS])
|
||||
coverage_cmd = ([sys.executable, 'tools/code_coverage/coverage.py'] +
|
||||
["%s.app" % t for t in XC_TESTS + TESTS] +
|
||||
['-b %s' % DIRECTORY, '-o out/report'] +
|
||||
['-i=\'.*/out/.*|.*/third_party/.*|.*test.*\''] +
|
||||
[FormatIossimTest(t, is_xctest=True) for t in XC_TESTS] +
|
||||
[FormatIossimTest(t, is_xctest=False) for t in TESTS])
|
||||
|
||||
print 'To get code coverage using iOS sim just run following commands:'
|
||||
print ''
|
||||
print ' '.join(gn_cmd)
|
||||
print ''
|
||||
print ' '.join(coverage_cmd)
|
||||
return 0
|
||||
print('To get code coverage using iOS sim just run following commands:')
|
||||
print('')
|
||||
print(' '.join(gn_cmd))
|
||||
print('')
|
||||
print(' '.join(coverage_cmd))
|
||||
return 0
|
||||
|
||||
|
||||
def GenerateIOSDeviceCommand():
|
||||
gn_args_string = ' '.join(GetGNArgs(is_simulator=False))
|
||||
gn_args_string = ' '.join(GetGNArgs(is_simulator=False))
|
||||
|
||||
coverage_report_cmd = (
|
||||
[sys.executable, 'tools/code_coverage/coverage.py'] +
|
||||
['%s.app' % t for t in TESTS] + ['-b %s' % DIRECTORY] +
|
||||
['-o out/report'] + ['-p %s/merged.profdata' % DIRECTORY] +
|
||||
['-i=\'.*/out/.*|.*/third_party/.*|.*test.*\''])
|
||||
coverage_report_cmd = ([sys.executable, 'tools/code_coverage/coverage.py'] +
|
||||
['%s.app' % t for t in TESTS] + ['-b %s' % DIRECTORY] +
|
||||
['-o out/report'] +
|
||||
['-p %s/merged.profdata' % DIRECTORY] +
|
||||
['-i=\'.*/out/.*|.*/third_party/.*|.*test.*\''])
|
||||
|
||||
print 'Computing code coverage for real iOS device is a little bit tedious.'
|
||||
print ''
|
||||
print 'You will need:'
|
||||
print ''
|
||||
print '1. Generate xcode project and open it with Xcode 10+:'
|
||||
print ' gn gen %s --ide=xcode --args=\'%s\'' % (DIRECTORY, gn_args_string)
|
||||
print ' open %s/all.xcworkspace' % DIRECTORY
|
||||
print ''
|
||||
print '2. Execute these Run targets manually with Xcode Run button and '
|
||||
print 'manually save generated coverage.profraw file to %s:' % DIRECTORY
|
||||
print '\n'.join('- %s' % t for t in TESTS)
|
||||
print ''
|
||||
print '3. Execute these Test targets manually with Xcode Test button and '
|
||||
print 'manually save generated coverage.profraw file to %s:' % DIRECTORY
|
||||
print '\n'.join('- %s' % t for t in XC_TESTS)
|
||||
print ''
|
||||
print '4. Merge *.profraw files to *.profdata using llvm-profdata tool:'
|
||||
print(' build/mac_files/Xcode.app/Contents/Developer/Toolchains/' +
|
||||
'XcodeDefault.xctoolchain/usr/bin/llvm-profdata merge ' +
|
||||
'-o %s/merged.profdata ' % DIRECTORY +
|
||||
'-sparse=true %s/*.profraw' % DIRECTORY)
|
||||
print ''
|
||||
print '5. Generate coverage report:'
|
||||
print ' ' + ' '.join(coverage_report_cmd)
|
||||
return 0
|
||||
print('Computing code coverage for real iOS device is a little bit tedious.')
|
||||
print('')
|
||||
print('You will need:')
|
||||
print('')
|
||||
print('1. Generate xcode project and open it with Xcode 10+:')
|
||||
print(' gn gen %s --ide=xcode --args=\'%s\'' % (DIRECTORY, gn_args_string))
|
||||
print(' open %s/all.xcworkspace' % DIRECTORY)
|
||||
print('')
|
||||
print('2. Execute these Run targets manually with Xcode Run button and ')
|
||||
print('manually save generated coverage.profraw file to %s:' % DIRECTORY)
|
||||
print('\n'.join('- %s' % t for t in TESTS))
|
||||
print('')
|
||||
print('3. Execute these Test targets manually with Xcode Test button and ')
|
||||
print('manually save generated coverage.profraw file to %s:' % DIRECTORY)
|
||||
print('\n'.join('- %s' % t for t in XC_TESTS))
|
||||
print('')
|
||||
print('4. Merge *.profraw files to *.profdata using llvm-profdata tool:')
|
||||
print((' build/mac_files/Xcode.app/Contents/Developer/Toolchains/' +
|
||||
'XcodeDefault.xctoolchain/usr/bin/llvm-profdata merge ' +
|
||||
'-o %s/merged.profdata ' % DIRECTORY +
|
||||
'-sparse=true %s/*.profraw' % DIRECTORY))
|
||||
print('')
|
||||
print('5. Generate coverage report:')
|
||||
print(' ' + ' '.join(coverage_report_cmd))
|
||||
return 0
|
||||
|
||||
|
||||
def Main():
|
||||
if len(sys.argv) < 2:
|
||||
print 'Please specify type of coverage:'
|
||||
print ' %s simulator' % sys.argv[0]
|
||||
print ' %s device' % sys.argv[0]
|
||||
elif sys.argv[1] == 'simulator':
|
||||
GenerateIOSSimulatorCommand()
|
||||
elif sys.argv[1] == 'device':
|
||||
GenerateIOSDeviceCommand()
|
||||
else:
|
||||
print 'Unsupported type of coverage'
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print('Please specify type of coverage:')
|
||||
print(' %s simulator' % sys.argv[0])
|
||||
print(' %s device' % sys.argv[0])
|
||||
elif sys.argv[1] == 'simulator':
|
||||
GenerateIOSSimulatorCommand()
|
||||
elif sys.argv[1] == 'device':
|
||||
GenerateIOSDeviceCommand()
|
||||
else:
|
||||
print('Unsupported type of coverage')
|
||||
|
||||
return 0
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(Main())
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user