Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

top-level expect throws nSM when not using runner #132

Closed
jmesserly opened this issue Jun 1, 2015 · 1 comment
Closed

top-level expect throws nSM when not using runner #132

jmesserly opened this issue Jun 1, 2015 · 1 comment

Comments

@jmesserly
Copy link
Contributor

EDIT: see comment #132 (comment), this only affects top-level expect statements.

running

// @TestOn('vm') doesn't seem to make a difference
import 'package:test/test.dart';
main() {
  expect(true, true);
}

results in

$ dart test.dart
Unhandled exception:
The null object does not have a getter 'closed'.

NoSuchMethodError: method not found: 'closed'
Receiver: null
Arguments: []
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2      expect (package:test/src/frontend/expect.dart:42:23)
#3      main (file:///Users/jmesserly/scratch/test.dart:3:9)
#4      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:255)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:142)

Seems to happen in 0.12.2 as well as master.

According to docs:

It's also possible to run a test on the Dart VM only by invoking it using dart path/to/test.dart, but this doesn't load the full test runner and will be missing some features.

Context: I'm trying to migrate some existing code from unittest, and easiest thing to do was to leave our various scripts running the test files directly. That was also a really nice way to debug tests by launching them from WebStorm. Not sure if/how the debugger can attach to "pub run test". At first glance I wasn't sure what the workaround would be, as it doesn't look like I can create an Invoker or a runner environment without depending on "src" (don't worry, I won't do that :) ). So at the moment I'm stuck on older unittest.

@jmesserly
Copy link
Contributor Author

Aha, naturally as soon as I file this I figure out what's going on. So it seems we have some code that runs expect outside of a test. If it was inside a test I'm pretty sure it would work, as _globalDeclarer/LocalTest sets things up correctly. Anyway, that's easy, I can totally fix our code to not do that (I'm not even sure why it is ... but that's another story).

It might be good to support top-level expect (or at least not NoSuchMethodError) but way lower priority

@jmesserly jmesserly changed the title test files cannot run directly on VM top-level expect throws nSM when not using runner Jun 1, 2015
jmesserly pushed a commit to dart-archive/dev_compiler that referenced this issue Jun 1, 2015
dart_style becomes a dev_dependency, and remove the ability to auto-run it from dart backend, instead use the test formatter
migrate to package:test, which has a few tricky bits:
* expect can only appear inside a test now (dart-lang/test#132)
* mirrors is needed to get the test folder (dart-lang/test#110)
* test `main` can't take arguments. not sure what's up there, but not a big deal for us either.

[email protected]

Review URL: https://codereview.chromium.org/1166683005
@nex3 nex3 closed this as completed in cebcb3d Jun 1, 2015
nex3 pushed a commit to dart-lang/sdk that referenced this issue Aug 31, 2016
dart_style becomes a dev_dependency, and remove the ability to auto-run it from dart backend, instead use the test formatter
migrate to package:test, which has a few tricky bits:
* expect can only appear inside a test now (dart-lang/test#132)
* mirrors is needed to get the test folder (dart-lang/test#110)
* test `main` can't take arguments. not sure what's up there, but not a big deal for us either.

[email protected]

Review URL: https://codereview.chromium.org/1166683005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant