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

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

Issue 2066113002: Add location information to the JSON reporter. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: cr Created 4 years, 6 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/backend/group_entry.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 import 'package:stack_trace/stack_trace.dart';
6
5 import 'group_entry.dart'; 7 import 'group_entry.dart';
6 import 'metadata.dart'; 8 import 'metadata.dart';
7 import 'operating_system.dart'; 9 import 'operating_system.dart';
8 import 'test.dart'; 10 import 'test.dart';
9 import 'test_platform.dart'; 11 import 'test_platform.dart';
10 12
11 /// A group contains one or more tests and subgroups. 13 /// A group contains one or more tests and subgroups.
12 /// 14 ///
13 /// It includes metadata that applies to all contained tests. 15 /// It includes metadata that applies to all contained tests.
14 class Group implements GroupEntry { 16 class Group implements GroupEntry {
15 final String name; 17 final String name;
16 18
17 final Metadata metadata; 19 final Metadata metadata;
18 20
21 final Trace trace;
22
19 /// The children of this group. 23 /// The children of this group.
20 final List<GroupEntry> entries; 24 final List<GroupEntry> entries;
21 25
22 /// Returns a new root-level group. 26 /// Returns a new root-level group.
23 Group.root(Iterable<GroupEntry> entries, {Metadata metadata}) 27 Group.root(Iterable<GroupEntry> entries, {Metadata metadata})
24 : this(null, entries, metadata: metadata); 28 : this(null, entries, metadata: metadata);
25 29
26 /// A test to run before all tests in the group. 30 /// A test to run before all tests in the group.
27 /// 31 ///
28 /// This is `null` if no `setUpAll` callbacks were declared. 32 /// This is `null` if no `setUpAll` callbacks were declared.
29 final Test setUpAll; 33 final Test setUpAll;
30 34
31 /// A test to run after all tests in the group. 35 /// A test to run after all tests in the group.
32 /// 36 ///
33 /// This is `null` if no `tearDown` callbacks were declared. 37 /// This is `null` if no `tearDown` callbacks were declared.
34 final Test tearDownAll; 38 final Test tearDownAll;
35 39
36 /// The number of tests (recursively) in this group. 40 /// The number of tests (recursively) in this group.
37 int get testCount { 41 int get testCount {
38 if (_testCount != null) return _testCount; 42 if (_testCount != null) return _testCount;
39 _testCount = entries.fold(0, 43 _testCount = entries.fold(0,
40 (count, entry) => count + (entry is Group ? entry.testCount : 1)); 44 (count, entry) => count + (entry is Group ? entry.testCount : 1));
41 return _testCount; 45 return _testCount;
42 } 46 }
43 int _testCount; 47 int _testCount;
44 48
45 Group(this.name, Iterable<GroupEntry> entries, {Metadata metadata, 49 Group(this.name, Iterable<GroupEntry> entries, {Metadata metadata,
46 Test this.setUpAll, Test this.tearDownAll}) 50 this.trace, Test this.setUpAll, Test this.tearDownAll})
47 : entries = new List<GroupEntry>.unmodifiable(entries), 51 : entries = new List<GroupEntry>.unmodifiable(entries),
48 metadata = metadata == null ? new Metadata() : metadata; 52 metadata = metadata == null ? new Metadata() : metadata;
49 53
50 Group forPlatform(TestPlatform platform, {OperatingSystem os}) { 54 Group forPlatform(TestPlatform platform, {OperatingSystem os}) {
51 if (!metadata.testOn.evaluate(platform, os: os)) return null; 55 if (!metadata.testOn.evaluate(platform, os: os)) return null;
52 var newMetadata = metadata.forPlatform(platform, os: os); 56 var newMetadata = metadata.forPlatform(platform, os: os);
53 var filtered = _map((entry) => entry.forPlatform(platform, os: os)); 57 var filtered = _map((entry) => entry.forPlatform(platform, os: os));
54 if (filtered.isEmpty && !entries.isEmpty) return null; 58 if (filtered.isEmpty && !entries.isEmpty) return null;
55 return new Group(name, filtered, 59 return new Group(name, filtered,
56 metadata: newMetadata, setUpAll: setUpAll, tearDownAll: tearDownAll); 60 metadata: newMetadata,
61 trace: trace,
62 setUpAll: setUpAll,
63 tearDownAll: tearDownAll);
57 } 64 }
58 65
59 Group filter(bool callback(Test test)) { 66 Group filter(bool callback(Test test)) {
60 var filtered = _map((entry) => entry.filter(callback)); 67 var filtered = _map((entry) => entry.filter(callback));
61 if (filtered.isEmpty && !entries.isEmpty) return null; 68 if (filtered.isEmpty && !entries.isEmpty) return null;
62 return new Group(name, filtered, 69 return new Group(name, filtered,
63 metadata: metadata, setUpAll: setUpAll, tearDownAll: tearDownAll); 70 metadata: metadata,
71 trace: trace,
72 setUpAll: setUpAll,
73 tearDownAll: tearDownAll);
64 } 74 }
65 75
66 /// Returns the entries of this group mapped using [callback]. 76 /// Returns the entries of this group mapped using [callback].
67 /// 77 ///
68 /// Any `null` values returned by [callback] will be removed. 78 /// Any `null` values returned by [callback] will be removed.
69 List<GroupEntry> _map(GroupEntry callback(GroupEntry entry)) { 79 List<GroupEntry> _map(GroupEntry callback(GroupEntry entry)) {
70 return entries 80 return entries
71 .map((entry) => callback(entry)) 81 .map((entry) => callback(entry))
72 .where((entry) => entry != null) 82 .where((entry) => entry != null)
73 .toList(); 83 .toList();
74 } 84 }
75 } 85 }
OLDNEW
« no previous file with comments | « lib/src/backend/declarer.dart ('k') | lib/src/backend/group_entry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698