| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library testing.test_root; | 5 library testing.test_root; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show Future; |
| 8 Future; | |
| 9 | 8 |
| 10 import 'dart:convert' show | 9 import 'dart:convert' show JSON; |
| 11 JSON; | |
| 12 | 10 |
| 13 import 'dart:io' show | 11 import 'dart:io' show File; |
| 14 File; | |
| 15 | 12 |
| 16 import '../testing.dart' show | 13 import '../testing.dart' show Chain; |
| 17 Chain; | |
| 18 | 14 |
| 19 import 'analyze.dart' show | 15 import 'analyze.dart' show Analyze; |
| 20 Analyze; | |
| 21 | 16 |
| 22 import 'suite.dart' show | 17 import 'suite.dart' show Dart, Suite; |
| 23 Dart, | |
| 24 Suite; | |
| 25 | 18 |
| 26 /// Records properties of a test root. The information is read from a JSON file. | 19 /// Records properties of a test root. The information is read from a JSON file. |
| 27 /// | 20 /// |
| 28 /// Example with comments: | 21 /// Example with comments: |
| 29 /// { | 22 /// { |
| 30 /// # Path to the `.packages` file used. | 23 /// # Path to the `.packages` file used. |
| 31 /// "packages": "test/.packages", | 24 /// "packages": "test/.packages", |
| 32 /// # A list of test suites (collection of tests). | 25 /// # A list of test suites (collection of tests). |
| 33 /// "suites": [ | 26 /// "suites": [ |
| 34 /// # A list of suite objects. See the subclasses of [Suite] below. | 27 /// # A list of suite objects. See the subclasses of [Suite] below. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 56 | 49 |
| 57 TestRoot(this.packages, this.suites); | 50 TestRoot(this.packages, this.suites); |
| 58 | 51 |
| 59 Analyze get analyze => suites.last; | 52 Analyze get analyze => suites.last; |
| 60 | 53 |
| 61 List<Uri> get urisToAnalyze => analyze.uris; | 54 List<Uri> get urisToAnalyze => analyze.uris; |
| 62 | 55 |
| 63 List<RegExp> get excludedFromAnalysis => analyze.exclude; | 56 List<RegExp> get excludedFromAnalysis => analyze.exclude; |
| 64 | 57 |
| 65 Iterable<Dart> get dartSuites { | 58 Iterable<Dart> get dartSuites { |
| 66 return new List<Dart>.from( | 59 return new List<Dart>.from(suites.where((Suite suite) => suite is Dart)); |
| 67 suites.where((Suite suite) => suite is Dart)); | |
| 68 } | 60 } |
| 69 | 61 |
| 70 Iterable<Chain> get toolChains { | 62 Iterable<Chain> get toolChains { |
| 71 return new List<Chain>.from( | 63 return new List<Chain>.from(suites.where((Suite suite) => suite is Chain)); |
| 72 suites.where((Suite suite) => suite is Chain)); | |
| 73 } | 64 } |
| 74 | 65 |
| 75 String toString() { | 66 String toString() { |
| 76 return "TestRoot($suites, $urisToAnalyze)"; | 67 return "TestRoot($suites, $urisToAnalyze)"; |
| 77 } | 68 } |
| 78 | 69 |
| 79 static Future<TestRoot> fromUri(Uri uri) async { | 70 static Future<TestRoot> fromUri(Uri uri) async { |
| 80 String json = await new File.fromUri(uri).readAsString(); | 71 String json = await new File.fromUri(uri).readAsString(); |
| 81 Map data = JSON.decode(json); | 72 Map data = JSON.decode(json); |
| 82 | 73 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 95 } | 86 } |
| 96 | 87 |
| 97 static void addDefaults(Map data) { | 88 static void addDefaults(Map data) { |
| 98 data.putIfAbsent("packages", () => ".packages"); | 89 data.putIfAbsent("packages", () => ".packages"); |
| 99 data.putIfAbsent("suites", () => []); | 90 data.putIfAbsent("suites", () => []); |
| 100 Map analyze = data.putIfAbsent("analyze", () => {}); | 91 Map analyze = data.putIfAbsent("analyze", () => {}); |
| 101 analyze.putIfAbsent("uris", () => []); | 92 analyze.putIfAbsent("uris", () => []); |
| 102 analyze.putIfAbsent("exclude", () => []); | 93 analyze.putIfAbsent("exclude", () => []); |
| 103 } | 94 } |
| 104 } | 95 } |
| OLD | NEW |