dart-lang / test

A library for writing unit tests in Dart.
https://pub.dev/packages/test
495 stars 213 forks source link

Can't run 'pub run test' after upgrading to 0.12.3 #133

Closed dynaxis closed 9 years ago

dynaxis commented 9 years ago

I get the error shown in the end of this report, when I run 'pub run test' after upgrading to 0.12.3. It seems that it works fine in 0.12.2. I'm running Windows 8.1 on a x64 machine.

D:\msys64\home\dynaxis\work\xseed>pub run test
Unhandled exception:
Uncaught Error: FileSystemException: Cannot resolve symbolic links, path = 'D:\packages\dart-sdk\bin\dart' (OS Error: 吏
€?뺣맂 ?뚯씪??李얠쓣 ???놁뒿?덈떎.
, errno = 2)
Stack Trace:
#0      FileSystemEntity._throwIfError (dart:io/file_system_entity.dart:671)
#1      FileSystemEntity.resolveSymbolicLinksSync (dart:io/file_system_entity.dart:338)
#2      sdkDir.<anonymous closure> (package:test/src/util/io.dart:26)
#3      sdkDir (package:test/src/util/io.dart:28)
#4      sdkDir (package:test/src/util/io.dart:24)
#5      _sdkVersion (package:test/src/util/io.dart:32)
#6      _sdkVersion (package:test/src/util/io.dart:31)
#7      _supportsPubServe (package:test/src/util/io.dart:65)
#8      supportsPubServe (package:test/src/util/io.dart:60)
#9      supportsPubServe (package:test/src/util/io.dart:60)
#10     main.<main_async_body> (package:test/src/executable.dart:109)
#11     Future.Future.microtask.<anonymous closure> (dart:async/future.dart:144)
#12     _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#13     _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#14     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#15     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:143)

#0      _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:886)
#1      _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2      _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:143)
zoechi commented 9 years ago

To me this looks more like a file system or pub cache problem. Have you tried pub cache repair and the again pub get or pub upgrade

dynaxis commented 9 years ago

@zoechi per your suggestion, I tried pub cache repair followed by deletion of pubspec.lock and pub get. It produced the same error. And I even tried trash all of pub cache manually to no avail. I'm using SDK 1.10.1 and downgrading to test@0.12.2 solves the problem.

dynaxis commented 9 years ago

https://github.com/dart-lang/test/commit/1eb9d79009a215f492ac990abd3751f3c2868e91 I guess the above commit is making difference. The commit coincides with the stacktrace in my reporting.

The pub.bat on SDK refers to 'dart.exe' just as 'dart', and Platform.executable seems to report ...\bin\dart. Since there is no just 'dart' file on Windows (it's dart.exe), the resolveSymlinksSync fails with 'no such file' error.

kevmoo commented 9 years ago

@dynaxis that looks ugly – will investigate on our side.

nex3 commented 9 years ago

It looks like symbolic link resolution is failing on Windows. This may be a dart:io bug. @dynaxis, can you translate the error message for us?

dynaxis commented 9 years ago

@nex3 Sorry for the messed up error message. Due to some problem in my console setting, it is unreadable to me, too. But according to my test code trying to invoke resolveSymboliclinksSync on non-existing file (that is, ...\bin\dart when there is ...\bin\dart.exe), I got something like no such file exists (I ran it in WebStorm and got the message readable).

As I stated in my last comment, the cause is rather obvious. Platform.executable returns ...\bin\dart instead of ...\bin\dart.exe, and resolveSymbolicLinksSync requires there exist the given file. That's the cause of this problem.

I hope the canonical way of getting the SDK directory is sorted out soon.

kevmoo commented 9 years ago

I'm not able to reproduce this on 1.11.0-dev.3.0

Perhaps this was fixed recently...

dynaxis commented 9 years ago

@kevmoo I tried 1.11.0.-dev3.0 this time. And Platform.executable reports ...\bin\dart.exe now, instead of ...\bin\dart. That seems to solve this issue. I guess the release has its implementation of Platform.executable different from the previous releases.

I'll upgrade to the recent dev channel version of SDK for the time being.

dynaxis commented 9 years ago

The following commit on runtime/bin/platform_win.cc and related files seems to solve the issue. I'm not so familiar with Win32/64 programming, but GetModuleFileName seems to return the full path together with the full name of the executable.

https://github.com/dart-lang/sdk/commit/e03ab1743717c39099a9161999e231699098a811

nex3 commented 9 years ago

@kevmoo We should add a workaround for this so we can continue to support older versions of the SDK.

rbishop-bah commented 9 years ago

I see this error too (Win7 x64). I tried running tests after pub global activate test 0.12.2 but that failed with the same error. Please tell me we won't have to wait until SDK 1.11 is released to be able to test again.

On Edit: Note that as a workaround copying dart.exe to dart (with no extension) in the dart-sdk bin folder allows tests to run again.

nex3 commented 9 years ago

I see this error too (Win7 x64). I tried running tests after pub global activate test 0.12.2 but that failed with the same error.

The test runner doesn't (and never will) work with pub global activate. It needs to be installed in the same package graph as the tests it's running.

Please tell me we won't have to wait until SDK 1.11 is released to be able to test again.

Certainly not. You can fix this right now by adding an upper bound to your test constraint (test: ">=0.12.0 <0.12.3") and running pub get to get an older version. I'm also going to put out a fix very soon that adds a workaround.

seaneagan commented 9 years ago

@nex3 The changelog says this fix was released in 0.12.3+1, but that version has not yet been published to pub.dartlang.org.

nex3 commented 9 years ago

Good catch! Tagged and published.