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

Side by Side Diff: pkg/scheduled_test/lib/src/descriptor/utils.dart

Issue 12326087: Ensure scheduled_test directory entries are sorted when displaying error messages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « no previous file | 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.utils; 5 library descriptor.utils;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:pathos/path.dart' as path; 9 import 'package:pathos/path.dart' as path;
10 10
(...skipping 11 matching lines...) Expand all
22 if (new File(path).existsSync() || new Directory(path).existsSync()) { 22 if (new File(path).existsSync() || new Directory(path).existsSync()) {
23 return path; 23 return path;
24 } 24 }
25 throw "$type not found: '$path'."; 25 throw "$type not found: '$path'.";
26 } 26 }
27 27
28 var matchingEntries = new Directory(parent).listSync() 28 var matchingEntries = new Directory(parent).listSync()
29 .map((entry) => entry is File ? entry.fullPathSync() : entry.path) 29 .map((entry) => entry is File ? entry.fullPathSync() : entry.path)
30 .where((entry) => entry.contains(pattern)) 30 .where((entry) => entry.contains(pattern))
31 .toList(); 31 .toList();
32 matchingEntries.sort();
32 33
33 if (matchingEntries.length == 0) { 34 if (matchingEntries.length == 0) {
34 throw "No entry found in '$parent' matching ${describePattern(pattern)}."; 35 throw "No entry found in '$parent' matching ${describePattern(pattern)}.";
35 } else if (matchingEntries.length > 1) { 36 } else if (matchingEntries.length > 1) {
36 throw "Multiple entries found in '$parent' matching " 37 throw "Multiple entries found in '$parent' matching "
37 "${describePattern(pattern)}:\n" 38 "${describePattern(pattern)}:\n"
38 "${matchingEntries.map((entry) => '* $entry').join('\n')}"; 39 "${matchingEntries.map((entry) => '* $entry').join('\n')}";
39 } else { 40 } else {
40 return matchingEntries.first; 41 return matchingEntries.first;
41 } 42 }
42 } 43 }
43 44
44 /// Returns a human-readable description of [pattern]. 45 /// Returns a human-readable description of [pattern].
45 String describePattern(Pattern pattern) { 46 String describePattern(Pattern pattern) {
46 if (pattern is String) return "'$pattern'"; 47 if (pattern is String) return "'$pattern'";
47 if (pattern is! RegExp) return '$pattern'; 48 if (pattern is! RegExp) return '$pattern';
48 49
49 var flags = new StringBuffer(); 50 var flags = new StringBuffer();
50 if (!pattern.isCaseSensitive) flags.add('i'); 51 if (!pattern.isCaseSensitive) flags.add('i');
51 if (pattern.isMultiLine) flags.add('m'); 52 if (pattern.isMultiLine) flags.add('m');
52 return '/${pattern.pattern}/$flags'; 53 return '/${pattern.pattern}/$flags';
53 } 54 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698