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

Side by Side Diff: test/runner/browser/loader_test.dart

Issue 1107743002: Support asynchronous main methods. (Closed) Base URL: git@github.com:dart-lang/test@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 | « pubspec.yaml ('k') | test/runner/isolate_listener_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 @TestOn("vm") 5 @TestOn("vm")
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:test/src/backend/state.dart'; 10 import 'package:test/src/backend/state.dart';
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return liveTest.run().whenComplete(() => liveTest.close()); 81 return liveTest.run().whenComplete(() => liveTest.close());
82 }); 82 });
83 83
84 test("can load and run a failing test", () { 84 test("can load and run a failing test", () {
85 var liveTest = suite.tests[1].load(suite); 85 var liveTest = suite.tests[1].load(suite);
86 expectSingleFailure(liveTest); 86 expectSingleFailure(liveTest);
87 return liveTest.run().whenComplete(() => liveTest.close()); 87 return liveTest.run().whenComplete(() => liveTest.close());
88 }); 88 });
89 }); 89 });
90 90
91
92 test("loads tests that are defined asynchronously", () {
93 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync("""
94 import 'dart:async';
95
96 import 'package:test/test.dart';
97
98 Future main() {
99 return new Future(() {
100 test("success", () {});
101
102 return new Future(() {
103 test("failure", () => throw new TestFailure('oh no'));
104
105 return new Future(() {
106 test("error", () => throw 'oh no');
107 });
108 });
109 });
110 }
111 """);
112
113 return _loader.loadFile(p.join(_sandbox, 'a_test.dart')).toList()
114 .then((suites) {
115 expect(suites, hasLength(1));
116 var suite = suites.first;
117 expect(suite.tests, hasLength(3));
118 expect(suite.tests[0].name, equals("success"));
119 expect(suite.tests[1].name, equals("failure"));
120 expect(suite.tests[2].name, equals("error"));
121 });
122 });
123
91 test("loads a suite both in the browser and the VM", () { 124 test("loads a suite both in the browser and the VM", () {
92 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], 125 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome],
93 root: _sandbox, 126 root: _sandbox,
94 packageRoot: p.join(packageDir, 'packages')); 127 packageRoot: p.join(packageDir, 'packages'));
95 var path = p.join(_sandbox, 'a_test.dart'); 128 var path = p.join(_sandbox, 'a_test.dart');
96 return loader.loadFile(path).toList().then((suites) { 129 return loader.loadFile(path).toList().then((suites) {
97 expect(suites[0].platform, equals('VM')); 130 expect(suites[0].platform, equals('VM'));
98 expect(suites[0].path, equals(path)); 131 expect(suites[0].path, equals(path));
99 expect(suites[1].platform, equals('Chrome')); 132 expect(suites[1].platform, equals('Chrome'));
100 expect(suites[1].path, equals(path)); 133 expect(suites[1].path, equals(path));
101 134
102 for (var suite in suites) { 135 for (var suite in suites) {
103 expect(suite.tests, hasLength(3)); 136 expect(suite.tests, hasLength(3));
104 expect(suite.tests[0].name, equals("success")); 137 expect(suite.tests[0].name, equals("success"));
105 expect(suite.tests[1].name, equals("failure")); 138 expect(suite.tests[1].name, equals("failure"));
106 expect(suite.tests[2].name, equals("error")); 139 expect(suite.tests[2].name, equals("error"));
107 } 140 }
108 }).whenComplete(loader.close); 141 }).whenComplete(loader.close);
109 }); 142 });
110 } 143 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/runner/isolate_listener_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698