Skip to content

Tests with compile errors still run (then generate obscure corrupted error messages) #16496

Closed

Description

@Hixie

Try to "flutter test" the following file:

class Foo { Foo({ int arg }); }

void main() {
  new Foo(bogus: 1);
}

You get:

Running "flutter packages get" in scratch...
compiler message: test/a_test.dart:4:11: Error: Constructor has no named parameter with the name 'bogus'.
compiler message:   new Foo(bogus: 1);
compiler message:           ^^^^^
compiler message: test/a_test.dart:1:13: Context: Found this candidate, but the arguments don't match.
compiler message: class Foo { Foo({ int arg }); }
compiler message:             ^
00:00 +0 -1: loading /Users/ianh/dev/scratch/test/a_test.dart [E]
  Failed to load "/Users/ianh/dev/scratch/test/a_test.dart":
  No top-level method '' declared.
  Receiver: top-level
  Tried calling: (bogus: 1)
  package:test                                                                                   serializeSuite
  /var/folders/1b/7c22t3zx7h7_400fl83x5pxr000f_t/T/dart_test_listeneruFfxCR/listener.dart 18:27  main

00:00 +0 -1: Some tests failed.

If the test fails to compile, we should definitely not then run it. If we do run it, we should not have a bogus error message that refers to undeclared methods; instead we should get something more like what we used to get in Dart1:

Unhandled exception:
NoSuchMethodError: No constructor 'Foo' declared in class 'Foo'.
Receiver: Foo
Tried calling: new Foo(bogus: 1)
#0      NoSuchMethodError._throwNew (dart:core-patch/dart:core/errors_patch.dart:196)
#1      main (file:///Users/ianh/dev/scratch/test/a_test.dart:4:10)
#2      _startIsolate.<anonymous closure> (dart:isolate-patch/dart:isolate/isolate_patch.dart:279)
#3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:165)

cc @aam @tvolkert

Activity

  1. added
    a: tests"flutter test", flutter_test, or one of our tests
    on Apr 12, 2018
  2. self-assigned this
    on Apr 23, 2018
  3. added and removed on Apr 23, 2018
  4. github-actions commented on Sep 3, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: tests"flutter test", flutter_test, or one of our testsdependency: dartDart team may need to help us

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions