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

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

Issue 1206033004: Only load a certain number of test suites at once. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 5 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
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:async';
7 import 'dart:collection'; 8 import 'dart:collection';
8 9
10 import '../util/async_thunk.dart';
11 import '../utils.dart';
9 import 'metadata.dart'; 12 import 'metadata.dart';
10 import 'operating_system.dart'; 13 import 'operating_system.dart';
11 import 'test.dart'; 14 import 'test.dart';
12 import 'test_platform.dart'; 15 import 'test_platform.dart';
13 16
14 /// A test suite. 17 /// A test suite.
15 /// 18 ///
16 /// A test suite is a set of tests that are intended to be run together and that 19 /// A test suite is a set of tests that are intended to be run together and that
17 /// share default configuration. 20 /// share default configuration.
18 class Suite { 21 class Suite {
19 /// A description of the platform on which the suite is running, or `null` if 22 /// A description of the platform on which the suite is running, or `null` if
20 /// that platform is unknown. 23 /// that platform is unknown.
21 final String platform; 24 final String platform;
22 25
23 /// The path to the Dart test suite, or `null` if that path is unknown. 26 /// The path to the Dart test suite, or `null` if that path is unknown.
24 final String path; 27 final String path;
25 28
26 /// The metadata associated with this test suite. 29 /// The metadata associated with this test suite.
27 final Metadata metadata; 30 final Metadata metadata;
28 31
32 /// The thunk for running [close] exactly once.
33 final _closeThunk = new AsyncThunk();
34
35 /// The function to call when the suite is closed.
36 final AsyncFunction _onClose;
37
29 /// The tests in the test suite. 38 /// The tests in the test suite.
30 final List<Test> tests; 39 final List<Test> tests;
31 40
32 Suite(Iterable<Test> tests, {this.path, this.platform, Metadata metadata}) 41 Suite(Iterable<Test> tests, {this.path, this.platform, Metadata metadata,
42 AsyncFunction onClose})
33 : metadata = metadata == null ? new Metadata() : metadata, 43 : metadata = metadata == null ? new Metadata() : metadata,
44 _onClose = onClose,
34 tests = new UnmodifiableListView<Test>(tests.toList()); 45 tests = new UnmodifiableListView<Test>(tests.toList());
35 46
36 /// Returns a view of this suite for the given [platform] and [os]. 47 /// Returns a view of this suite for the given [platform] and [os].
37 /// 48 ///
38 /// This filters out tests that are invalid for [platform] and [os] and 49 /// This filters out tests that are invalid for [platform] and [os] and
39 /// resolves platform-specific metadata. If the suite itself is invalid for 50 /// resolves platform-specific metadata. If the suite itself is invalid for
40 /// [platform] and [os], returns `null`. 51 /// [platform] and [os], returns `null`.
41 Suite forPlatform(TestPlatform platform, {OperatingSystem os}) { 52 Suite forPlatform(TestPlatform platform, {OperatingSystem os}) {
42 if (!metadata.testOn.evaluate(platform, os: os)) return null; 53 if (!metadata.testOn.evaluate(platform, os: os)) return null;
43 return change(tests: tests.where((test) { 54 return change(tests: tests.where((test) {
44 return test.metadata.testOn.evaluate(platform, os: os); 55 return test.metadata.testOn.evaluate(platform, os: os);
45 }).map((test) { 56 }).map((test) {
46 return test.change(metadata: test.metadata.forPlatform(platform, os: os)); 57 return test.change(metadata: test.metadata.forPlatform(platform, os: os));
47 }), metadata: metadata.forPlatform(platform, os: os)); 58 }), metadata: metadata.forPlatform(platform, os: os));
48 } 59 }
49 60
50 /// Returns a new suite with the given fields updated. 61 /// Returns a new suite with the given fields updated.
51 Suite change({String path, String platform, Metadata metadata, 62 Suite change({String path, String platform, Metadata metadata,
52 Iterable<Test> tests}) { 63 Iterable<Test> tests}) {
53 if (path == null) path = this.path; 64 if (path == null) path = this.path;
54 if (platform == null) platform = this.platform; 65 if (platform == null) platform = this.platform;
55 if (metadata == null) metadata = this.metadata; 66 if (metadata == null) metadata = this.metadata;
56 if (tests == null) tests = this.tests; 67 if (tests == null) tests = this.tests;
57 return new Suite(tests, path: path, platform: platform, metadata: metadata); 68 return new Suite(tests, path: path, platform: platform, metadata: metadata,
69 onClose: this.close);
70 }
71
72 /// Closes the suite and releases any resources associated with it.
73 Future close() {
74 return _closeThunk.run(() async {
75 if (_onClose != null) await _onClose();
76 });
58 } 77 }
59 } 78 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/executable.dart » ('j') | test/runner/signal_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698