/// Runs the Test workspace script. library; import 'dart:io'; /// Runs tests, combines coverage, enforces coverage, and checks Dart docs. Future main(List arguments) async { await _deleteCoverageDirectory(); await _run('dart', ['pub', 'global', 'activate', 'coverage']); await _run('dart', ['test', '--coverage=coverage']); await _run('dart', [ 'pub', 'global', 'run', 'coverage:format_coverage', '--lcov', '--in=coverage', '--out=coverage/lcov.info', '--packages=.dart_tool/package_config.json', '--report-on=packages', ]); await _run('dart', [ 'run', 'tool/check_coverage.dart', 'coverage/lcov.info', '80', ]); await _run('dart', ['run', 'tool/check_docs.dart']); } Future _deleteCoverageDirectory() async { final coverage = Directory('coverage'); if (await coverage.exists()) { await coverage.delete(recursive: true); } } Future _run(String executable, List arguments) async { final command = '$executable ${arguments.join(' ')}'; stdout.writeln('> $command'); final result = await Process.run( executable, arguments, runInShell: Platform.isWindows, ); stdout.write(result.stdout); stderr.write(result.stderr); if (result.exitCode != 0) { throw ProcessException( executable, arguments, 'Command failed with exit code ${result.exitCode}.', result.exitCode, ); } }