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

Unified Diff: pkg/scheduled_test/lib/src/descriptor/utils.dart

Issue 12853005: Change the way Patterns work in scheduled_test/descriptor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add Nothing.validateNow. 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 side-by-side diff with in-line comments
Download patch
Index: pkg/scheduled_test/lib/src/descriptor/utils.dart
diff --git a/pkg/scheduled_test/lib/src/descriptor/utils.dart b/pkg/scheduled_test/lib/src/descriptor/utils.dart
deleted file mode 100644
index c53b429dfbc899111744ceac9677643ee35e7f0a..0000000000000000000000000000000000000000
--- a/pkg/scheduled_test/lib/src/descriptor/utils.dart
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library descriptor.utils;
-
-import 'dart:io';
-
-import '../../../../../pkg/pathos/lib/path.dart' as path;
-
-/// Returns a single filesystem entry within [parent] whose name matches
-/// [pattern]. If [pattern] is a string, looks for an exact match; otherwise,
-/// looks for an entry that contains [pattern].
-///
-/// If there are no entries in [parent] matching [pattern], or more than one,
-/// this will throw an exception.
-///
-/// [type] is used for error reporting. It should be capitalized.
-String entryMatchingPattern(String type, String parent, Pattern pattern) {
- if (pattern is String) {
- var fullPath = path.join(parent, pattern);
- if (new File(fullPath).existsSync() || new Directory(fullPath).existsSync()) {
- return fullPath;
- }
- throw "$type not found: '$fullPath'.";
- }
-
- var matchingEntries = new Directory(parent).listSync()
- .map((entry) => entry is File ? entry.fullPathSync() : entry.path)
- .where((entry) => path.basename(entry).contains(pattern))
- .toList();
- matchingEntries.sort();
-
- if (matchingEntries.length == 0) {
- throw "No entry found in '$parent' matching ${describePattern(pattern)}.";
- } else if (matchingEntries.length > 1) {
- throw "Multiple entries found in '$parent' matching "
- "${describePattern(pattern)}:\n"
- "${matchingEntries.map((entry) => '* $entry').join('\n')}";
- } else {
- return matchingEntries.first;
- }
-}
-
-/// Returns a human-readable description of [pattern].
-String describePattern(Pattern pattern) {
- if (pattern is String) return "'$pattern'";
- if (pattern is! RegExp) return '$pattern';
-
- var flags = new StringBuffer();
- if (!pattern.isCaseSensitive) flags.write('i');
- if (pattern.isMultiLine) flags.write('m');
- return '/${pattern.pattern}/$flags';
-}

Powered by Google App Engine
This is Rietveld 408576698