forked from Rexios80/packages_flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.dart
121 lines (107 loc) · 3.41 KB
/
test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// ignore_for_file: avoid_print
////////////////////////////////////////////////////////////////////////////////
/// Script for executing the Pigeon tests
///
/// usage: dart run tool/test.dart
////////////////////////////////////////////////////////////////////////////////
library;
import 'dart:io' show Platform, exit;
import 'dart:math';
import 'package:args/args.dart';
import 'shared/test_runner.dart';
import 'shared/test_suites.dart';
const String _testFlag = 'test';
const String _noGen = 'no-generation';
const String _listFlag = 'list';
const String _format = 'format';
Future<void> main(List<String> args) async {
final ArgParser parser = ArgParser()
..addMultiOption(_testFlag, abbr: 't', help: 'Only run specified tests.')
..addFlag(_noGen,
abbr: 'g', help: 'Skips the generation step.', negatable: false)
..addFlag(_format,
abbr: 'f', help: 'Formats generated test files before running tests.')
..addFlag(_listFlag,
negatable: false, abbr: 'l', help: 'List available tests.')
..addFlag('help',
negatable: false, abbr: 'h', help: 'Print this reference.');
final ArgResults argResults = parser.parse(args);
List<String> testsToRun = <String>[];
if (argResults.wasParsed(_listFlag)) {
print('available tests:');
final int columnWidth =
testSuites.keys.map((String key) => key.length).reduce(max) + 4;
for (final MapEntry<String, TestInfo> info in testSuites.entries) {
print('${info.key.padRight(columnWidth)}- ${info.value.description}');
}
exit(0);
} else if (argResults.wasParsed('help')) {
print('''
Pigeon run_tests
usage: dart run tool/test.dart [-l | -t <test name>]
${parser.usage}''');
exit(0);
} else if (argResults.wasParsed(_testFlag)) {
testsToRun = argResults[_testFlag] as List<String>;
}
// If no tests are provided, run everything that is supported on the current
// platform.
if (testsToRun.isEmpty) {
const List<String> dartTests = <String>[
dartUnitTests,
flutterUnitTests,
commandLineTests,
];
const List<String> androidTests = <String>[
androidJavaUnitTests,
androidKotlinUnitTests,
androidJavaIntegrationTests,
androidKotlinIntegrationTests,
androidJavaLint,
];
const List<String> iOSTests = <String>[
iOSObjCUnitTests,
iOSObjCIntegrationTests,
iOSSwiftUnitTests,
iOSSwiftIntegrationTests,
];
const List<String> macOSTests = <String>[
macOSObjCIntegrationTests,
macOSSwiftUnitTests,
macOSSwiftIntegrationTests
];
const List<String> windowsTests = <String>[
windowsUnitTests,
windowsIntegrationTests,
];
if (Platform.isMacOS) {
testsToRun = <String>[
...dartTests,
...androidTests,
...iOSTests,
...macOSTests,
];
} else if (Platform.isWindows) {
testsToRun = <String>[
...dartTests,
...windowsTests,
];
} else if (Platform.isLinux) {
testsToRun = <String>[
...dartTests,
...androidTests,
];
} else {
print('Unsupported host platform.');
exit(1);
}
}
await runTests(
testsToRun,
runGeneration: !argResults.wasParsed(_noGen),
runFormat: argResults.wasParsed(_format),
);
}