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

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

Issue 1036943002: Add a testOn parameter to test() and group(). (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: 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/platform_selector.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 unittest.backend.suite; 5 library unittest.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 'test.dart'; 11 import 'test.dart';
12 import 'test_platform.dart';
11 13
12 /// A test suite. 14 /// A test suite.
13 /// 15 ///
14 /// A test suite is a set of tests that are intended to be run together and that 16 /// A test suite is a set of tests that are intended to be run together and that
15 /// share default configuration. 17 /// share default configuration.
16 class Suite { 18 class Suite {
17 /// A description of the platform on which the suite is running, or `null` if 19 /// A description of the platform on which the suite is running, or `null` if
18 /// that platform is unknown. 20 /// that platform is unknown.
19 final String platform; 21 final String platform;
20 22
21 /// The path to the Dart test suite, or `null` if that path is unknown. 23 /// The path to the Dart test suite, or `null` if that path is unknown.
22 final String path; 24 final String path;
23 25
24 /// The metadata associated with this test suite. 26 /// The metadata associated with this test suite.
25 final Metadata metadata; 27 final Metadata metadata;
26 28
27 /// The tests in the test suite. 29 /// The tests in the test suite.
28 final List<Test> tests; 30 final List<Test> tests;
29 31
30 Suite(Iterable<Test> tests, {this.path, this.platform, Metadata metadata}) 32 Suite(Iterable<Test> tests, {this.path, this.platform, Metadata metadata})
31 : metadata = metadata == null ? new Metadata() : metadata, 33 : metadata = metadata == null ? new Metadata() : metadata,
32 tests = new UnmodifiableListView<Test>(tests.toList()); 34 tests = new UnmodifiableListView<Test>(tests.toList());
33 35
36 /// Returns a new suite that only contains tests that are valid for the given
37 /// [platform] and [os].
38 ///
39 /// If the suite itself is invalid for [platform] and [os], returns `null`.
40 Suite filter(TestPlatform platform, {OperatingSystem os}) {
41 if (!metadata.testOn.evaluate(platform, os: os)) return null;
42 return change(tests: tests.where((test) {
43 return test.metadata.testOn.evaluate(platform, os: os);
44 }));
45 }
46
34 /// Returns a new suite with the given fields updated. 47 /// Returns a new suite with the given fields updated.
35 Suite change({String path, String platform, Metadata metadata, 48 Suite change({String path, String platform, Metadata metadata,
36 Iterable<Test> tests}) { 49 Iterable<Test> tests}) {
37 if (path == null) path = this.path; 50 if (path == null) path = this.path;
38 if (platform == null) platform = this.platform; 51 if (platform == null) platform = this.platform;
39 if (metadata == null) metadata = this.metadata; 52 if (metadata == null) metadata = this.metadata;
40 if (tests == null) tests = this.tests; 53 if (tests == null) tests = this.tests;
41 return new Suite(tests, path: path, platform: platform, metadata: metadata); 54 return new Suite(tests, path: path, platform: platform, metadata: metadata);
42 } 55 }
43 } 56 }
OLDNEW
« no previous file with comments | « lib/src/backend/platform_selector.dart ('k') | lib/src/backend/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698