run function
Implementation
Future<void> run(List<String> arguments) async {
var parser = ArgParser()
..addFlag('headless', defaultsTo: true, negatable: true)
..addFlag('record', negatable: true)
..addOption('parallel-runs',
defaultsTo: Platform.numberOfProcessors.toString())
..addOption('platform', abbr: 'p', allowed: ['ios'], mandatory: true)
..addMultiOption('device', abbr: 'd')
..addOption('outputPath', abbr: 'o', defaultsTo: '/')
..addMultiOption('permission');
try {
final results = parser.parse(arguments);
if ((results['device'] as List<String>).isEmpty) {
error(
'You need to specify at least one device on ${results["platform"]}');
exit(1);
}
var p = (results['platform'] as String).parseToPlatform();
var nep = (results['permission'] as List<String>)
.where((perm) => !p.verifyPermission(perm));
if (nep.isNotEmpty) {
throw Exception('${nep.join(", ")} permissions does not exists');
}
for (var device in (results['device'] as List<String>)) {
if (!p.checkDeviceIdentifier(device)) {
throw Exception("${results['device']} does not exists on $p devices");
}
}
for (var device in (results['device'] as List<String>)) {
var simulator = Simulator(
deviceIdentifier: device,
permissions: results['permission'],
os: p.getDefaultRuntime(),
headless: results['headless'],
name: 'ft-simulator',
platform: p);
for (var testFile in results.rest) {
var testResult = await simulator.runTests(
testFile, results['record'], results['outputPath']!);
print('TEST RESULTS $testResult');
simulator.cleanUp();
if (!testResult) {
error('Test $testFile failed');
exit(1);
}
}
exit(0);
}
} on FormatException catch (e) {
error(e.message);
}
}