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

Side by Side Diff: pkg/scheduled_test/test/descriptor_test.dart

Issue 12440054: Properly collate multiple directory validation errors in scheduled_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 9 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
« no previous file with comments | « pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart ('k') | no next file » | 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) 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 library descriptor_test; 5 library descriptor_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import '../../../pkg/pathos/lib/path.dart' as path; 10 import '../../../pkg/pathos/lib/path.dart' as path;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 d.file('subfile2.txt', 'subcontents2') 288 d.file('subfile2.txt', 'subcontents2')
289 ]), 289 ]),
290 d.file('file1.txt', 'contents1'), 290 d.file('file1.txt', 'contents1'),
291 d.file('file2.txt', 'contents2') 291 d.file('file2.txt', 'contents2')
292 ]).validate(); 292 ]).validate();
293 }); 293 });
294 294
295 test('test 2', () { 295 test('test 2', () {
296 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 296 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
297 expect(errors.length, equals(1)); 297 expect(errors.length, equals(1));
298 expect(errors.first.error, 298 expect(errors.first.error.toString(),
299 matches(r"^Directory not found: '[^']+[\\/]dir[\\/]subdir'\.$")); 299 matches(r"^Directory not found: '[^']+[\\/]dir[\\/]subdir'\.$"));
300 }); 300 });
301 }, passing: ['test 2']); 301 }, passing: ['test 2']);
302 302
303 expectTestsPass("directory().validate() fails if a file isn't found", () { 303 expectTestsPass("directory().validate() fails if a file isn't found", () {
304 var errors; 304 var errors;
305 test('test 1', () { 305 test('test 1', () {
306 scheduleSandbox(); 306 scheduleSandbox();
307 307
308 currentSchedule.onException.schedule(() { 308 currentSchedule.onException.schedule(() {
(...skipping 21 matching lines...) Expand all
330 d.file('subfile2.txt', 'subcontents2') 330 d.file('subfile2.txt', 'subcontents2')
331 ]), 331 ]),
332 d.file('file1.txt', 'contents1'), 332 d.file('file1.txt', 'contents1'),
333 d.file('file2.txt', 'contents2') 333 d.file('file2.txt', 'contents2')
334 ]).validate(); 334 ]).validate();
335 }); 335 });
336 336
337 test('test 2', () { 337 test('test 2', () {
338 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 338 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
339 expect(errors.length, equals(1)); 339 expect(errors.length, equals(1));
340 expect(errors.first.error, 340 expect(errors.first.error.toString(),
341 matches(r"^File not found: '[^']+[\\/]dir[\\/]file2\.txt'\.$")); 341 matches(r"^File not found: '[^']+[\\/]dir[\\/]file2\.txt'\.$"));
342 }); 342 });
343 }, passing: ['test 2']); 343 }, passing: ['test 2']);
344 344
345 expectTestsPass("directory().validate() fails if multiple children aren't "
346 "found or have the wrong contents", () {
347 var errors;
348 test('test 1', () {
349 scheduleSandbox();
350
351 currentSchedule.onException.schedule(() {
352 errors = currentSchedule.errors;
353 });
354
355 schedule(() {
356 var dirPath = path.join(sandbox, 'dir');
357 var subdirPath = path.join(dirPath, 'subdir');
358 return new Directory(subdirPath).create(recursive: true).then((_) {
359 return Future.wait([
360 new File(path.join(dirPath, 'file1.txt'))
361 .writeAsString('contents1'),
362 new File(path.join(subdirPath, 'subfile2.txt'))
363 .writeAsString('subwrongtents2')
364 ]);
365 });
366 });
367
368 d.dir('dir', [
369 d.dir('subdir', [
370 d.file('subfile1.txt', 'subcontents1'),
371 d.file('subfile2.txt', 'subcontents2')
372 ]),
373 d.file('file1.txt', 'contents1'),
374 d.file('file2.txt', 'contents2')
375 ]).validate();
376 });
377
378 test('test 2', () {
379 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
380 expect(errors.length, equals(1));
381 expect(errors.first.error.toString(), matches(
382 r"^\* File not found: '[^']+[\\/]dir[\\/]subdir[\\/]subfile1\.txt'\."
383 r"\n"
384 r"\* File 'subfile2\.txt' should contain:\n"
385 r" \| subcontents2\n"
386 r" but actually contained:\n"
387 r" X subwrongtents2\n"
388 r"\* File not found: '[^']+[\\/]dir[\\/]file2\.txt'\.$"));
389 });
390 }, passing: ['test 2']);
391
345 expectTestsPass("directory().validate() fails if a file has the wrong " 392 expectTestsPass("directory().validate() fails if a file has the wrong "
346 "contents", () { 393 "contents", () {
347 var errors; 394 var errors;
348 test('test 1', () { 395 test('test 1', () {
349 scheduleSandbox(); 396 scheduleSandbox();
350 397
351 currentSchedule.onException.schedule(() { 398 currentSchedule.onException.schedule(() {
352 errors = currentSchedule.errors; 399 errors = currentSchedule.errors;
353 }); 400 });
354 401
(...skipping 19 matching lines...) Expand all
374 d.file('subfile1.txt', 'subcontents1'), 421 d.file('subfile1.txt', 'subcontents1'),
375 d.file('subfile2.txt', 'subcontents2') 422 d.file('subfile2.txt', 'subcontents2')
376 ]), 423 ]),
377 d.file('file1.txt', 'contents1'), 424 d.file('file1.txt', 'contents1'),
378 d.file('file2.txt', 'contents2') 425 d.file('file2.txt', 'contents2')
379 ]).validate(); 426 ]).validate();
380 }); 427 });
381 428
382 test('test 2', () { 429 test('test 2', () {
383 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 430 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
384 expect(errors.map((e) => e.error), equals([ 431 expect(errors.map((e) => e.error.toString()), equals([
385 "File 'subfile1.txt' should contain:\n" 432 "File 'subfile1.txt' should contain:\n"
386 "| subcontents1\n" 433 "| subcontents1\n"
387 "but actually contained:\n" 434 "but actually contained:\n"
388 "X wrongtents1" 435 "X wrongtents1"
389 ])); 436 ]));
390 }); 437 });
391 }, passing: ['test 2']); 438 }, passing: ['test 2']);
392 439
393 expectTestsPass("directory().load() loads a file", () { 440 expectTestsPass("directory().load() loads a file", () {
394 test('test', () { 441 test('test', () {
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 964
918 Future<List<int>> byteStreamToList(Stream<List<int>> stream) { 965 Future<List<int>> byteStreamToList(Stream<List<int>> stream) {
919 return stream.reduce(<int>[], (buffer, chunk) { 966 return stream.reduce(<int>[], (buffer, chunk) {
920 buffer.addAll(chunk); 967 buffer.addAll(chunk);
921 return buffer; 968 return buffer;
922 }); 969 });
923 } 970 }
924 971
925 Future<String> byteStreamToString(Stream<List<int>> stream) => 972 Future<String> byteStreamToString(Stream<List<int>> stream) =>
926 byteStreamToList(stream).then((bytes) => new String.fromCharCodes(bytes)); 973 byteStreamToList(stream).then((bytes) => new String.fromCharCodes(bytes));
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/descriptor/directory_descriptor.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698