blob: a3b182ff3787ac89b3e3fff9ef6bd0e2719bd109 [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2017 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import os
import stat
import string
import sys
def main():
parser = argparse.ArgumentParser(
description='Generate a script that invokes the Dart tester')
parser.add_argument('--wd',
help='Path to the working directory, relative to that of the invocation file',
required=True)
parser.add_argument('--out',
help='Path to the invocation file to generate',
required=True)
parser.add_argument('--dart',
help='Path to the dart binary, relative to the working directory',
required=True)
parser.add_argument('--snapshot',
help='Path to snapshot of the the test runner, relative to the working directory',
required=True)
parser.add_argument('--sdk-root',
help='Path to the SDK platform files, relative to the working directory',
required=True)
parser.add_argument('--tests',
help='Path to test-to-precompiled-kernel file list, relative to the working directory',
required=True)
parser.add_argument('--dot-packages',
help='Path to the .packages file, relative to the working directory',
required=True)
parser.add_argument('--flutter-shell',
help='Path to the Flutter shell, relative to the working directory',
required=True)
parser.add_argument('--icudtl',
help='Path to the ICU data file, relative to the working directory',
required=True)
args = parser.parse_args()
test_file = args.out
test_path = os.path.dirname(test_file)
if not os.path.exists(test_path):
os.makedirs(test_path)
script_template = string.Template('''#!/bin/bash
# DO NOT EDIT
# This script is generated by:
# //topaz/runtime/dart/gen_flutter_test_invocation.py
# See: //topaz/runtime/dart/flutter_test.gni
cd "$$(dirname $$0)/$wd"
$dart $snapshot \\
--packages=$dot_packages \\
--shell=$flutter_shell \\
--tests=$tests \\
--sdk-root=$sdk_root \\
--icudtl=$icudtl \\
"$$@"
''')
with open(test_file, 'w') as file:
file.write(script_template.substitute(args.__dict__))
permissions = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP |
stat.S_IROTH)
os.chmod(test_file, permissions)
if __name__ == '__main__':
sys.exit(main())