|
| 1 | +#!/usr/bin/env python3 |
| 2 | + |
| 3 | +import argparse |
| 4 | +import subprocess |
| 5 | +import os |
| 6 | +import pathlib |
| 7 | + |
| 8 | +def parse_args() -> argparse.Namespace: |
| 9 | + parser = argparse.ArgumentParser() |
| 10 | + parser.add_argument('-p', '--project', help='The project to stress-test') |
| 11 | + parser.add_argument('-f', '--file-filter', default=None, help='Only stress-test files whose file contains this substring') |
| 12 | + parser.add_argument('-r', '--rewrite-modes', default='none insideOut concurrent', help='Perform the these rewrite modes. (default: %(default)s)') |
| 13 | + parser.add_argument('-o', '--offset-filter', help='If specified, only stress test actions at this offset') |
| 14 | + parser.add_argument('--source-compat-suite', help='Path to the swift-source-compat-suite directory') |
| 15 | + parser.add_argument('--swiftc', required=True, help='Path to the swiftc inside the toolchain to stress-test') |
| 16 | + parser.add_argument('--xcode', help='The Xcode.app whose SDK to use to compile the projects') |
| 17 | + parser.add_argument('--request-durations', default='/tmp/request-durations.json', help='A file where the measured request durations will be saved to') |
| 18 | + return parser.parse_args() |
| 19 | + |
| 20 | +def main(): |
| 21 | + args = parse_args() |
| 22 | + if os.path.exists(args.request_durations): |
| 23 | + os.remove(args.request_durations) |
| 24 | + if not args.xcode: |
| 25 | + args.xcode = subprocess.check_output(["xcode-select", "-p"], encoding='utf-8').strip() |
| 26 | + if not args.source_compat_suite: |
| 27 | + args.source_compat_suite = (pathlib.Path(__file__).parent.parent.parent.parent / "swift-source-compat-suite").resolve() |
| 28 | + print(args.source_compat_suite) |
| 29 | + |
| 30 | + environ = dict(os.environ) |
| 31 | + if args.file_filter: |
| 32 | + environ['SK_STRESS_FILE_FILTER'] = args.file_filter |
| 33 | + environ['SK_STRESS_REWRITE_MODES'] = args.rewrite_modes |
| 34 | + environ['SK_XFAILS_PATH'] = os.path.join(args.source_compat_suite, 'sourcekit-xfails.json') |
| 35 | + environ['DEVELOPER_DIR'] = args.xcode |
| 36 | + environ['CODE_SIGN_IDENTITY'] = '' |
| 37 | + environ['CODE_SIGNING_REQUIRED'] = 'NO' |
| 38 | + environ['ENTITLEMENTS_REQUIRED'] = 'NO' |
| 39 | + environ['ENABLE_BITCODE'] = 'NO' |
| 40 | + environ['INDEX_ENABLE_DATA_STORE'] = 'NO' |
| 41 | + environ['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO' |
| 42 | + environ['SWIFT_TREAT_WARNINGS_AS_ERRORS'] = 'NO' |
| 43 | + environ['SK_STRESS_REQUEST_DURATIONS_FILE'] = args.request_durations |
| 44 | + if args.offset_filter: |
| 45 | + environ['SK_OFFSET_FILTER'] = args.offset_filter |
| 46 | + |
| 47 | + subprocess.call([ |
| 48 | + os.path.join(args.source_compat_suite, 'run_sk_stress_test'), |
| 49 | + '--filter-by-project', args.project, |
| 50 | + '--swiftc', args.swiftc, |
| 51 | + '--skip-tools-clone', |
| 52 | + '--skip-tools-build', |
| 53 | + 'main' |
| 54 | + ], env=environ) |
| 55 | + |
| 56 | +if __name__ == '__main__': |
| 57 | + main() |
0 commit comments