Skip to content

Commit

Permalink
Fix some minor Windows issues (#6783)
Browse files Browse the repository at this point in the history
`Uri.parse()` shouldn't be used with file paths for Windows (should use `Uri.file()`) + tweak some tests to always use posix paths in strings that are checked so that they're consistent across platforms.
  • Loading branch information
DanTup authored Nov 21, 2023
1 parent 139b614 commit 89c7a48
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions packages/devtools_shared/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 6.0.2
* Fix an issue parsing file paths on Windows that could prevent extensions from being detected.

# 6.0.1
* Bump minimum Dart SDK version to `3.3.0-91.0.dev` and minimum Flutter SDK version to `3.17.0-0.0.pre`.
* Add field `isPublic` to `DevToolsExtensionConfig`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ExtensionsManager {
try {
extensions = await findExtensions(
'devtools',
packageConfig: Uri.parse(
packageConfig: Uri.file(
path.join(
rootPath,
'.dart_tool',
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_shared/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: devtools_shared
description: Package of shared Dart structures between devtools_app, dds, and other tools.

version: 6.0.1
version: 6.0.2-wip

repository: https://github.com/flutter/devtools/tree/master/packages/devtools_shared

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
setUp(() {
options = DevToolsOptions();
tmpDir = Directory.current.createTempSync();
tmpUri = Uri.parse(tmpDir.path);
tmpUri = Uri.file(tmpDir.path);
});

tearDown(() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ void main() {

Directory _createFromDir() {
final from = Directory('tmp')..createSync();
File.fromUri(Uri.parse(p.join(from.path, 'foo.txt')))..createSync();
File(p.join(from.path, 'foo.txt'))..createSync();
final dir = Directory(p.join(from.path, 'bar'))..createSync();
File.fromUri(Uri.parse(p.join(dir.path, 'baz.txt')))..createSync();
File(p.join(dir.path, 'baz.txt'))..createSync();
final contents = _contentAsOrderedString(from);
expect(
contents,
Expand All @@ -65,5 +65,17 @@ Directory _createToDir() {
String _contentAsOrderedString(Directory dir) {
final contents = dir.listSync(recursive: true)
..sort((a, b) => a.path.compareTo(b.path));
return contents.toString();
return contents
// Always use posix paths so that expectations can be consistent between
// Mac/Windows.
.map(
(e) =>
"${e is Directory ? 'Directory' : 'File'}: '${posixPath(e.path)}'",
)
.toList()
.toString();
}

/// Returns a relative path [input] with posix/forward slashes regardless of
/// the current platform.
String posixPath(String input) => p.posix.joinAll(p.split(input));

0 comments on commit 89c7a48

Please sign in to comment.