From 0c8e349a2318136f520a7c4e20c479bdb3855b4f Mon Sep 17 00:00:00 2001 From: Dimoshka Date: Mon, 12 Oct 2026 10:34:41 +0000 Subject: [PATCH 1/2] test(platform): install-layout assertions read the path on any platform Windows CI checks the tree out with CRLF-free but drive-lettered paths: uri.path is '/d:/a/...' there, so Directory(uri.path + '/lib') failed with errno 123, and toFilePath() separates with '\', so the endsWith 'state/default' assertion could never hold. Directory.path and Uri.path are the platform-independent spellings; both assertions keep their intent. --- .../test/platform/ports_contract_test.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/alteri_one_platform/test/platform/ports_contract_test.dart b/packages/alteri_one_platform/test/platform/ports_contract_test.dart index 54294e2..693f7bc 100644 --- a/packages/alteri_one_platform/test/platform/ports_contract_test.dart +++ b/packages/alteri_one_platform/test/platform/ports_contract_test.dart @@ -144,8 +144,10 @@ void main() { // `dart:io` is still imported by a web compilation if it is reachable from the entry point, // so the arrangement is only true if the *directory* is the boundary and not merely the files // checked above. + // `uri.path` on Windows begins with '/' before the drive letter, so it is not a usable OS + // path; `Directory.path` is. for (final file in _dartFilesIn( - Directory(_packageRoot().uri.path + '/lib'), + Directory('${_packageRoot().path}/lib'), )) { if (_isInsideIoDirectory(file.path)) continue; for (final library in _platformLibraries) { @@ -470,10 +472,9 @@ void main() { // root. A caller handed a root cannot be handed a path elsewhere by passing one. final paths = PlatformPaths(Uri.file('/srv/install')); - expect( - paths.resolve('state/default').toFilePath(), - endsWith('state/default'), - ); + // `.path`, not `toFilePath()`: on Windows the latter separates with '\', and this assertion + // is about the joined segments. + expect(paths.resolve('state/default').path, endsWith('state/default')); for (final absolute in const [ '/etc/passwd', From d81c2cbec199c7a2e3f511a81793aa25462aae42 Mon Sep 17 00:00:00 2001 From: Dimoshka Date: Mon, 12 Oct 2026 10:44:48 +0000 Subject: [PATCH 2/2] test(platform): the io-directory check normalised no separator at all r'\\' is a two-character string, so the replaceAll matched nothing on Windows: paths kept their backslashes, lib/src/io/ was not found, and every native adapter was reported as outside its own directory. Invisible on Linux, and invisible on Windows until the walk that reached this line was fixed. The pattern is '\\'. --- .../test/platform/ports_contract_test.dart | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/alteri_one_platform/test/platform/ports_contract_test.dart b/packages/alteri_one_platform/test/platform/ports_contract_test.dart index 693f7bc..9351079 100644 --- a/packages/alteri_one_platform/test/platform/ports_contract_test.dart +++ b/packages/alteri_one_platform/test/platform/ports_contract_test.dart @@ -1238,9 +1238,7 @@ File _fileAbove(String relative) { var directory = Directory.current; File? found; while (found == null) { - final candidate = File( - '${directory.path}/$relative'.replaceAll(r'\\', '/'), - ); + final candidate = File('${directory.path}/$relative'.replaceAll('\\', '/')); if (candidate.existsSync()) found = candidate; final parent = directory.parent; if (parent.path == directory.path) break; @@ -1323,9 +1321,13 @@ List _directivesFor(String source, String library) { /// Matches `lib/src/io/` with no leading separator, because the paths tested here come from a walk /// rooted at the current directory and are therefore already repository-relative. An earlier version /// looked for `/lib/src/io/` and reported every native adapter as being outside its own directory — a -/// check that could not pass, which is the useful kind of failure only if somebody reads it. +/// check that could not pass, which is the useful kind of failure only if somebody reads it. The same +/// shape bit again here: a raw `r'\\'` is a two-character string, so on Windows, where every separator is a +/// single backslash, the replacement matched nothing, the path kept its backslashes, and +/// `.contains('lib/src/io/')` failed — every native adapter reported as outside its own directory, this +/// time passing silently on Linux where the separators are already `/`. The pattern is `'\\'`. bool _isInsideIoDirectory(String path) => - path.replaceAll(r'\\', '/').contains('lib/src/io/'); + path.replaceAll('\\', '/').contains('lib/src/io/'); /// Every `.dart` file under [directory], sorted, skipping generated and tool output. List _dartFilesIn(Directory directory) {