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

fix: flutter coverage-package unusable through melos #696

Open
1 task done
llfbandit opened this issue Apr 12, 2024 · 6 comments
Open
1 task done

fix: flutter coverage-package unusable through melos #696

llfbandit opened this issue Apr 12, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@llfbandit
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

Version

5.3.0

Description

This command for example:
melos exec -- "flutter test --coverage --coverage-package=MELOS_PACKAGE_NAME(|_service)"
will end with an error.

This is not due to the env variable MELOS_PACKAGE_NAME but to the regular expression itself. Tested with other expressions with the same result.
I also tried to put the regular expression to an env variable.

Those examples are OK ✅:
flutter test --coverage --coverage-package=package_name(|_service)✅
melos exec -- "flutter test --coverage --coverage-package=MELOS_PACKAGE_NAME" => ✅
melos exec -- "flutter test --coverage --coverage-package=package_name" => ✅

Steps to reproduce

  1. Execute melos exec -- "flutter test --coverage --coverage-package=MELOS_PACKAGE_NAME(|_service)"
  2. Acquire the error:
ERROR: ERROR: ERROR: Unhandled exception:
FormatException: Unexpected extension byte (at offset 96)
#0      _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1845:7)
#1      _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:304:28)
#2      _Utf8ConversionSink.add (dart:convert/string_conversion.dart:300:5)
#3      _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:69:18)
#4      _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#9      _StreamController._add (dart:async/stream_controller.dart:658:7)
#10     _StreamController.add (dart:async/stream_controller.dart:606:5)
#11     _Socket._onData (dart:io-patch/socket_patch.dart:2447:41)
#12     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#13     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#14     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#15     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#16     _StreamController._add (dart:async/stream_controller.dart:658:7)
#17     _StreamController.add (dart:async/stream_controller.dart:606:5)
#18     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1936:33)
#19     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1379:14)
#20     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#21     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#22     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#23     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

Expected behavior

MELOS_PACKAGE_NAME replaced and the regular expression correctly handled to provide deep code coverage

Screenshots

No response

Additional context and comments

No response

@llfbandit llfbandit added the bug Something isn't working label Apr 12, 2024
@spydon
Copy link
Collaborator

spydon commented Apr 12, 2024

(|_service) is some type of regex shell expansion for a specific shell right? Is it just expanding to two versions of the script, one with package_name and one with package_name_service as arguments? I don't think it would be possible for us to support this within Melos since startCommand is using /bin/sh.

You could try running it through the shell you want to use like melos exec -- "zsh -c flutter test --coverage --coverage-package=MELOS_PACKAGE_NAME(|_service)" (replace zsh with your shell).

@llfbandit
Copy link
Author

No there's no hidden part here.
coverage-package is a parameter for flutter test command. The regular expression is simple String set in melos.yaml.
I'm on Windows host. Tested with CMD and Powershell.
I suppose the culprit is the pipe ('|') here.

Here's the help text for this parameter.

--coverage-package=<package-name-regexp>
A regular expression matching packages names to include in the coverage report (if coverage is enabled). If unset, matches the current package name.

@spydon
Copy link
Collaborator

spydon commented Apr 15, 2024

Ah, I didn't know that was included in --coverage-package, I think you're just missing some inner quotes then, try this:

melos exec -- "flutter test --coverage --coverage-package='MELOS_PACKAGE_NAME(|_service)'"

@llfbandit
Copy link
Author

Nope same result.

@spydon
Copy link
Collaborator

spydon commented Apr 15, 2024

Interesting, I did not get that same result on Linux.
Can you try escaping the problematic characters then? Probably both that parenthesis and the pipe.

@llfbandit
Copy link
Author

llfbandit commented Apr 15, 2024

Escaping does not help.
I transformed the sample expression to this one MELOS_PACKAGE_NAME(_service)?
So, by removing the pipe, the process runs as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants