Skip to content

Commit

Permalink
Cleanup lib/src/run_and_collect.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Jun 29, 2022
1 parent 8831b86 commit 62428b0
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions lib/src/run_and_collect.dart
Expand Up @@ -16,31 +16,35 @@ Future<Map<String, dynamic>> runAndCollect(String scriptPath,
final dartArgs = [
'--enable-vm-service',
'--pause_isolates_on_exit',
if (checked) '--checked',
scriptPath,
...?scriptArgs,
];

if (checked) {
dartArgs.add('--checked');
}

dartArgs.add(scriptPath);

if (scriptArgs != null) {
dartArgs.addAll(scriptArgs);
}

final process = await Process.start(Platform.executable, dartArgs);

final serviceUri = await serviceUriFromProcess(process.stdout.lines());
Map<String, dynamic> coverage;
try {
coverage = await collect(serviceUri, true, true, includeDart, <String>{},
timeout: timeout);
coverage = await collect(
serviceUri,
true,
true,
includeDart,
<String>{},
timeout: timeout,
);
} finally {
await process.stderr.drain();
}
final exitStatus = await process.exitCode;
if (exitStatus != 0) {
throw 'Process exited with exit code $exitStatus';
throw ProcessException(
Platform.executable,
dartArgs,
'Process failed.',
exitStatus,
);
}
return coverage;
}

0 comments on commit 62428b0

Please sign in to comment.