From 2630361e204e7179017b79d2856d55e861f2fe62 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 20:44:36 +0000 Subject: [PATCH 01/18] add a test for running by absolute file: uri --- pkgs/test/test/runner/runner_test.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart index 19419afe8..9ac07658a 100644 --- a/pkgs/test/test/runner/runner_test.dart +++ b/pkgs/test/test/runner/runner_test.dart @@ -7,6 +7,7 @@ import 'dart:io'; import 'dart:math' as math; +import 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'package:test_core/src/util/exit_codes.dart' as exit_codes; import 'package:test_descriptor/test_descriptor.dart' as d; @@ -362,6 +363,14 @@ $_usage'''); expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); await test.shouldExit(0); }); + + test('given a file: uri on windows', () async { + await d.file('test.dart', _success).create(); + var path = p.absolute('test.dart'); + var test = await runTest(['file://$path']); + expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); + await test.shouldExit(0); + }, testOn: 'windows'); }); group('runs successful tests with async setup', () { From 349720231d9db3bac7b3a8e488dccaddceccc0b6 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 20:59:00 +0000 Subject: [PATCH 02/18] use p.url --- pkgs/test/test/runner/runner_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart index 9ac07658a..dd9827383 100644 --- a/pkgs/test/test/runner/runner_test.dart +++ b/pkgs/test/test/runner/runner_test.dart @@ -366,7 +366,7 @@ $_usage'''); test('given a file: uri on windows', () async { await d.file('test.dart', _success).create(); - var path = p.absolute('test.dart'); + var path = p.url.absolute('test.dart'); var test = await runTest(['file://$path']); expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); await test.shouldExit(0); From 3965b20fe7446296d63f38bade52b9b8a9edab87 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 21:19:58 +0000 Subject: [PATCH 03/18] run on all platforms, rely on p.toUri to create the file URI --- pkgs/test/test/runner/runner_test.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart index dd9827383..baac5faae 100644 --- a/pkgs/test/test/runner/runner_test.dart +++ b/pkgs/test/test/runner/runner_test.dart @@ -366,11 +366,10 @@ $_usage'''); test('given a file: uri on windows', () async { await d.file('test.dart', _success).create(); - var path = p.url.absolute('test.dart'); - var test = await runTest(['file://$path']); + var test = await runTest([p.toUri(p.absolute('test.dart')).toString()]); expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); await test.shouldExit(0); - }, testOn: 'windows'); + }); }); group('runs successful tests with async setup', () { From ab1ac622ca5c13872de0d295fc6efda44138ca6f Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 21:21:25 +0000 Subject: [PATCH 04/18] update test name, assert that the uri is in fact a file: uri --- pkgs/test/test/runner/runner_test.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart index baac5faae..24578b11f 100644 --- a/pkgs/test/test/runner/runner_test.dart +++ b/pkgs/test/test/runner/runner_test.dart @@ -364,9 +364,11 @@ $_usage'''); await test.shouldExit(0); }); - test('given a file: uri on windows', () async { + test('given a file: uri', () async { await d.file('test.dart', _success).create(); - var test = await runTest([p.toUri(p.absolute('test.dart')).toString()]); + var fileUri = p.toUri(p.absolute('test.dart')).toString(); + expect(fileUri, startsWith('file:///')); + var test = await runTest([fileUri]); expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); await test.shouldExit(0); }); From cf3f9f23bf077e15c4861f113b78d208cead4112 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 21:38:38 +0000 Subject: [PATCH 05/18] always parse test paths as uris and grab paths from that --- pkgs/test/test/runner/runner_test.dart | 2 +- pkgs/test_core/CHANGELOG.md | 1 + pkgs/test_core/lib/src/runner/configuration/args.dart | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart index 24578b11f..5f54976ad 100644 --- a/pkgs/test/test/runner/runner_test.dart +++ b/pkgs/test/test/runner/runner_test.dart @@ -366,7 +366,7 @@ $_usage'''); test('given a file: uri', () async { await d.file('test.dart', _success).create(); - var fileUri = p.toUri(p.absolute('test.dart')).toString(); + var fileUri = p.toUri(d.path('test.dart')).toString(); expect(fileUri, startsWith('file:///')); var test = await runTest([fileUri]); expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md index 3cfc241f2..84139d8a9 100644 --- a/pkgs/test_core/CHANGELOG.md +++ b/pkgs/test_core/CHANGELOG.md @@ -2,6 +2,7 @@ * Avoid empty expandable groups for tests without extra output in Github reporter. +* Always parse test paths as uris and grab the path from that. # 0.4.22 diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart index fcd2e89da..4d6a2875c 100644 --- a/pkgs/test_core/lib/src/runner/configuration/args.dart +++ b/pkgs/test_core/lib/src/runner/configuration/args.dart @@ -181,7 +181,7 @@ void _parseTestSelection( TestSelection selection; String path; if (firstQuestion == -1) { - path = option; + path = Uri.parse(option).path; selection = TestSelection(); } else if (option.substring(0, firstQuestion).contains('\\')) { throw FormatException( From 5912d653f57776405d736a0db8af67ac1e097b95 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 21:41:57 +0000 Subject: [PATCH 06/18] add a test for running paths with a relative windows path --- pkgs/test/test/runner/runner_test.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart index 5f54976ad..a96a94d6c 100644 --- a/pkgs/test/test/runner/runner_test.dart +++ b/pkgs/test/test/runner/runner_test.dart @@ -372,6 +372,13 @@ $_usage'''); expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); await test.shouldExit(0); }); + + test('with windows style (\\) relative paths', () async { + await d.file('foo/test.dart', _success).create(); + var test = await runTest(['foo\\test.dart']); + expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); + await test.shouldExit(0); + }, testOn: 'windows'); }); group('runs successful tests with async setup', () { From b33927fdec35136f7f9b2a1e90b82052d279656c Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 22:05:39 +0000 Subject: [PATCH 07/18] update to use d.dir to create the root dir --- pkgs/test/test/runner/runner_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart index a96a94d6c..260f37c17 100644 --- a/pkgs/test/test/runner/runner_test.dart +++ b/pkgs/test/test/runner/runner_test.dart @@ -374,7 +374,7 @@ $_usage'''); }); test('with windows style (\\) relative paths', () async { - await d.file('foo/test.dart', _success).create(); + await d.dir('foo', [d.file('test.dart', _success)]).create(); var test = await runTest(['foo\\test.dart']); expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); await test.shouldExit(0); From 7d1777399dd713b10484788fb5e0c45f780ea139 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 22:28:46 +0000 Subject: [PATCH 08/18] only parse as a Uri if it looks like it has a scheme --- pkgs/test_core/lib/src/runner/configuration/args.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart index 4d6a2875c..79e448746 100644 --- a/pkgs/test_core/lib/src/runner/configuration/args.dart +++ b/pkgs/test_core/lib/src/runner/configuration/args.dart @@ -181,7 +181,15 @@ void _parseTestSelection( TestSelection selection; String path; if (firstQuestion == -1) { - path = Uri.parse(option).path; + if (option.contains('://')) { + path = Uri.parse(option).path; + // Strip out the leading slash before the drive letter. + if (Platform.isWindows && path.startsWith('/')) { + path = path.substring(1); + } + } else { + path = option; + } selection = TestSelection(); } else if (option.substring(0, firstQuestion).contains('\\')) { throw FormatException( From 4aa293485cf3bf3d25a93f86339fa07cc1c1b698 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 22:48:23 +0000 Subject: [PATCH 09/18] update changelog --- pkgs/test_core/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md index 84139d8a9..c62e1ad46 100644 --- a/pkgs/test_core/CHANGELOG.md +++ b/pkgs/test_core/CHANGELOG.md @@ -2,7 +2,7 @@ * Avoid empty expandable groups for tests without extra output in Github reporter. -* Always parse test paths as uris and grab the path from that. +* Support running tests by absolute file uri. # 0.4.22 From 847de6fda2cfe8ef4ecf5e093692e467a885e103 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 1 Feb 2023 22:49:27 +0000 Subject: [PATCH 10/18] copy changelog entry to package:test as well --- pkgs/test/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index 2a5651c51..cce2035b5 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -4,6 +4,7 @@ reporter. * Add support for CHROME_EXECUTABLE environment variable. This overrides any config file settings. +* Support running tests by absolute file uri. ## 1.22.2 From b3b958db026c4d3da0a21c49505979f1f35c89a2 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Thu, 2 Feb 2023 15:35:46 +0000 Subject: [PATCH 11/18] simplify logic a bit, unify URI parsing --- .../lib/src/runner/configuration/args.dart | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart index 79e448746..3839e7485 100644 --- a/pkgs/test_core/lib/src/runner/configuration/args.dart +++ b/pkgs/test_core/lib/src/runner/configuration/args.dart @@ -180,20 +180,13 @@ void _parseTestSelection( var firstQuestion = option.indexOf('?'); TestSelection selection; String path; - if (firstQuestion == -1) { - if (option.contains('://')) { - path = Uri.parse(option).path; - // Strip out the leading slash before the drive letter. - if (Platform.isWindows && path.startsWith('/')) { - path = path.substring(1); - } - } else { - path = option; - } + if (firstQuestion == -1 && !option.contains('://')) { + path = option; selection = TestSelection(); - } else if (option.substring(0, firstQuestion).contains('\\')) { + } else if (firstQuestion != -1 && + option.substring(0, firstQuestion).contains('\\')) { throw FormatException( - 'When passing test path queries, you must pass the path in URI ' + 'When passing test path uris, you must pass the path in URI ' 'format (use `/` for directory separators instead of `\\`).'); } else { final uri = Uri.parse(option); @@ -209,6 +202,10 @@ void _parseTestSelection( ); } path = uri.path; + // Strip out the leading slash before the drive letter on windows. + if (Platform.isWindows && path.startsWith('/')) { + path = path.substring(1); + } selection = TestSelection( testPatterns: fullName != null ? {RegExp('^${RegExp.escape(fullName)}\$')} From 4d2e5809575f34046d49cbb81873e44163af9e4a Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Thu, 2 Feb 2023 15:49:47 +0000 Subject: [PATCH 12/18] further simplify logic, always parse test paths as URIs, but decode the path component when extracting it --- .../lib/src/runner/configuration/args.dart | 61 ++++++++----------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart index 3839e7485..c3f04ab42 100644 --- a/pkgs/test_core/lib/src/runner/configuration/args.dart +++ b/pkgs/test_core/lib/src/runner/configuration/args.dart @@ -177,46 +177,35 @@ Configuration parse(List args) => _Parser(args).parse(); void _parseTestSelection( String option, Map> selections) { - var firstQuestion = option.indexOf('?'); - TestSelection selection; - String path; - if (firstQuestion == -1 && !option.contains('://')) { - path = option; - selection = TestSelection(); - } else if (firstQuestion != -1 && - option.substring(0, firstQuestion).contains('\\')) { - throw FormatException( - 'When passing test path uris, you must pass the path in URI ' - 'format (use `/` for directory separators instead of `\\`).'); - } else { - final uri = Uri.parse(option); + final uri = Uri.parse(option); + // Restore the path to how it was given (namely, we want to report paths + // with their original separators). + var path = Uri.decodeComponent(uri.path); + // Strip out the leading slash before the drive letter on windows. + if (Platform.isWindows && path.startsWith('/')) { + path = path.substring(1); + } - final names = uri.queryParametersAll['name']; - final fullName = uri.queryParameters['full-name']; - final line = uri.queryParameters['line']; - final col = uri.queryParameters['col']; + final names = uri.queryParametersAll['name']; + final fullName = uri.queryParameters['full-name']; + final line = uri.queryParameters['line']; + final col = uri.queryParameters['col']; - if (names != null && names.isNotEmpty && fullName != null) { - throw FormatException( - 'Cannot specify both "name=<...>" and "full-name=<...>".', - ); - } - path = uri.path; - // Strip out the leading slash before the drive letter on windows. - if (Platform.isWindows && path.startsWith('/')) { - path = path.substring(1); - } - selection = TestSelection( - testPatterns: fullName != null - ? {RegExp('^${RegExp.escape(fullName)}\$')} - : { - if (names != null) - for (var name in names) RegExp(name) - }, - line: line == null ? null : int.parse(line), - col: col == null ? null : int.parse(col), + if (names != null && names.isNotEmpty && fullName != null) { + throw FormatException( + 'Cannot specify both "name=<...>" and "full-name=<...>".', ); } + final selection = TestSelection( + testPatterns: fullName != null + ? {RegExp('^${RegExp.escape(fullName)}\$')} + : { + if (names != null) + for (var name in names) RegExp(name) + }, + line: line == null ? null : int.parse(line), + col: col == null ? null : int.parse(col), + ); selections.update(path, (selections) => selections..add(selection), ifAbsent: () => {selection}); From 8e87f7f63e6ec52a9ef5074b4b71545c37aa50d1 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Thu, 2 Feb 2023 16:16:38 +0000 Subject: [PATCH 13/18] update tests to always expect test path outputs to be in URI format --- .../runner/configuration/platform_test.dart | 12 +++---- .../configuration/randomize_order_test.dart | 12 +++---- pkgs/test/test/runner/shard_test.dart | 36 +++++++------------ .../lib/src/runner/configuration/args.dart | 4 +-- 4 files changed, 23 insertions(+), 41 deletions(-) diff --git a/pkgs/test/test/runner/configuration/platform_test.dart b/pkgs/test/test/runner/configuration/platform_test.dart index 0a9f42794..f2b965e50 100644 --- a/pkgs/test/test/runner/configuration/platform_test.dart +++ b/pkgs/test/test/runner/configuration/platform_test.dart @@ -205,10 +205,8 @@ void main() { var test = await runTest(['.']); expect( test.stdout, - containsInOrder([ - '+0: .${Platform.pathSeparator}test_foo.dart: test_foo', - '+1: All tests passed!' - ])); + containsInOrder( + ['+0: ./test_foo.dart: test_foo', '+1: All tests passed!'])); await test.shouldExit(0); }); @@ -243,10 +241,8 @@ void main() { var test = await runTest(['.']); expect( test.stdout, - containsInOrder([ - '+0: .${Platform.pathSeparator}foo_test.dart: foo_test', - '+1: All tests passed!' - ])); + containsInOrder( + ['+0: ./foo_test.dart: foo_test', '+1: All tests passed!'])); await test.shouldExit(0); }); diff --git a/pkgs/test/test/runner/configuration/randomize_order_test.dart b/pkgs/test/test/runner/configuration/randomize_order_test.dart index c7cf3f1eb..a9fffa8a4 100644 --- a/pkgs/test/test/runner/configuration/randomize_order_test.dart +++ b/pkgs/test/test/runner/configuration/randomize_order_test.dart @@ -148,14 +148,14 @@ void main() { test.stdout, emitsInAnyOrder([ containsInOrder([ - '.${Platform.pathSeparator}1_test.dart: test 1.2', - '.${Platform.pathSeparator}1_test.dart: test 1.3', - '.${Platform.pathSeparator}1_test.dart: test 1.1' + './1_test.dart: test 1.2', + './1_test.dart: test 1.3', + './1_test.dart: test 1.1' ]), containsInOrder([ - '.${Platform.pathSeparator}2_test.dart: test 2.2', - '.${Platform.pathSeparator}2_test.dart: test 2.3', - '.${Platform.pathSeparator}2_test.dart: test 2.1' + './2_test.dart: test 2.2', + './2_test.dart: test 2.3', + './2_test.dart: test 2.1' ]), contains('+6: All tests passed!') ])); diff --git a/pkgs/test/test/runner/shard_test.dart b/pkgs/test/test/runner/shard_test.dart index 0d1f72b87..3e359eab6 100644 --- a/pkgs/test/test/runner/shard_test.dart +++ b/pkgs/test/test/runner/shard_test.dart @@ -95,14 +95,10 @@ void main() { test.stdout, emitsInOrder([ emitsAnyOf([ - containsInOrder([ - '+0: .${Platform.pathSeparator}1_test.dart: test 1.1', - '+1: .${Platform.pathSeparator}2_test.dart: test 2.1' - ]), - containsInOrder([ - '+0: .${Platform.pathSeparator}2_test.dart: test 2.1', - '+1: .${Platform.pathSeparator}1_test.dart: test 1.1' - ]) + containsInOrder( + ['+0: ./1_test.dart: test 1.1', '+1: ./2_test.dart: test 2.1']), + containsInOrder( + ['+0: ./2_test.dart: test 2.1', '+1: ./1_test.dart: test 1.1']) ]), contains('+2: All tests passed!') ])); @@ -113,14 +109,10 @@ void main() { test.stdout, emitsInOrder([ emitsAnyOf([ - containsInOrder([ - '+0: .${Platform.pathSeparator}1_test.dart: test 1.2', - '+1: .${Platform.pathSeparator}2_test.dart: test 2.2' - ]), - containsInOrder([ - '+0: .${Platform.pathSeparator}2_test.dart: test 2.2', - '+1: .${Platform.pathSeparator}1_test.dart: test 1.2' - ]) + containsInOrder( + ['+0: ./1_test.dart: test 1.2', '+1: ./2_test.dart: test 2.2']), + containsInOrder( + ['+0: ./2_test.dart: test 2.2', '+1: ./1_test.dart: test 1.2']) ]), contains('+2: All tests passed!') ])); @@ -131,14 +123,10 @@ void main() { test.stdout, emitsInOrder([ emitsAnyOf([ - containsInOrder([ - '+0: .${Platform.pathSeparator}1_test.dart: test 1.3', - '+1: .${Platform.pathSeparator}2_test.dart: test 2.3' - ]), - containsInOrder([ - '+0: .${Platform.pathSeparator}2_test.dart: test 2.3', - '+1: .${Platform.pathSeparator}1_test.dart: test 1.3' - ]) + containsInOrder( + ['+0: ./1_test.dart: test 1.3', '+1: ./2_test.dart: test 2.3']), + containsInOrder( + ['+0: ./2_test.dart: test 2.3', '+1: ./1_test.dart: test 1.3']) ]), contains('+2: All tests passed!') ])); diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart index c3f04ab42..78d28e320 100644 --- a/pkgs/test_core/lib/src/runner/configuration/args.dart +++ b/pkgs/test_core/lib/src/runner/configuration/args.dart @@ -178,9 +178,7 @@ Configuration parse(List args) => _Parser(args).parse(); void _parseTestSelection( String option, Map> selections) { final uri = Uri.parse(option); - // Restore the path to how it was given (namely, we want to report paths - // with their original separators). - var path = Uri.decodeComponent(uri.path); + var path = uri.path; // Strip out the leading slash before the drive letter on windows. if (Platform.isWindows && path.startsWith('/')) { path = path.substring(1); From e118ac755180fa6c074b50d4ce87276dceaac1b9 Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Thu, 2 Feb 2023 16:19:40 +0000 Subject: [PATCH 14/18] remove unused imports --- pkgs/test/test/runner/configuration/platform_test.dart | 1 - pkgs/test/test/runner/configuration/randomize_order_test.dart | 1 - pkgs/test/test/runner/shard_test.dart | 3 --- 3 files changed, 5 deletions(-) diff --git a/pkgs/test/test/runner/configuration/platform_test.dart b/pkgs/test/test/runner/configuration/platform_test.dart index f2b965e50..d3d7e92c5 100644 --- a/pkgs/test/test/runner/configuration/platform_test.dart +++ b/pkgs/test/test/runner/configuration/platform_test.dart @@ -4,7 +4,6 @@ @TestOn('vm') import 'dart:convert'; -import 'dart:io'; import 'package:test/test.dart'; import 'package:test_core/src/util/exit_codes.dart' as exit_codes; diff --git a/pkgs/test/test/runner/configuration/randomize_order_test.dart b/pkgs/test/test/runner/configuration/randomize_order_test.dart index a9fffa8a4..4908eb299 100644 --- a/pkgs/test/test/runner/configuration/randomize_order_test.dart +++ b/pkgs/test/test/runner/configuration/randomize_order_test.dart @@ -4,7 +4,6 @@ @TestOn('vm') import 'dart:convert'; -import 'dart:io'; import 'package:test/test.dart'; import 'package:test_descriptor/test_descriptor.dart' as d; diff --git a/pkgs/test/test/runner/shard_test.dart b/pkgs/test/test/runner/shard_test.dart index 3e359eab6..33b5d460e 100644 --- a/pkgs/test/test/runner/shard_test.dart +++ b/pkgs/test/test/runner/shard_test.dart @@ -3,9 +3,6 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') - -import 'dart:io'; - import 'package:test/test.dart'; import 'package:test_core/src/util/exit_codes.dart' as exit_codes; import 'package:test_descriptor/test_descriptor.dart' as d; From 605dd1dfc82b50288a0075865ab5069e51af6d4d Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Thu, 2 Feb 2023 16:42:49 +0000 Subject: [PATCH 15/18] restore decodeComponent logic, add test for windows style path with query params --- pkgs/test/test/runner/runner_test.dart | 14 +++++++++++--- .../lib/src/runner/configuration/args.dart | 4 +++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart index 260f37c17..9fef3fee9 100644 --- a/pkgs/test/test/runner/runner_test.dart +++ b/pkgs/test/test/runner/runner_test.dart @@ -373,12 +373,20 @@ $_usage'''); await test.shouldExit(0); }); - test('with windows style (\\) relative paths', () async { + test('with platform specific relative paths', () async { await d.dir('foo', [d.file('test.dart', _success)]).create(); - var test = await runTest(['foo\\test.dart']); + var test = await runTest([p.join('foo', 'test.dart')]); expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); await test.shouldExit(0); - }, testOn: 'windows'); + }); + + test('with platform specific relative paths containing query params', + () async { + await d.dir('foo', [d.file('test.dart', _success)]).create(); + var test = await runTest(['${p.join('foo', 'test.dart')}?line=6']); + expect(test.stdout, emitsThrough(contains('+1: All tests passed!'))); + await test.shouldExit(0); + }); }); group('runs successful tests with async setup', () { diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart index 78d28e320..c3f04ab42 100644 --- a/pkgs/test_core/lib/src/runner/configuration/args.dart +++ b/pkgs/test_core/lib/src/runner/configuration/args.dart @@ -178,7 +178,9 @@ Configuration parse(List args) => _Parser(args).parse(); void _parseTestSelection( String option, Map> selections) { final uri = Uri.parse(option); - var path = uri.path; + // Restore the path to how it was given (namely, we want to report paths + // with their original separators). + var path = Uri.decodeComponent(uri.path); // Strip out the leading slash before the drive letter on windows. if (Platform.isWindows && path.startsWith('/')) { path = path.substring(1); From a499e1303b0a38b8ac211681fdbc47030acaeb69 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 3 Feb 2023 13:56:46 -0800 Subject: [PATCH 16/18] fix windows, try removing decodeComponent logic again --- pkgs/test_core/lib/src/runner.dart | 3 ++- pkgs/test_core/lib/src/runner/configuration/args.dart | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkgs/test_core/lib/src/runner.dart b/pkgs/test_core/lib/src/runner.dart index ae7d6ee8c..540e1b91c 100644 --- a/pkgs/test_core/lib/src/runner.dart +++ b/pkgs/test_core/lib/src/runner.dart @@ -317,7 +317,8 @@ class Runner { 'Cannot filter by line/column for this test suite, no suite' 'path available.'); } - var absoluteSuitePath = p.absolute(path); + // The absolute path as it will appear in stack traces. + var absoluteSuitePath = File(path).absolute.uri.toFilePath(); bool matchLineAndCol(Frame frame) { if (frame.uri.scheme != 'file' || diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart index c3f04ab42..78d28e320 100644 --- a/pkgs/test_core/lib/src/runner/configuration/args.dart +++ b/pkgs/test_core/lib/src/runner/configuration/args.dart @@ -178,9 +178,7 @@ Configuration parse(List args) => _Parser(args).parse(); void _parseTestSelection( String option, Map> selections) { final uri = Uri.parse(option); - // Restore the path to how it was given (namely, we want to report paths - // with their original separators). - var path = Uri.decodeComponent(uri.path); + var path = uri.path; // Strip out the leading slash before the drive letter on windows. if (Platform.isWindows && path.startsWith('/')) { path = path.substring(1); From b8f7c01002e919c1bc167a458cfd37e0582f0b74 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Fri, 3 Feb 2023 14:00:09 -0800 Subject: [PATCH 17/18] remove unused import --- pkgs/test_core/lib/src/runner.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/test_core/lib/src/runner.dart b/pkgs/test_core/lib/src/runner.dart index 540e1b91c..0c54015a1 100644 --- a/pkgs/test_core/lib/src/runner.dart +++ b/pkgs/test_core/lib/src/runner.dart @@ -7,7 +7,6 @@ import 'dart:io'; import 'package:async/async.dart'; import 'package:boolean_selector/boolean_selector.dart'; -import 'package:path/path.dart' as p; import 'package:stack_trace/stack_trace.dart'; // ignore: deprecated_member_use import 'package:test_api/backend.dart' From c7520bd7b0491fe894887a45d03f003d7c170b7b Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Mon, 6 Feb 2023 22:31:30 +0000 Subject: [PATCH 18/18] restore decodeComponent logic --- pkgs/test_core/lib/src/runner/configuration/args.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/test_core/lib/src/runner/configuration/args.dart b/pkgs/test_core/lib/src/runner/configuration/args.dart index 78d28e320..c3f04ab42 100644 --- a/pkgs/test_core/lib/src/runner/configuration/args.dart +++ b/pkgs/test_core/lib/src/runner/configuration/args.dart @@ -178,7 +178,9 @@ Configuration parse(List args) => _Parser(args).parse(); void _parseTestSelection( String option, Map> selections) { final uri = Uri.parse(option); - var path = uri.path; + // Restore the path to how it was given (namely, we want to report paths + // with their original separators). + var path = Uri.decodeComponent(uri.path); // Strip out the leading slash before the drive letter on windows. if (Platform.isWindows && path.startsWith('/')) { path = path.substring(1);