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

Chain.capture() not working in tests #50

Open
mleonhard opened this issue Feb 25, 2019 · 0 comments
Open

Chain.capture() not working in tests #50

mleonhard opened this issue Feb 25, 2019 · 0 comments

Comments

@mleonhard
Copy link

Dear Dart-lang Maintainers,
Thank you for your hard work making Dart. It is very useful to me. Here is test/unit/truncated_trace_test.dart which demonstrates a problem in my Dart application:

import 'package:test/test.dart' show test;

class CustomException implements Exception {
  final String details;

  CustomException(dynamic e, StackTrace trace)
      : this.details = 'CustomException: $e\n'
            'Stack Trace:\n${Chain.forTrace(trace).terse}';

  @override
  String toString() => 'BEGIN\n$details\nEND\n';
}

Future<void> function2() async {
  try {
    throw new Exception('exception1');
  } catch (e, trace) {
    throw new CustomException(e, trace);
  }
}

Future<void> function1() async => await function2();

void main() {
  Chain.capture(() {
    test('test function1()', () async {
      await function1();
    });
  });
}

Here is the output of running the test:

00:01 +0 -1: test function1() [E]
  BEGIN
  CustomException: Exception: exception1
  Stack Trace:
  test/unit/truncated_trace_test.dart 17:5          function2
  ===== asynchronous gap ===========================
  dart:async                                        _asyncThenWrapperHelper
  package:test_api/src/backend/declarer.dart        Declarer.test.<fn>.<fn>.<fn>
  package:test_api/src/backend/invoker.dart 249:15  Invoker.waitForOutstandingCallbacks.<fn>
  ===== asynchronous gap ===========================
  dart:async                                        new Future
  package:test_api/src/backend/invoker.dart 398:11  Invoker._onRun.<fn>.<fn>.<fn>
  
  END
  
  test/unit/truncated_trace_test.dart 19:5  function2
  ===== asynchronous gap ===========================
  dart:async                                _AsyncAwaitCompleter.completeError
  test/unit/truncated_trace_test.dart       function2
  
00:01 +0 -1: Some tests failed.

The problem is that function1 and main are missing from the stack trace. So far this seems to happen only in tests. Is there any way to get the missing entries to show? I would appreciate any help you can give on this issue.

Sincerely,
Michael

More info:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.3 18D109, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    ✗ Verify that all connected devices have been paired with this computer in Xcode.
      If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.
      To update with Brew, run:
        brew update
        brew uninstall --ignore-dependencies libimobiledevice
        brew uninstall --ignore-dependencies usbmuxd
        brew install --HEAD usbmuxd
        brew unlink usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ Brew can be used to install tools for iOS device development.
      Download brew at https://brew.sh/.
[✓] Android Studio (version 3.3)
[!] IntelliJ IDEA Community Edition (version 2018.3.4)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.
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