Skip to content
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ on:
jobs:
e2e:
runs-on: ubuntu-latest

strategy:
matrix:
test:
Expand Down
3 changes: 0 additions & 3 deletions bricks/test_optimizer/hooks/lib/pre_gen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// No need for documentation in brick hooks
// ignore_for_file: public_member_api_docs

import 'dart:io';

import 'package:hooks/dart_identifier_generator.dart';
Expand Down
2 changes: 1 addition & 1 deletion bricks/test_optimizer/hooks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ dependencies:
dev_dependencies:
mocktail: ^1.0.0
test: ^1.25.0
very_good_analysis: ^9.0.0
very_good_analysis: ^10.0.0
2 changes: 1 addition & 1 deletion e2e/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ dev_dependencies:
pub_updater: ^0.5.0
test: ^1.25.0
universal_io: ^2.0.4
very_good_analysis: ^9.0.0
very_good_analysis: ^10.0.0
very_good_cli:
path: ../
2 changes: 1 addition & 1 deletion e2e/test/commands/create/dart_cli/dart_cli_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void main() {
['coverage/lcov.info', '-o', 'coverage'],
workingDirectory: workingDirectory,
);
expect(testCoverageResult.stdout, contains('lines......: 100.0%'));
expect(testCoverageResult.stdout, matches(RegExp('lines(.+) 100.0%')));
}),
);
}
2 changes: 1 addition & 1 deletion e2e/test/commands/create/dart_package/dart_pkg_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void main() {
['coverage/lcov.info', '-o', 'coverage'],
workingDirectory: workingDirectory,
);
expect(testCoverageResult.stdout, contains('lines......: 100.0%'));
expect(testCoverageResult.stdout, matches(RegExp('lines(.+) 100.0%')));
}),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void main() {
['coverage/lcov.info', '-o', 'coverage'],
workingDirectory: workingDirectory,
);
expect(testCoverageResult.stdout, contains('lines......: 100.0%'));
expect(testCoverageResult.stdout, matches(RegExp('lines(.+) 100.0%')));
}),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void main() {
['coverage/lcov.info', '-o', 'coverage'],
workingDirectory: packageDirectory,
);
expect(testCoverageResult.stdout, contains('lines......: 100.0%'));
expect(testCoverageResult.stdout, matches(RegExp('lines(.+) 100.0%')));
}
}),
);
Expand Down
13 changes: 6 additions & 7 deletions e2e/test/commands/test/async_main/async_main_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ void main() {

await copyDirectory(fixture, tempDirectory);

await expectSuccessfulProcessResult('flutter', [
'pub',
'get',
], workingDirectory: tempDirectory.path);
await expectSuccessfulProcessResult(
'flutter',
['pub', 'get'],
workingDirectory: tempDirectory.path,
);

final cwd = Directory.current;
Directory.current = tempDirectory;
addTearDown(() {
Directory.current = cwd;
});
addTearDown(() => Directory.current = cwd);

final result = await commandRunner.run(['test']);
expect(result, equals(ExitCode.success.code));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@ void main() {
tempDirectory,
);

await expectSuccessfulProcessResult('flutter', [
'pub',
'get',
], workingDirectory: tempDirectory.path);
await expectSuccessfulProcessResult(
'flutter',
['pub', 'get'],
workingDirectory: tempDirectory.path,
);

final cwd = Directory.current;
Directory.current = tempDirectory;
addTearDown(() {
Directory.current = cwd;
});
addTearDown(() => Directory.current = cwd);

final result = await commandRunner.run(['test']);

expect(result, equals(ExitCode.unavailable.code));
verify(
() => logger.err(any(that: contains('- test/.test_optimizer.dart'))),
() => logger.err(
any(that: contains('- test/.test_optimizer.dart')),
),
).called(1);
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import 'package:compilation_error/compilation_error.dart';
import 'package:test/test.dart';

void main() {
test('can be instantiated', () {
expect(Thing(thing: true), isNull);
group(Thing, () {
test('can be instantiated', () {
expect(Thing(thing: true), isNull);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ void main() {
tempDirectory,
);

await expectSuccessfulProcessResult('flutter', [
'pub',
'get',
], workingDirectory: tempDirectory.path);
await expectSuccessfulProcessResult('flutter', [
'test',
'--update-goldens',
], workingDirectory: tempDirectory.path);
await expectSuccessfulProcessResult(
'flutter',
['pub', 'get'],
workingDirectory: tempDirectory.path,
);

await expectSuccessfulProcessResult(
'flutter',
['test', '--update-goldens'],
workingDirectory: tempDirectory.path,
);

Directory.current = tempDirectory;
final result = await commandRunner.run(['test']);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/cli/templates/test_optimizer_bundle.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions lib/src/cli/test_cli_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ Future<int> _testCommand({
],
runInShell: true,
).listen(
(event) {
if (event.shouldCancelTimer()) timerSubscription.cancel();
(event) async {
if (event.shouldCancelTimer()) unawaited(timerSubscription.cancel());
if (event is SuiteTestEvent) suites[event.suite.id] = event.suite;
if (event is GroupTestEvent) groups[event.group.id] = event.group;
if (event is TestStartEvent) tests[event.test.id] = event.test;
Expand Down Expand Up @@ -451,8 +451,8 @@ Future<int> _testCommand({

if (event is ExitTestEvent) {
if (completer.isCompleted) return;
subscription.cancel();
sigintWatchSubscription.cancel();
unawaited(subscription.cancel());
unawaited(sigintWatchSubscription.cancel());

completer.complete(
event.exitCode == ExitCode.success.code
Expand Down
3 changes: 0 additions & 3 deletions lib/src/commands/create/commands/flame_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ class CreateFlameGame extends CreateSubCommand with OrgName {
@override
Map<String, dynamic> getTemplateVars() {
final vars = super.getTemplateVars();

final platforms = argResults['platforms'] as List<String>;

vars['platforms'] = platforms;

return vars;
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dev_dependencies:
build_verify: ^3.1.0
mocktail: ^1.0.4
test: ^1.25.8
very_good_analysis: ^9.0.0
very_good_analysis: ^10.0.0

executables:
very_good:
51 changes: 27 additions & 24 deletions test/src/cli/dart_cli_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ void main() {
});

group('.installed', () {
test('returns true when dart is installed', () {
ProcessOverrides.runZoned(
test('returns true when dart is installed', () async {
await ProcessOverrides.runZoned(
() => expectLater(Dart.installed(logger: logger), completion(isTrue)),
runProcess: process.run,
);
});

test('returns false when dart is not installed', () {
test('returns false when dart is not installed', () async {
final processResult = ProcessResult(
42,
ExitCode.software.code,
Expand All @@ -97,17 +97,19 @@ void main() {
),
).thenAnswer((_) async => processResult);

ProcessOverrides.runZoned(
() =>
expectLater(Dart.installed(logger: logger), completion(isFalse)),
await ProcessOverrides.runZoned(
() => expectLater(
Dart.installed(logger: logger),
completion(isFalse),
),
runProcess: process.run,
);
});
});

group('.pubGet', () {
test('throws when there is no pubspec.yaml', () {
ProcessOverrides.runZoned(
test('throws when there is no pubspec.yaml', () async {
await ProcessOverrides.runZoned(
() => expectLater(
Dart.pubGet(cwd: Directory.systemTemp.path, logger: logger),
throwsA(isA<PubspecNotFound>()),
Expand All @@ -116,7 +118,7 @@ void main() {
);
});

test('throws when process fails', () {
test('throws when process fails', () async {
when(
() => process.run(
'flutter',
Expand All @@ -125,7 +127,8 @@ void main() {
workingDirectory: any(named: 'workingDirectory'),
),
).thenAnswer((_) async => softwareErrorProcessResult);
ProcessOverrides.runZoned(

await ProcessOverrides.runZoned(
() => expectLater(
Dart.pubGet(cwd: Directory.systemTemp.path, logger: logger),
throwsException,
Expand All @@ -134,15 +137,15 @@ void main() {
);
});

test('completes when the process succeeds', () {
ProcessOverrides.runZoned(
test('completes when the process succeeds', () async {
await ProcessOverrides.runZoned(
() => expectLater(Dart.pubGet(logger: logger), completes),
runProcess: process.run,
);
});

test('completes when the process succeeds (recursive)', () {
ProcessOverrides.runZoned(
test('completes when the process succeeds (recursive)', () async {
await ProcessOverrides.runZoned(
() => expectLater(
Dart.pubGet(recursive: true, logger: logger),
completes,
Expand All @@ -154,7 +157,7 @@ void main() {
test(
'completes when there is a pubspec.yaml and '
'directory is ignored (recursive)',
() {
() async {
final tempDirectory = Directory.systemTemp.createTempSync();
addTearDown(() => tempDirectory.deleteSync(recursive: true));

Expand All @@ -173,7 +176,7 @@ void main() {

final relativePathPrefix = '.${p.context.separator}';

ProcessOverrides.runZoned(
await ProcessOverrides.runZoned(
() => expectLater(
Dart.pubGet(
cwd: tempDirectory.path,
Expand Down Expand Up @@ -221,7 +224,7 @@ void main() {
},
);

test('throws when process fails', () {
test('throws when process fails', () async {
when(
() => process.run(
any(),
Expand All @@ -231,13 +234,13 @@ void main() {
),
).thenAnswer((_) async => softwareErrorProcessResult);

ProcessOverrides.runZoned(
await ProcessOverrides.runZoned(
() => expectLater(Dart.pubGet(logger: logger), throwsException),
runProcess: process.run,
);
});

test('throws when process fails (recursive)', () {
test('throws when process fails (recursive)', () async {
when(
() => process.run(
any(),
Expand All @@ -247,7 +250,7 @@ void main() {
),
).thenAnswer((_) async => softwareErrorProcessResult);

ProcessOverrides.runZoned(
await ProcessOverrides.runZoned(
() => expectLater(
Dart.pubGet(recursive: true, logger: logger),
throwsException,
Expand All @@ -256,7 +259,7 @@ void main() {
);
});

test('throws when there is an unreachable git url', () {
test('throws when there is an unreachable git url', () async {
final tempDirectory = Directory.systemTemp.createTempSync();
addTearDown(() => tempDirectory.deleteSync(recursive: true));

Expand All @@ -273,7 +276,7 @@ void main() {
),
).thenAnswer((_) async => softwareErrorProcessResult);

ProcessOverrides.runZoned(
await ProcessOverrides.runZoned(
() => expectLater(
() => Dart.pubGet(cwd: tempDirectory.path, logger: logger),
throwsA(isA<UnreachableGitDependency>()),
Expand All @@ -284,8 +287,8 @@ void main() {
});

group('.applyFixes', () {
test('completes normally', () {
ProcessOverrides.runZoned(
test('completes normally', () async {
await ProcessOverrides.runZoned(
() => expectLater(Dart.applyFixes(logger: logger), completes),
runProcess: process.run,
);
Expand Down
Loading