test icon indicating copy to clipboard operation
test copied to clipboard

Cannot run wasm test on windows

Open Zekfad opened this issue 1 year ago • 1 comments

Config:

platforms: [chrome,firefox,vm]
compilers: [dart2wasm,dart2js,exe]

Output

Z:\Users\vorob\Desktop\Projects\fetch_client>dart test        
Building package executable... (2.4s)
Built test:test.
00:00 +0: [Chrome, Dart2Wasm] loading test\client_conformance_test.dart
#0      _Uri._checkWindowsPathReservedCharacters (dart:core/uri.dart:1841)
#1      _Uri._makeWindowsFileUrl (dart:core/uri.dart:1906)
#2      new _Uri.file (dart:core/uri.dart:1808)
#3      new UriOption.<anonymous closure> (package:dart2wasm/option.dart:70)
#4      Option.applyToOptions (package:dart2wasm/option.dart:18)
#5      parseArguments (package:dart2wasm/dart2wasm.dart:150)
#6      main (package:dart2wasm/dart2wasm.dart:162)
#7      main (file:///C:/b/s/w/ir/x/w/sdk/pkg/dart2wasm/bin/dart2wasm.dart:10)
#8      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295)
#9      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184)

Zekfad avatar May 26 '24 16:05 Zekfad

@osa1 @mkustermann – could be an SDK issue?

kevmoo avatar May 31 '24 20:05 kevmoo

I have the exact same issue. I've investigated a bit and it seems it originates from (await packageConfigUri).path which returns a path from a file URI.

image

As a quick test I amended the --packages argument to provide a hardcoded Windows path, and compilation to wasm was successful.

d-markey avatar Aug 10 '24 21:08 d-markey

For the record:

Dart SDK version: 3.4.4 (stable) (Wed Jun 12 15:54:31 2024 +0000) on "windows_x64"

The source code is from test_core-0.6.5\lib\src\runner\wasm_compiler_pool.dart

d-markey avatar Aug 10 '24 21:08 d-markey

Could you try Dart 3.5? Just released...

kevmoo avatar Aug 10 '24 21:08 kevmoo

I was on Flutter 3.22.x, just upgraded to Flutter 3.24 with Dart 3.5. Same.

image

d-markey avatar Aug 10 '24 22:08 d-markey

It looks like (await packageConfigUri).path somehow returning an illegal path for Windows. Repro:

void main() {
  Uri.file('/C:/_Projects/github/squadron/.dart_tool/package_config.json', windows: true);
}

Crashes with:

Invalid argument(s): Illegal character in path
#0      _Uri._checkWindowsPathReservedCharacters (dart:core/uri.dart:1841:11)
#1      _Uri._makeWindowsFileUrl (dart:core/uri.dart:1929:9)
#2      new _Uri.file (dart:core/uri.dart:1808:11)
#3      main (file:///usr/local/google/home/omersa/dart/test.dart:2:7)
#4      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#5      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

The problem seems to be the first character which is '/'. If I remove it it's parsed as expected.

I don't know yet where that '/' is coming from.

It's also weird that the error in the test runner shows the stack trace but not the error message, maybe something else to investigate.

osa1 avatar Aug 12 '24 08:08 osa1

I think we are converting a valid Windows file path to URI and then back. Example:

void main() {
  final windowsPath = 'C:\\Documents\\Foo';
  final uri = Uri.file(windowsPath, windows: true);
  print(uri.path);
}

This generates an invalid Windows path the same way as the original error:

$ dart test.dart
/C:/Documents/Foo

I'm not sure if uri.path is supposed to work this way, investigating..

osa1 avatar Aug 12 '24 08:08 osa1

I'm not sure if uri.path is supposed to work this way, investigating..

I think that's somewhat expected, a Uri.file(r'c:\A\B.txt, isWindows: true) will have a

  • Uri = {.scheme = 'file', .path = '/C:/A/B.txt'}
  • Uri.toString() is concatenating the .scheme and .path seperated by //, so file:///C:/A/B.txt
  • a Uri.parse('file:///C:/A/B.txt') will produce the same Uri

mkustermann avatar Aug 12 '24 08:08 mkustermann

In #2265 we start running the dart2wasm integration test on Windows, which catches this bug.

osa1 avatar Aug 12 '24 09:08 osa1