13 parser = argparse.ArgumentParser(
14 sys.argv[0], description=
"Generate main file for Fuchsia dart test"
16 parser.add_argument(
"--out", help=
"Path to .dart file to generate", required=
True)
17 parser.add_argument(
"--main-dart", help=
"Path to main.dart file to import", required=
True)
18 args = parser.parse_args()
19 out_dir = os.path.dirname(args.out)
20 assert os.path.isfile(os.path.join(os.path.dirname(args.out), args.main_dart))
21 outfile = open(args.out,
'w')
26 outfile.write(
'''// Generated by ''')
27 outfile.write(os.path.basename(__file__))
32// ignore_for_file: avoid_relative_lib_imports
35import 'package:flutter_driver/driver_extension.dart';
38 outfile.write(
"import '%s' as flutter_app_main;\n" % args.main_dart)
42 assert(await (() async {
43 // TODO(awdavies): Use the logger instead.
44 print(
'Overriding app main method because flutter_driver_extendable '
45 'is enabled in the build file');
48 // Enables Flutter Driver VM service extension
50 // This extension
is required
for tests that use package:flutter_driver
51 // to drive applications
from a separate process.
52 enableFlutterDriverExtension();
54 // TODO(awdavies): Use the logger instead.
55 print(
'flutter driver extensions enabled.');
56 //ignore: avoid_catches_without_on_clauses
58 // TODO(awdavies): Use the logger instead.
60 print(
'flutter driver extensions not enabled. $e');
62 // Always
return true so that the
assert succeeds.
65 // Execute the main method of the app under test
66 var res = (flutter_app_main.main
as dynamic)();
67 if (res != null && res
is Future) {
76if __name__ ==
'__main__':
def print(*args, **kwargs)