Skip to content

Commit

Permalink
test: fix flaky tests linux CI/CD environments #2 (#680)
Browse files Browse the repository at this point in the history
* chore: fix test timed out after 30 seconds

* chore: update multiple scripts group test

* chore: apply timeout to bootstrap test only for linux environments
  • Loading branch information
jessicatarra authored Mar 27, 2024
1 parent 28882a1 commit 69b7fae
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 49 deletions.
102 changes: 54 additions & 48 deletions packages/melos/test/commands/bootstrap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,86 +146,92 @@ Generating IntelliJ IDE files...
);
});

test('resolves workspace packages with path dependency', () async {
final workspaceDir = await createTemporaryWorkspace();
test(
'resolves workspace packages with path dependency',
() async {
final workspaceDir = await createTemporaryWorkspace();

final aDir = await createProject(
workspaceDir,
PubSpec(
name: 'a',
dependencies: {'b': HostedReference(VersionConstraint.any)},
),
);
await createProject(
workspaceDir,
const PubSpec(name: 'b'),
);
final aDir = await createProject(
workspaceDir,
PubSpec(
name: 'a',
dependencies: {'b': HostedReference(VersionConstraint.any)},
),
);
await createProject(
workspaceDir,
const PubSpec(name: 'b'),
);

await createProject(
workspaceDir,
pubSpecFromJsonFile(fileName: 'add_to_app_json.json'),
);
await createProject(
workspaceDir,
pubSpecFromJsonFile(fileName: 'add_to_app_json.json'),
);

await createProject(
workspaceDir,
pubSpecFromJsonFile(fileName: 'plugin_json.json'),
);
await createProject(
workspaceDir,
pubSpecFromJsonFile(fileName: 'plugin_json.json'),
);

final logger = TestLogger();
final config = await MelosWorkspaceConfig.fromWorkspaceRoot(workspaceDir);
final melos = Melos(
logger: logger,
config: config,
);
final logger = TestLogger();
final config =
await MelosWorkspaceConfig.fromWorkspaceRoot(workspaceDir);
final melos = Melos(
logger: logger,
config: config,
);

await runMelosBootstrap(melos, logger);
await runMelosBootstrap(melos, logger);

expect(
logger.output,
ignoringAnsii(
allOf(
[
'''
expect(
logger.output,
ignoringAnsii(
allOf(
[
'''
melos bootstrap
└> ${workspaceDir.path}
Running "flutter pub get" in workspace packages...''',
'''
'''
✓ a
└> packages/a
''',
'''
'''
✓ b
└> packages/b
''',
'''
'''
✓ c
└> packages/c
''',
'''
'''
✓ d
└> packages/d
''',
'''
'''
> SUCCESS
Generating IntelliJ IDE files...
> SUCCESS
-> 4 packages bootstrapped
''',
].map(contains).toList(),
].map(contains).toList(),
),
),
),
);
);

final aConfig = packageConfigForPackageAt(aDir);
final aConfig = packageConfigForPackageAt(aDir);

expect(
aConfig.packages.firstWhere((p) => p.name == 'b').rootUri,
'../../b',
);
});
expect(
aConfig.packages.firstWhere((p) => p.name == 'b').rootUri,
'../../b',
);
},
timeout:
io.Platform.isLinux ? const Timeout(Duration(seconds: 45)) : null,
);

test(
'bootstrap transitive dependencies',
Expand Down
2 changes: 1 addition & 1 deletion packages/melos/test/commands/run_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ melos run test_script

expect(
logger.output.normalizeNewLines(),
ignoringAnsii(
ignoringDependencyMessages(
'''
melos run hello_script
└> test_script
Expand Down

0 comments on commit 69b7fae

Please sign in to comment.