diff --git a/lib/src/run_and_collect.dart b/lib/src/run_and_collect.dart index b9a09324..1bd57908 100644 --- a/lib/src/run_and_collect.dart +++ b/lib/src/run_and_collect.dart @@ -16,31 +16,35 @@ Future> 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 coverage; try { - coverage = await collect(serviceUri, true, true, includeDart, {}, - timeout: timeout); + coverage = await collect( + serviceUri, + true, + true, + includeDart, + {}, + 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; }