invertase / melos

🌋 A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.12k stars 200 forks source link

FileSystemException when running test #196

Closed swavkulinski closed 2 years ago

swavkulinski commented 2 years ago

I've got a FileSystemException when running

melos run test

Output:

melos run test
   └> melos run test:flutter | melos run test:dart
       └> RUNNING

melos run test:dart
   └> melos exec --dir-exists="test" -c 1 --fail-fast -- "pub run test"
       └> RUNNING

$ melos exec
   └> pub run test
       └> RUNNING (in 1 packages)

------------------------------------------------------------------------------------------------------------------------------
riverpod_bookstore_api:
00:00 +0: loading test/repository_test.dart
00:01 +0: loading test/repository_test.dart
00:01 +0: test/repository_test.dart: BookstoreRepository addBook - book is added and list is a copy
00:01 +1: test/repository_test.dart: BookstoreRepository addBook - book is added and list is a copy
00:01 +1: test/repository_test.dart: BookstoreRepository removeBook - book is removed and list is a copy                    
00:01 +2: test/repository_test.dart: BookstoreRepository removeBook - book is removed and list is a copy
00:01 +2: test/repository_test.dart: CategoryRepository addCategory - category is added and list is a copy
00:01 +3: test/repository_test.dart: CategoryRepository addCategory - category is added and list is a copy
00:01 +3: test/repository_test.dart: CategoryRepository removeCategory - category is removed and list is a copy
00:01 +4: test/repository_test.dart: CategoryRepository removeCategory - category is removed and list is a copy
00:01 +4: All tests passed!
riverpod_bookstore_api: SUCCESS
------------------------------------------------------------------------------------------------------------------------------

$ melos exec
   └> pub run test
       └> SUCCESS

melos run test:dart
   └> melos exec --dir-exists="test" -c 1 --fail-fast -- "pub run test"
       └> SUCCESS
Unhandled exception:
FileSystemException: writeFrom failed, path = '' (OS Error: Broken pipe, errno = 32)
#0      _RandomAccessFile.writeFromSync (dart:io/file_impl.dart:870:7)
#1      _StdConsumer.addStream.<anonymous closure> (dart:io/stdio.dart:286:15)
#2      _RootZone.runUnaryGuarded (dart:async/zone.dart:1620:10)
#3      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#4      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#5      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#6      _StreamController._add (dart:async/stream_controller.dart:607:7)
#7      _StreamController.add (dart:async/stream_controller.dart:554:5)
#8      _StreamSinkImpl.add (dart:io/io_sink.dart:136:17)
#9      _StdSink.add (dart:io/stdio.dart:327:11)
#10     startProcess.<anonymous closure> (package:melos/src/common/utils.dart:270:14)
#11     _RootZone.runUnaryGuarded (dart:async/zone.dart:1620:10)
#12     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#13     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#14     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#15     _StreamController._add (dart:async/stream_controller.dart:607:7)
#16     _StreamController.add (dart:async/stream_controller.dart:554:5)
#17     _Socket._onData (dart:io-patch/socket_patch.dart:2166:41)
#18     _RootZone.runUnaryGuarded (dart:async/zone.dart:1620:10)
#19     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#20     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#21     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#22     _StreamController._add (dart:async/stream_controller.dart:607:7)
#23     _StreamController.add (dart:async/stream_controller.dart:554:5)
#24     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1702:33)
#25     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1213:14)
#26     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#27     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#28     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:120:13)
#29     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

melos run test
   └> melos run test:flutter | melos run test:dart
       └> SUCCESS

Running melos run test:dart and then melos run test:flutter complete without problems

my melos.yaml

name: riverpod_bookstore

packages:
  - packages/**

scripts:

  test:
    run: melos run test:flutter | melos run test:dart
    description: Run all tests

  test:flutter:
    run: melos exec --dir-exists="test" -c 1 --fail-fast -- "flutter test --coverage"
    description: Run Flutter tests for all flutter packages
    select-package:
      flutter: true
      dir-exists: test

  test:dart:
    run: melos exec --dir-exists="test" -c 1 --fail-fast -- "pub run test"
    description: Run Dart tests for all dart packages
    select-package:
      flutter: false
      dir-exists: test
swavkulinski commented 2 years ago

it doesn't throw error when test is defined as follows

  test:
    run: melos run test:flutter & melos run test:dart
blaugold commented 2 years ago

There's the problem.

With this, you're piping (|) the stdout from melos run test:flutter into the stdin of melos run test:dart:

  test:
    run: melos run test:flutter | melos run test:dart

You want to use && between commands, to run multiple commands one after the other and fail if any of the commands fails.

blaugold commented 2 years ago

Closing this, since it's not an issue with Melos.