fix parsing of windows file paths into a URI (#1611)
https://github.com/dart-lang/test/issues/1614
diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md
index f17e0d1..6753d5b 100644
--- a/pkgs/test/CHANGELOG.md
+++ b/pkgs/test/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.19.1
+
+* Fix parsing of file paths into a URI on windows.
+
## 1.19.0
* Support query parameters `name`, `full-name`, `line`, and `col` on test paths,
diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml
index e892a46..cb7496f 100644
--- a/pkgs/test/pubspec.yaml
+++ b/pkgs/test/pubspec.yaml
@@ -1,5 +1,5 @@
name: test
-version: 1.19.0
+version: 1.19.1
description: >-
A full featured library for writing and running Dart tests across platforms.
repository: https://github.com/dart-lang/test/blob/master/pkgs/test
@@ -33,7 +33,7 @@
yaml: ^3.0.0
# Use an exact version until the test_api and test_core package are stable.
test_api: 0.4.6
- test_core: 0.4.6
+ test_core: 0.4.7
dev_dependencies:
fake_async: ^1.0.0
diff --git a/pkgs/test/test/runner/name_test.dart b/pkgs/test/test/runner/name_test.dart
index 301b21e..a11f45a 100644
--- a/pkgs/test/test/runner/name_test.dart
+++ b/pkgs/test/test/runner/name_test.dart
@@ -294,7 +294,7 @@
var test = await runTest(['test.dart?name=selected&full-name=selected 1']);
- await test.shouldExit(255);
+ await test.shouldExit(64);
});
group('with the --name flag,', () {
diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md
index 5ec11fa..1596b3a 100644
--- a/pkgs/test_core/CHANGELOG.md
+++ b/pkgs/test_core/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.4.7
+
+* Fix parsing of file paths into a URI on windows.
+
## 0.4.6
* Support query parameters `name`, `full-name`, `line`, and `col` on test paths,
diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart
index 71f4da3..59f8b94 100644
--- a/pkgs/test_core/lib/src/runner/configuration/args.dart
+++ b/pkgs/test_core/lib/src/runner/configuration/args.dart
@@ -175,6 +175,15 @@
Configuration parse(List<String> args) => _Parser(args).parse();
PathConfiguration _parsePathConfiguration(String option) {
+ var firstQuestion = option.indexOf('?');
+ if (firstQuestion == -1) {
+ return PathConfiguration(testPath: option);
+ } else if (option.substring(0, firstQuestion).contains('\\')) {
+ throw FormatException(
+ 'When passing test path queries, you must pass the path in URI '
+ 'format (use `/` for directory separators instead of `\\`).');
+ }
+
final uri = Uri.parse(option);
final names = uri.queryParametersAll['name'];
@@ -210,8 +219,9 @@
/// Returns the parsed configuration.
Configuration parse() {
var patterns = (_options['name'] as List<String>)
- .map<Pattern>(
- (value) => _wrapFormatException('name', () => RegExp(value)))
+ .map<Pattern>((value) => _wrapFormatException(
+ value, () => RegExp(value),
+ optionName: 'name'))
.toList()
..addAll(_options['plain-name'] as List<String>);
@@ -342,7 +352,8 @@
var value = _options[name];
if (value == null) return null;
- return _wrapFormatException(name, () => parse(value as String));
+ return _wrapFormatException(value, () => parse(value as String),
+ optionName: name);
}
Map<String, String>? _parseFileReporterOption() =>
@@ -362,11 +373,13 @@
/// Runs [parse], and wraps any [FormatException] it throws with additional
/// information.
- T _wrapFormatException<T>(String name, T Function() parse) {
+ T _wrapFormatException<T>(Object? value, T Function() parse,
+ {String? optionName}) {
try {
return parse();
} on FormatException catch (error) {
- throw FormatException('Couldn\'t parse --$name "${_options[name]}": '
+ throw FormatException(
+ 'Couldn\'t parse ${optionName == null ? '' : '--$optionName '}"$value": '
'${error.message}');
}
}
diff --git a/pkgs/test_core/pubspec.yaml b/pkgs/test_core/pubspec.yaml
index 46296a8..66e4522 100644
--- a/pkgs/test_core/pubspec.yaml
+++ b/pkgs/test_core/pubspec.yaml
@@ -1,5 +1,5 @@
name: test_core
-version: 0.4.6
+version: 0.4.7
description: A basic library for writing tests and running them on the VM.
homepage: https://github.com/dart-lang/test/blob/master/pkgs/test_core