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

Side by Side Diff: pkg/scheduled_test/test/descriptor/directory_test.dart

Issue 24276010: Change package scheduled_test to throw TestFailures rather than strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import 'package:path/path.dart' as path; 8 import 'package:path/path.dart' as path;
9 import 'package:scheduled_test/descriptor.dart' as d; 9 import 'package:scheduled_test/descriptor.dart' as d;
10 import 'package:scheduled_test/scheduled_test.dart'; 10 import 'package:scheduled_test/scheduled_test.dart';
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 d.file('subfile2.txt', 'subcontents2') 120 d.file('subfile2.txt', 'subcontents2')
121 ]), 121 ]),
122 d.file('file1.txt', 'contents1'), 122 d.file('file1.txt', 'contents1'),
123 d.file('file2.txt', 'contents2') 123 d.file('file2.txt', 'contents2')
124 ]).validate(); 124 ]).validate();
125 }); 125 });
126 126
127 test('test 2', () { 127 test('test 2', () {
128 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 128 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
129 expect(errors.length, equals(1)); 129 expect(errors.length, equals(1));
130 // Error is _DirectoryValidationError.
nweiz 2013/09/20 21:45:41 I don't think these comments are useful. The tests
Bill Hesse 2013/09/23 17:15:25 Done.
130 expect(errors.first.error.toString(), 131 expect(errors.first.error.toString(),
131 matches(r"^Directory not found: '[^']+[\\/]dir[\\/]subdir'\.$")); 132 matches(r"^Directory not found: '[^']+[\\/]dir[\\/]subdir'\.$"));
132 }); 133 });
133 }, passing: ['test 2']); 134 }, passing: ['test 2']);
134 135
135 expectTestsPass("directory().validate() fails if a file isn't found", () { 136 expectTestsPass("directory().validate() fails if a file isn't found", () {
136 var errors; 137 var errors;
137 test('test 1', () { 138 test('test 1', () {
138 scheduleSandbox(); 139 scheduleSandbox();
139 140
(...skipping 22 matching lines...) Expand all
162 d.file('subfile2.txt', 'subcontents2') 163 d.file('subfile2.txt', 'subcontents2')
163 ]), 164 ]),
164 d.file('file1.txt', 'contents1'), 165 d.file('file1.txt', 'contents1'),
165 d.file('file2.txt', 'contents2') 166 d.file('file2.txt', 'contents2')
166 ]).validate(); 167 ]).validate();
167 }); 168 });
168 169
169 test('test 2', () { 170 test('test 2', () {
170 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 171 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
171 expect(errors.length, equals(1)); 172 expect(errors.length, equals(1));
173 // Error is a _DirectoryValidationError.
172 expect(errors.first.error.toString(), 174 expect(errors.first.error.toString(),
173 matches(r"^File not found: '[^']+[\\/]dir[\\/]file2\.txt'\.$")); 175 matches(r"^File not found: '[^']+[\\/]dir[\\/]file2\.txt'\.$"));
174 }); 176 });
175 }, passing: ['test 2']); 177 }, passing: ['test 2']);
176 178
177 expectTestsPass("directory().validate() fails if multiple children aren't " 179 expectTestsPass("directory().validate() fails if multiple children aren't "
178 "found or have the wrong contents", () { 180 "found or have the wrong contents", () {
179 var errors; 181 var errors;
180 test('test 1', () { 182 test('test 1', () {
181 scheduleSandbox(); 183 scheduleSandbox();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 295
294 expectTestsPass("directory().load() fails to load a nested directory", () { 296 expectTestsPass("directory().load() fails to load a nested directory", () {
295 test('test', () { 297 test('test', () {
296 var dir = d.dir('dir', [ 298 var dir = d.dir('dir', [
297 d.dir('subdir', [ 299 d.dir('subdir', [
298 d.file('name.txt', 'subcontents') 300 d.file('name.txt', 'subcontents')
299 ]), 301 ]),
300 d.file('name.txt', 'contents') 302 d.file('name.txt', 'contents')
301 ]); 303 ]);
302 304
303 expect(dir.load('subdir').toList(), 305 expect(dir.load('subdir').toList(), throwsA(allOf(
304 throwsA(equals("Couldn't find a readable entry named 'subdir' within " 306 new isInstanceOf<TestFailure>(),
305 "'dir'."))); 307 predicate((x) => x.message ==
308 "Couldn't find a readable entry named 'subdir' within 'dir'."))));
306 }); 309 });
307 }); 310 });
308 311
309 expectTestsPass("directory().load() fails to load an absolute path", () { 312 expectTestsPass("directory().load() fails to load an absolute path", () {
310 test('test', () { 313 test('test', () {
311 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); 314 var dir = d.dir('dir', [d.file('name.txt', 'contents')]);
312 315
313 expect(dir.load('/name.txt').toList(), throwsArgumentError); 316 expect(dir.load('/name.txt').toList(), throwsArgumentError);
314 }); 317 });
315 }); 318 });
316 319
317 expectTestsPass("directory().load() fails to load '.', '..', or ''", () { 320 expectTestsPass("directory().load() fails to load '.', '..', or ''", () {
318 test('test', () { 321 test('test', () {
319 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); 322 var dir = d.dir('dir', [d.file('name.txt', 'contents')]);
320 323
321 expect(dir.load('.').toList(), throwsArgumentError); 324 expect(dir.load('.').toList(), throwsArgumentError);
322 325
323 expect(dir.load('..').toList(), throwsArgumentError); 326 expect(dir.load('..').toList(), throwsArgumentError);
324 327
325 expect(dir.load('').toList(), throwsArgumentError); 328 expect(dir.load('').toList(), throwsArgumentError);
326 }); 329 });
327 }); 330 });
328 331
329 expectTestsPass("directory().load() fails to load a file that doesn't exist", 332 expectTestsPass("directory().load() fails to load a file that doesn't exist",
330 () { 333 () {
331 test('test', () { 334 test('test', () {
332 var dir = d.dir('dir', [d.file('name.txt', 'contents')]); 335 var dir = d.dir('dir', [d.file('name.txt', 'contents')]);
333 336
334 expect(dir.load('not-name.txt').toList(), 337 expect(dir.load('not-name.txt').toList(), throwsA(allOf(
335 throwsA(equals("Couldn't find a readable entry named 'not-name.txt' " 338 new isInstanceOf<TestFailure>(),
336 "within 'dir'."))); 339 predicate((x) => x.message == "Couldn't find a readable entry "
340 "named 'not-name.txt' within 'dir'.")))) ;
337 }); 341 });
338 }); 342 });
339 343
340 expectTestsPass("directory().load() fails to load a file that exists " 344 expectTestsPass("directory().load() fails to load a file that exists "
341 "multiple times", () { 345 "multiple times", () {
342 test('test', () { 346 test('test', () {
343 var dir = d.dir('dir', [ 347 var dir = d.dir('dir', [
344 d.file('name.txt', 'contents'), 348 d.file('name.txt', 'contents'),
345 d.file('name.txt', 'contents') 349 d.file('name.txt', 'contents')
346 ]); 350 ]);
347 351
348 expect(dir.load('name.txt').toList(), 352 expect(dir.load('name.txt').toList(), throwsA(allOf(
349 throwsA(equals("Found multiple readable entries named 'name.txt' " 353 new isInstanceOf<TestFailure>(),
350 "within 'dir'."))); 354 predicate((x) => x.message ==
355 "Found multiple readable entries named 'name.txt' within 'dir'.")) ));
351 }); 356 });
352 }); 357 });
353 358
354 expectTestsPass("directory().load() loads a file next to a subdirectory with " 359 expectTestsPass("directory().load() loads a file next to a subdirectory with "
355 "the same name", () { 360 "the same name", () {
356 test('test', () { 361 test('test', () {
357 var dir = d.dir('dir', [ 362 var dir = d.dir('dir', [
358 d.file('name', 'contents'), 363 d.file('name', 'contents'),
359 d.dir('name', [d.file('subfile', 'contents')]) 364 d.dir('name', [d.file('subfile', 'contents')])
360 ]); 365 ]);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 "'-- file2.txt")); 410 "'-- file2.txt"));
406 }); 411 });
407 }); 412 });
408 413
409 expectTestsPass("directory().describe() with no contents returns the " 414 expectTestsPass("directory().describe() with no contents returns the "
410 "directory name", () { 415 "directory name", () {
411 test('test', () { 416 test('test', () {
412 expect(d.dir('dir').describe(), equals('dir')); 417 expect(d.dir('dir').describe(), equals('dir'));
413 }); 418 });
414 }); 419 });
415 } 420 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698