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

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

Issue 1083433002: More gracefully handle load errors. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes 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 | « test/runner/browser/compiler_pool_test.dart ('k') | test/runner/browser/runner_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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 }); 42 });
43 43
44 tearDown(() { 44 tearDown(() {
45 new Directory(_sandbox).deleteSync(recursive: true); 45 new Directory(_sandbox).deleteSync(recursive: true);
46 return _loader.close(); 46 return _loader.close();
47 }); 47 });
48 48
49 group(".loadFile()", () { 49 group(".loadFile()", () {
50 var suite; 50 var suite;
51 setUp(() { 51 setUp(() {
52 return _loader.loadFile(p.join(_sandbox, 'a_test.dart')).then((suites) { 52 return _loader.loadFile(p.join(_sandbox, 'a_test.dart')).toList()
53 .then((suites) {
53 expect(suites, hasLength(1)); 54 expect(suites, hasLength(1));
54 suite = suites.first; 55 suite = suites.first;
55 }); 56 });
56 }); 57 });
57 58
58 test("returns a suite with the file path and platform", () { 59 test("returns a suite with the file path and platform", () {
59 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart'))); 60 expect(suite.path, equals(p.join(_sandbox, 'a_test.dart')));
60 expect(suite.platform, equals('Chrome')); 61 expect(suite.platform, equals('Chrome'));
61 }); 62 });
62 63
(...skipping 19 matching lines...) Expand all
82 test("can load and run a failing test", () { 83 test("can load and run a failing test", () {
83 var liveTest = suite.tests[1].load(suite); 84 var liveTest = suite.tests[1].load(suite);
84 expectSingleFailure(liveTest); 85 expectSingleFailure(liveTest);
85 return liveTest.run().whenComplete(() => liveTest.close()); 86 return liveTest.run().whenComplete(() => liveTest.close());
86 }); 87 });
87 }); 88 });
88 89
89 test("throws a nice error if the package root doesn't exist", () { 90 test("throws a nice error if the package root doesn't exist", () {
90 var loader = new Loader([TestPlatform.chrome]); 91 var loader = new Loader([TestPlatform.chrome]);
91 expect( 92 expect(
92 loader.loadFile(p.join(_sandbox, 'a_test.dart')) 93 loader.loadFile(p.join(_sandbox, 'a_test.dart')).first
93 .whenComplete(loader.close), 94 .whenComplete(loader.close),
94 throwsA(isLoadException( 95 throwsA(isLoadException(
95 "Directory ${p.join(_sandbox, 'packages')} does not exist."))); 96 "Directory ${p.join(_sandbox, 'packages')} does not exist.")));
96 }); 97 });
97 98
98 test("loads a suite both in the browser and the VM", () { 99 test("loads a suite both in the browser and the VM", () {
99 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome], 100 var loader = new Loader([TestPlatform.vm, TestPlatform.chrome],
100 packageRoot: p.join(packageDir, 'packages')); 101 packageRoot: p.join(packageDir, 'packages'));
101 var path = p.join(_sandbox, 'a_test.dart'); 102 var path = p.join(_sandbox, 'a_test.dart');
102 return loader.loadFile(path).then((suites) { 103 return loader.loadFile(path).toList().then((suites) {
103 expect(suites[0].platform, equals('VM')); 104 expect(suites[0].platform, equals('VM'));
104 expect(suites[0].path, equals(path)); 105 expect(suites[0].path, equals(path));
105 expect(suites[1].platform, equals('Chrome')); 106 expect(suites[1].platform, equals('Chrome'));
106 expect(suites[1].path, equals(path)); 107 expect(suites[1].path, equals(path));
107 108
108 for (var suite in suites) { 109 for (var suite in suites) {
109 expect(suite.tests, hasLength(3)); 110 expect(suite.tests, hasLength(3));
110 expect(suite.tests[0].name, equals("success")); 111 expect(suite.tests[0].name, equals("success"));
111 expect(suite.tests[1].name, equals("failure")); 112 expect(suite.tests[1].name, equals("failure"));
112 expect(suite.tests[2].name, equals("error")); 113 expect(suite.tests[2].name, equals("error"));
113 } 114 }
114 }).whenComplete(loader.close); 115 }).whenComplete(loader.close);
115 }); 116 });
116 } 117 }
OLDNEW
« no previous file with comments | « test/runner/browser/compiler_pool_test.dart ('k') | test/runner/browser/runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698