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.suite; | 5 library test.backend.suite; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'metadata.dart'; | 9 import 'metadata.dart'; |
10 import 'operating_system.dart'; | 10 import 'operating_system.dart'; |
(...skipping 26 matching lines...) Expand all Loading... |
37 /// | 37 /// |
38 /// This filters out tests that are invalid for [platform] and [os] and | 38 /// This filters out tests that are invalid for [platform] and [os] and |
39 /// resolves platform-specific metadata. If the suite itself is invalid for | 39 /// resolves platform-specific metadata. If the suite itself is invalid for |
40 /// [platform] and [os], returns `null`. | 40 /// [platform] and [os], returns `null`. |
41 Suite forPlatform(TestPlatform platform, {OperatingSystem os}) { | 41 Suite forPlatform(TestPlatform platform, {OperatingSystem os}) { |
42 if (!metadata.testOn.evaluate(platform, os: os)) return null; | 42 if (!metadata.testOn.evaluate(platform, os: os)) return null; |
43 return change(tests: tests.where((test) { | 43 return change(tests: tests.where((test) { |
44 return test.metadata.testOn.evaluate(platform, os: os); | 44 return test.metadata.testOn.evaluate(platform, os: os); |
45 }).map((test) { | 45 }).map((test) { |
46 return test.change(metadata: test.metadata.forPlatform(platform, os: os)); | 46 return test.change(metadata: test.metadata.forPlatform(platform, os: os)); |
47 })); | 47 }), metadata: metadata.forPlatform(platform, os: os)); |
48 } | 48 } |
49 | 49 |
50 /// Returns a new suite with the given fields updated. | 50 /// Returns a new suite with the given fields updated. |
51 Suite change({String path, String platform, Metadata metadata, | 51 Suite change({String path, String platform, Metadata metadata, |
52 Iterable<Test> tests}) { | 52 Iterable<Test> tests}) { |
53 if (path == null) path = this.path; | 53 if (path == null) path = this.path; |
54 if (platform == null) platform = this.platform; | 54 if (platform == null) platform = this.platform; |
55 if (metadata == null) metadata = this.metadata; | 55 if (metadata == null) metadata = this.metadata; |
56 if (tests == null) tests = this.tests; | 56 if (tests == null) tests = this.tests; |
57 return new Suite(tests, path: path, platform: platform, metadata: metadata); | 57 return new Suite(tests, path: path, platform: platform, metadata: metadata); |
58 } | 58 } |
59 } | 59 } |
OLD | NEW |