[2.7.0] Using Dart to run bin command that executes tests

7 views
Skip to first unread message

John McMahon

unread,
Jan 19, 2022, 7:28:47 AMJan 19
to Dart Misc
Hi all,

I am working on a PR for the test_coverage package (using the opportunity to setup a GitLab CI/CD workflow for Dart projects). I see in the Travis CI file that it runs the following script to ensure the executable and code work:

pub run test_coverage --exclude="test/stub_package/**"

The project still has the SDK limitation in pubspec.yaml to sdk: '>=2.3.0 <3.0.0'.

Through trial and error, I found that it works with a minimal version of Dart 2.7.0. So the revamp of the CLI commands is not yet available.

Since this package intends to provide test coverage, this script will run the tests, collect relevant data, and then produce a file.

Now it runs fine for me locally, but when I run it in my GitLab runner, I get an error about a 255 exit code.

Whether I use "dart ./bin/test_coverage.dart"  or "pub run", locally it runs fine. And I do have Dart 2.7.0 installed locally.

I put in some debugging code for the process.stderr and I get the following error:
Unhandled exception:
Dummy exception to set exit code.
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1114:29)
#1 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#2 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#3 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:393:30)
#4 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5)
#5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

I am curious because as I searched this error I saw a comment from nex3:

     This exception is only intended to arise when running a test file directly using dart path/to/file.dart, but it may happen if you're calling test() or group() from non-test code (something that is emphatically not supported).

The way test_coverage runs the test, is by using Process to run:

dart --pause-isolates-on-exit --enable_asserts --enable-vm-service=$port test .test_coverage.dart

So I don't know why the executable has an issue during CI/CD, but not locally.

The unit tests pass on the CI/CD which executes the same code.


Reply all
Reply to author
Forward
0 new messages