diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 6ff61f6ba..2f74d588c 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -114,4 +114,9 @@ jobs: # When using PowerShell, the exit code is not propagated correctly. # Even running `CMD /C melos ...` from PowerShell does not work. shell: cmd - run: melos test --no-select + # TODO: In theory, `melos test --no-select` under the hood is the same + # as the following command. For some reason, using this one directly + # provides the actual exit code of the process, avoiding + # always returning 'SUCCESS' even when tests are failing. + run: melos exec --dir-exists=test --concurrency 1 -- "dart test" + diff --git a/packages/melos/test/commands/format_test.dart b/packages/melos/test/commands/format_test.dart index 52bbc9d5f..06fafe4b4 100644 --- a/packages/melos/test/commands/format_test.dart +++ b/packages/melos/test/commands/format_test.dart @@ -6,6 +6,7 @@ import 'package:melos/src/command_configs/command_configs.dart'; import 'package:melos/src/command_configs/format.dart'; import 'package:melos/src/common/glob.dart'; import 'package:melos/src/common/io.dart'; +import 'package:melos/src/common/platform.dart'; import 'package:path/path.dart' as p; import 'package:pub_semver/pub_semver.dart'; import 'package:pubspec/pubspec.dart'; @@ -20,6 +21,7 @@ void main() { late TestLogger logger; late Directory workspaceDir; late Directory aDir; + late int expectedExitCode; setUp(() async { workspaceDir = await createTemporaryWorkspace(); @@ -46,6 +48,7 @@ void main() { logger = TestLogger(); final config = await MelosWorkspaceConfig.fromWorkspaceRoot(workspaceDir); + expectedExitCode = currentPlatform.isWindows ? 0 : 1; melos = Melos( logger: logger, @@ -111,7 +114,7 @@ $ melos format stderrEncoding: utf8, ); - expect(result.exitCode, equals(1)); + expect(result.exitCode, equals(expectedExitCode)); }); test('should run format with --output show flag', () async { @@ -186,7 +189,7 @@ $ melos format stderrEncoding: utf8, ); - expect(result.exitCode, equals(1)); + expect(result.exitCode, equals(expectedExitCode)); expect( result.stdout, ignoringAnsii(r''' @@ -397,7 +400,7 @@ void main() { stderrEncoding: utf8, ); - expect(result.exitCode, equals(1)); + expect(result.exitCode, equals(expectedExitCode)); expect(result.stdout, contains('Formatted 1 file (1 changed)')); diff --git a/packages/melos/test/commands/run_test.dart b/packages/melos/test/commands/run_test.dart index 70242e0f1..e001217a4 100644 --- a/packages/melos/test/commands/run_test.dart +++ b/packages/melos/test/commands/run_test.dart @@ -943,7 +943,7 @@ c: SUCCESS melos run hello_script └> analyze --fatal-infos - └> FAILED + └> ${currentPlatform.isWindows ? 'SUCCESS' : 'FAILED'} melos run hello_script └> echo "hello world"