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

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

Issue 1400743002: Add support for setUpAll and tearDownAll. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 2 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/declarer.dart ('k') | lib/src/runner/browser/browser_manager.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.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';
11 import 'test_platform.dart'; 11 import 'test_platform.dart';
12 12
13 /// A group contains one or more tests and subgroups. 13 /// A group contains one or more tests and subgroups.
14 /// 14 ///
15 /// It includes metadata that applies to all contained tests. 15 /// It includes metadata that applies to all contained tests.
16 class Group implements GroupEntry { 16 class Group implements GroupEntry {
17 final String name; 17 final String name;
18 18
19 final Metadata metadata; 19 final Metadata metadata;
20 20
21 /// The children of this group. 21 /// The children of this group.
22 final List<GroupEntry> entries; 22 final List<GroupEntry> entries;
23 23
24 /// Returns a new root-level group. 24 /// Returns a new root-level group.
25 Group.root(Iterable<GroupEntry> entries, {Metadata metadata}) 25 Group.root(Iterable<GroupEntry> entries, {Metadata metadata})
26 : this(null, entries, metadata: metadata); 26 : this(null, entries, metadata: metadata);
27 27
28 Group(this.name, Iterable<GroupEntry> entries, {Metadata metadata}) 28 /// A test to run before all tests in the group.
29 ///
30 /// This is `null` if no `setUpAll` callbacks were declared.
31 final Test setUpAll;
32
33 /// A test to run after all tests in the group.
34 ///
35 /// This is `null` if no `tearDown` callbacks were declared.
36 final Test tearDownAll;
37
38 Group(this.name, Iterable<GroupEntry> entries, {Metadata metadata,
39 Test this.setUpAll, Test this.tearDownAll})
29 : entries = new List<GroupEntry>.unmodifiable(entries), 40 : entries = new List<GroupEntry>.unmodifiable(entries),
30 metadata = metadata == null ? new Metadata() : metadata; 41 metadata = metadata == null ? new Metadata() : metadata;
31 42
32 Group forPlatform(TestPlatform platform, {OperatingSystem os}) { 43 Group forPlatform(TestPlatform platform, {OperatingSystem os}) {
33 if (!metadata.testOn.evaluate(platform, os: os)) return null; 44 if (!metadata.testOn.evaluate(platform, os: os)) return null;
34 var newMetadata = metadata.forPlatform(platform, os: os); 45 var newMetadata = metadata.forPlatform(platform, os: os);
35 var filtered = _map((entry) => entry.forPlatform(platform, os: os)); 46 var filtered = _map((entry) => entry.forPlatform(platform, os: os));
36 if (filtered.isEmpty) return null; 47 if (filtered.isEmpty) return null;
37 return new Group(name, filtered, metadata: newMetadata); 48 return new Group(name, filtered,
49 metadata: newMetadata, setUpAll: setUpAll, tearDownAll: tearDownAll);
38 } 50 }
39 51
40 Group filter(bool callback(Test test)) { 52 Group filter(bool callback(Test test)) {
41 var filtered = _map((entry) => entry.filter(callback)); 53 var filtered = _map((entry) => entry.filter(callback));
42 if (filtered.isEmpty) return null; 54 if (filtered.isEmpty) return null;
43 return new Group(name, filtered, metadata: metadata); 55 return new Group(name, filtered,
56 metadata: metadata, setUpAll: setUpAll, tearDownAll: tearDownAll);
44 } 57 }
45 58
46 /// Returns the entries of this group mapped using [callback]. 59 /// Returns the entries of this group mapped using [callback].
47 /// 60 ///
48 /// Any `null` values returned by [callback] will be removed. 61 /// Any `null` values returned by [callback] will be removed.
49 List<GroupEntry> _map(GroupEntry callback(GroupEntry entry)) { 62 List<GroupEntry> _map(GroupEntry callback(GroupEntry entry)) {
50 return entries 63 return entries
51 .map((entry) => callback(entry)) 64 .map((entry) => callback(entry))
52 .where((entry) => entry != null) 65 .where((entry) => entry != null)
53 .toList(); 66 .toList();
54 } 67 }
55 } 68 }
OLDNEW
« no previous file with comments | « lib/src/backend/declarer.dart ('k') | lib/src/runner/browser/browser_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698