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

test: fix tests in Windows environment #751

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +117 to +120
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like something we should file a bug for

Copy link
Contributor Author

@jessicatarra jessicatarra Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree

run: melos exec --dir-exists=test --concurrency 1 -- "dart test"

31 changes: 28 additions & 3 deletions packages/melos/test/commands/format_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,24 @@ $ melos format
stderrEncoding: utf8,
);

expect(result.exitCode, equals(1));
///TODO: exit code in windows environments is not reliable when is not
///equal to 0
if (!Platform.isWindows) {
expect(result.exitCode, equals(1));
}

expect(result.stdout, contains('Formatted 1 file (1 changed)'));

expect(
result.stdout,
contains(
r'''
$ melos format
β””> dart format --set-exit-if-changed .
β””> FAILED (in 1 packages)
β””> a (with exit code 1)''',
),
);
});

test('should run format with --output show flag', () async {
Expand Down Expand Up @@ -186,7 +203,11 @@ $ melos format
stderrEncoding: utf8,
);

expect(result.exitCode, equals(1));
///TODO: exit code in windows environments is not reliable when is not
///equal to 0
if (!Platform.isWindows) {
expect(result.exitCode, equals(1));
}
expect(
result.stdout,
ignoringAnsii(r'''
Expand Down Expand Up @@ -397,7 +418,11 @@ void main() {
stderrEncoding: utf8,
);

expect(result.exitCode, equals(1));
///TODO: exit code in windows environments is not reliable when is not
///equal to 0
if (!Platform.isWindows) {
expect(result.exitCode, equals(1));
}

expect(result.stdout, contains('Formatted 1 file (1 changed)'));

Expand Down
7 changes: 6 additions & 1 deletion packages/melos/test/matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ Matcher ignoringDependencyMessages(String expected) {
(line) =>
!line.startsWith('Resolving dependencies...') &&
!line.startsWith('Downloading packages...') &&
!line.startsWith('Got dependencies!'),
!line.startsWith('Got dependencies!') &&
!line.contains('pub_updater') &&
!line.contains(
'newer versions incompatible with dependency constraints',
) &&
!line.contains('Try `dart pub outdated` for more information.'),
)
.join('\n');
return ignoringAnsii(expected).matches(normalizedActual, {});
Expand Down
Loading