Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: lib/src/backend/suite.dart

Issue 1097183003: Add an "onPlatform" parameter to test() and group(). (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/backend/metadata.dart ('k') | lib/src/backend/test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 /// The metadata associated with this test suite. 26 /// The metadata associated with this test suite.
27 final Metadata metadata; 27 final Metadata metadata;
28 28
29 /// The tests in the test suite. 29 /// The tests in the test suite.
30 final List<Test> tests; 30 final List<Test> tests;
31 31
32 Suite(Iterable<Test> tests, {this.path, this.platform, Metadata metadata}) 32 Suite(Iterable<Test> tests, {this.path, this.platform, Metadata metadata})
33 : metadata = metadata == null ? new Metadata() : metadata, 33 : metadata = metadata == null ? new Metadata() : metadata,
34 tests = new UnmodifiableListView<Test>(tests.toList()); 34 tests = new UnmodifiableListView<Test>(tests.toList());
35 35
36 /// Returns a new suite that only contains tests that are valid for the given 36 /// Returns a view of this suite for the given [platform] and [os].
37 /// [platform] and [os].
38 /// 37 ///
39 /// If the suite itself is invalid for [platform] and [os], returns `null`. 38 /// This filters out tests that are invalid for [platform] and [os] and
40 Suite filter(TestPlatform platform, {OperatingSystem os}) { 39 /// resolves platform-specific metadata. If the suite itself is invalid for
40 /// [platform] and [os], returns `null`.
41 Suite forPlatform(TestPlatform platform, {OperatingSystem os}) {
41 if (!metadata.testOn.evaluate(platform, os: os)) return null; 42 if (!metadata.testOn.evaluate(platform, os: os)) return null;
42 return change(tests: tests.where((test) { 43 return change(tests: tests.where((test) {
43 return test.metadata.testOn.evaluate(platform, os: os); 44 return test.metadata.testOn.evaluate(platform, os: os);
45 }).map((test) {
46 return test.change(metadata: test.metadata.forPlatform(platform, os: os));
44 })); 47 }));
45 } 48 }
46 49
47 /// Returns a new suite with the given fields updated. 50 /// Returns a new suite with the given fields updated.
48 Suite change({String path, String platform, Metadata metadata, 51 Suite change({String path, String platform, Metadata metadata,
49 Iterable<Test> tests}) { 52 Iterable<Test> tests}) {
50 if (path == null) path = this.path; 53 if (path == null) path = this.path;
51 if (platform == null) platform = this.platform; 54 if (platform == null) platform = this.platform;
52 if (metadata == null) metadata = this.metadata; 55 if (metadata == null) metadata = this.metadata;
53 if (tests == null) tests = this.tests; 56 if (tests == null) tests = this.tests;
54 return new Suite(tests, path: path, platform: platform, metadata: metadata); 57 return new Suite(tests, path: path, platform: platform, metadata: metadata);
55 } 58 }
56 } 59 }
OLDNEW
« no previous file with comments | « lib/src/backend/metadata.dart ('k') | lib/src/backend/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698