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

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

Issue 1264393004: Pass Configuration to Loader and Server. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 4 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/runner/loader.dart ('k') | test/runner/loader_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';
11 import 'package:test/src/backend/test_platform.dart'; 11 import 'package:test/src/backend/test_platform.dart';
12 import 'package:test/src/runner/configuration.dart';
12 import 'package:test/src/runner/loader.dart'; 13 import 'package:test/src/runner/loader.dart';
13 import 'package:test/src/util/io.dart'; 14 import 'package:test/src/util/io.dart';
14 import 'package:test/test.dart'; 15 import 'package:test/test.dart';
15 16
16 import '../../io.dart'; 17 import '../../io.dart';
17 import '../../utils.dart'; 18 import '../../utils.dart';
18 19
19 Loader _loader; 20 Loader _loader;
20 String _sandbox; 21 String _sandbox;
21 22
22 final _tests = """ 23 final _tests = """
23 import 'dart:async'; 24 import 'dart:async';
24 25
25 import 'package:test/test.dart'; 26 import 'package:test/test.dart';
26 27
27 void main() { 28 void main() {
28 test("success", () {}); 29 test("success", () {});
29 test("failure", () => throw new TestFailure('oh no')); 30 test("failure", () => throw new TestFailure('oh no'));
30 test("error", () => throw 'oh no'); 31 test("error", () => throw 'oh no');
31 } 32 }
32 """; 33 """;
33 34
34 void main() { 35 void main() {
35 setUp(() { 36 setUp(() {
36 _sandbox = createTempDir(); 37 _sandbox = createTempDir();
37 _loader = new Loader([TestPlatform.chrome], 38 _loader = new Loader(new Configuration(
38 root: _sandbox, 39 platforms: [TestPlatform.chrome],
39 packageRoot: p.join(packageDir, 'packages')); 40 packageRoot: p.join(packageDir, 'packages')),
41 root: _sandbox);
40 /// TODO(nweiz): Use scheduled_test for this once it's compatible with this 42 /// TODO(nweiz): Use scheduled_test for this once it's compatible with this
41 /// version of test. 43 /// version of test.
42 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync(_tests); 44 new File(p.join(_sandbox, 'a_test.dart')).writeAsStringSync(_tests);
43 }); 45 });
44 46
45 tearDown(() { 47 tearDown(() {
46 new Directory(_sandbox).deleteSync(recursive: true); 48 new Directory(_sandbox).deleteSync(recursive: true);
47 return _loader.close(); 49 return _loader.close();
48 }); 50 });
49 51
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 expect(suites, hasLength(1)); 118 expect(suites, hasLength(1));
117 var loadSuite = suites.first; 119 var loadSuite = suites.first;
118 var suite = await loadSuite.getSuite(); 120 var suite = await loadSuite.getSuite();
119 expect(suite.tests, hasLength(3)); 121 expect(suite.tests, hasLength(3));
120 expect(suite.tests[0].name, equals("success")); 122 expect(suite.tests[0].name, equals("success"));
121 expect(suite.tests[1].name, equals("failure")); 123 expect(suite.tests[1].name, equals("failure"));
122 expect(suite.tests[2].name, equals("error")); 124 expect(suite.tests[2].name, equals("error"));
123 }); 125 });
124 126
125 test("loads a suite both in the browser and the VM", () async { 127 test("loads a suite both in the browser and the VM", () async {
126 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], 128 var loader = new Loader(
127 root: _sandbox, 129 new Configuration(
128 packageRoot: p.join(packageDir, 'packages')); 130 platforms: [TestPlatform.vm, TestPlatform.chrome],
131 packageRoot: p.join(packageDir, 'packages')),
132 root: _sandbox);
129 var path = p.join(_sandbox, 'a_test.dart'); 133 var path = p.join(_sandbox, 'a_test.dart');
130 134
131 try { 135 try {
132 var suites = await loader.loadFile(path) 136 var suites = await loader.loadFile(path)
133 .asyncMap((loadSuite) => loadSuite.getSuite()).toList(); 137 .asyncMap((loadSuite) => loadSuite.getSuite()).toList();
134 expect(suites[0].platform, equals(TestPlatform.vm)); 138 expect(suites[0].platform, equals(TestPlatform.vm));
135 expect(suites[0].path, equals(path)); 139 expect(suites[0].path, equals(path));
136 expect(suites[1].platform, equals(TestPlatform.chrome)); 140 expect(suites[1].platform, equals(TestPlatform.chrome));
137 expect(suites[1].path, equals(path)); 141 expect(suites[1].path, equals(path));
138 142
(...skipping 18 matching lines...) Expand all
157 .toList(); 161 .toList();
158 expect(suites, hasLength(1)); 162 expect(suites, hasLength(1));
159 var loadSuite = suites.first; 163 var loadSuite = suites.first;
160 164
161 var liveTest = await loadSuite.tests.single.load(loadSuite); 165 var liveTest = await loadSuite.tests.single.load(loadSuite);
162 expect(liveTest.onPrint.first, completion(equals("print within test"))); 166 expect(liveTest.onPrint.first, completion(equals("print within test")));
163 await liveTest.run(); 167 await liveTest.run();
164 expectTestPassed(liveTest); 168 expectTestPassed(liveTest);
165 }); 169 });
166 } 170 }
OLDNEW
« no previous file with comments | « lib/src/runner/loader.dart ('k') | test/runner/loader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698