| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.backend.group; | 5 library test.backend.group; |
| 6 | 6 |
| 7 import 'metadata.dart'; | 7 import 'metadata.dart'; |
| 8 import 'operating_system.dart'; | 8 import 'operating_system.dart'; |
| 9 import 'group_entry.dart'; | 9 import 'group_entry.dart'; |
| 10 import 'test.dart'; | 10 import 'test.dart'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 Group(this.name, Iterable<GroupEntry> entries, {Metadata metadata, | 38 Group(this.name, Iterable<GroupEntry> entries, {Metadata metadata, |
| 39 Test this.setUpAll, Test this.tearDownAll}) | 39 Test this.setUpAll, Test this.tearDownAll}) |
| 40 : entries = new List<GroupEntry>.unmodifiable(entries), | 40 : entries = new List<GroupEntry>.unmodifiable(entries), |
| 41 metadata = metadata == null ? new Metadata() : metadata; | 41 metadata = metadata == null ? new Metadata() : metadata; |
| 42 | 42 |
| 43 Group forPlatform(TestPlatform platform, {OperatingSystem os}) { | 43 Group forPlatform(TestPlatform platform, {OperatingSystem os}) { |
| 44 if (!metadata.testOn.evaluate(platform, os: os)) return null; | 44 if (!metadata.testOn.evaluate(platform, os: os)) return null; |
| 45 var newMetadata = metadata.forPlatform(platform, os: os); | 45 var newMetadata = metadata.forPlatform(platform, os: os); |
| 46 var filtered = _map((entry) => entry.forPlatform(platform, os: os)); | 46 var filtered = _map((entry) => entry.forPlatform(platform, os: os)); |
| 47 if (filtered.isEmpty) return null; | 47 if (filtered.isEmpty && !entries.isEmpty) return null; |
| 48 return new Group(name, filtered, | 48 return new Group(name, filtered, |
| 49 metadata: newMetadata, setUpAll: setUpAll, tearDownAll: tearDownAll); | 49 metadata: newMetadata, setUpAll: setUpAll, tearDownAll: tearDownAll); |
| 50 } | 50 } |
| 51 | 51 |
| 52 Group filter(bool callback(Test test)) { | 52 Group filter(bool callback(Test test)) { |
| 53 var filtered = _map((entry) => entry.filter(callback)); | 53 var filtered = _map((entry) => entry.filter(callback)); |
| 54 if (filtered.isEmpty) return null; | 54 if (filtered.isEmpty && !entries.isEmpty) return null; |
| 55 return new Group(name, filtered, | 55 return new Group(name, filtered, |
| 56 metadata: metadata, setUpAll: setUpAll, tearDownAll: tearDownAll); | 56 metadata: metadata, setUpAll: setUpAll, tearDownAll: tearDownAll); |
| 57 } | 57 } |
| 58 | 58 |
| 59 /// Returns the entries of this group mapped using [callback]. | 59 /// Returns the entries of this group mapped using [callback]. |
| 60 /// | 60 /// |
| 61 /// Any `null` values returned by [callback] will be removed. | 61 /// Any `null` values returned by [callback] will be removed. |
| 62 List<GroupEntry> _map(GroupEntry callback(GroupEntry entry)) { | 62 List<GroupEntry> _map(GroupEntry callback(GroupEntry entry)) { |
| 63 return entries | 63 return entries |
| 64 .map((entry) => callback(entry)) | 64 .map((entry) => callback(entry)) |
| 65 .where((entry) => entry != null) | 65 .where((entry) => entry != null) |
| 66 .toList(); | 66 .toList(); |
| 67 } | 67 } |
| 68 } | 68 } |
| OLD | NEW |