| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library testing.test_description; | 5 library testing.test_description; |
| 6 | 6 |
| 7 import 'dart:io' show | 7 import 'dart:io' show File, FileSystemEntity; |
| 8 File, | |
| 9 FileSystemEntity; | |
| 10 | 8 |
| 11 class TestDescription implements Comparable<TestDescription> { | 9 class TestDescription implements Comparable<TestDescription> { |
| 12 final Uri root; | 10 final Uri root; |
| 13 final File file; | 11 final File file; |
| 14 final Uri output; | 12 final Uri output; |
| 15 | 13 |
| 16 /// If non-null, this is a generated multitest, and the set contains the | 14 /// If non-null, this is a generated multitest, and the set contains the |
| 17 /// expected outcomes. | 15 /// expected outcomes. |
| 18 Set<String> multitestExpectations; | 16 Set<String> multitestExpectations; |
| 19 | 17 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 } | 35 } |
| 38 | 36 |
| 39 void writeClosureOn(StringSink sink) { | 37 void writeClosureOn(StringSink sink) { |
| 40 sink.write(' "'); | 38 sink.write(' "'); |
| 41 sink.write(shortName); | 39 sink.write(shortName); |
| 42 sink.write('": '); | 40 sink.write('": '); |
| 43 sink.write(escapedName); | 41 sink.write(escapedName); |
| 44 sink.writeln('.main,'); | 42 sink.writeln('.main,'); |
| 45 } | 43 } |
| 46 | 44 |
| 47 static TestDescription from( | 45 static TestDescription from(Uri root, FileSystemEntity entity, |
| 48 Uri root, FileSystemEntity entity, {Pattern pattern}) { | 46 {Pattern pattern}) { |
| 49 if (entity is! File) return null; | 47 if (entity is! File) return null; |
| 50 pattern ??= "_test.dart"; | 48 pattern ??= "_test.dart"; |
| 51 String path = entity.uri.path; | 49 String path = entity.uri.path; |
| 52 bool hasMatch = false; | 50 bool hasMatch = false; |
| 53 if (pattern is String) { | 51 if (pattern is String) { |
| 54 if (path.endsWith(pattern)) hasMatch = true; | 52 if (path.endsWith(pattern)) hasMatch = true; |
| 55 } else if (path.contains(pattern)) { | 53 } else if (path.contains(pattern)) { |
| 56 hasMatch = true; | 54 hasMatch = true; |
| 57 } | 55 } |
| 58 return hasMatch ? new TestDescription(root, entity) : null; | 56 return hasMatch ? new TestDescription(root, entity) : null; |
| 59 } | 57 } |
| 60 | 58 |
| 61 int compareTo(TestDescription other) => "$uri".compareTo("${other.uri}"); | 59 int compareTo(TestDescription other) => "$uri".compareTo("${other.uri}"); |
| 62 | 60 |
| 63 String formatError(String message) { | 61 String formatError(String message) { |
| 64 String base = Uri.base.toFilePath(); | 62 String base = Uri.base.toFilePath(); |
| 65 String path = uri.toFilePath(); | 63 String path = uri.toFilePath(); |
| 66 if (path.startsWith(base)) { | 64 if (path.startsWith(base)) { |
| 67 path = path.substring(base.length); | 65 path = path.substring(base.length); |
| 68 } | 66 } |
| 69 return "$path:$message"; | 67 return "$path:$message"; |
| 70 } | 68 } |
| 71 } | 69 } |
| OLD | NEW |