Line data Source code
1 : // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file 2 : // for details. All rights reserved. Use of this source code is governed by a 3 : // BSD-style license that can be found in the LICENSE file. 4 : 5 : import 'dart:convert'; 6 : import 'dart:io'; 7 : 8 : import 'package:path/path.dart' as p; 9 : 10 : import 'live_suite_controller.dart'; 11 : 12 : /// Collects coverage and outputs to the [coveragePath] path. 13 0 : Future<void> writeCoverage( 14 : String coveragePath, LiveSuiteController controller) async { 15 0 : var suite = controller.liveSuite.suite; 16 0 : var coverage = await controller.liveSuite.suite.gatherCoverage(); 17 0 : final outfile = File(p.join(coveragePath, 18 0 : '${suite.path}.${suite.platform.runtime.name.toLowerCase()}.json')) 19 0 : ..createSync(recursive: true); 20 0 : final out = outfile.openWrite(); 21 0 : out.write(json.encode(coverage)); 22 0 : await out.flush(); 23 0 : await out.close(); 24 : }