Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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: 1 addition & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- test/commands/test/compilation_error/compilation_error_test.dart
- test/commands/test/no_project/no_project_test.dart
- test/commands/test/spaced_golden_file_name/spaced_golden_file_name_test.dart
- test/commands/test/very_good_config/very_good_config_test.dart

# E2E tests for the create command
- test/commands/create/flutter_app/core_test.dart
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/very_good_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ jobs:
os: [ubuntu-latest, windows-latest]
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1
with:
runs_on: ${{ matrix.os }}
flutter_version: "3.44.x"
coverage_excludes: "**/*.{gen,g}.dart"
concurrency: 1
coverage_excludes: "**/*.gen.dart"
run_bloc_lint: false
run_skipped: true
runs_on: ${{ matrix.os }}
run_bloc_lint: false
# The CLI's own test suite is run directly rather than through the test optimizer,
# matching the CI behavior prior to adopting this shared workflow.
test_optimization: false

pana:
Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include: package:very_good_analysis/analysis_options.yaml
analyzer:
exclude:
- "**/*.g.dart"
- "**/version.dart"
- "bricks/**/__brick__"
8 changes: 8 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
targets:
$default:
sources:
- $package$
- lib/**
- bin/**
- test/**
- pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int untestedFunction(int value) => value * 2;
10 changes: 10 additions & 0 deletions e2e/test/commands/test/very_good_config/fixture/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: very_good_config_fixture
description: Fixture for testing very_good.yaml configuration.
version: 0.1.0+1
publish_to: none

environment:
sdk: ^3.12.0

dev_dependencies:
test: ^1.24.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:test/test.dart';

void main() {
group('very_good_config_fixture', () {
// This test exists only to produce a passing coverage run so the
// `min_coverage: 100` config can be evaluated against the deliberately
// uncovered `lib/uncovered.dart`.
test('trivially succeeds', () {
expect(true, isTrue);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
min_coverage: 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: malformed_fixture
description: Fixture for testing malformed very_good.yaml.
version: 0.1.0+1
publish_to: none

environment:
sdk: ^3.12.0

dev_dependencies:
test: ^1.24.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- not
- a
- map
121 changes: 121 additions & 0 deletions e2e/test/commands/test/very_good_config/very_good_config_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import 'package:mason/mason.dart';
import 'package:mocktail/mocktail.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:universal_io/io.dart';

import '../../../../helpers/helpers.dart';

void main() {
group('very_good.yaml', () {
test(
'enforces min-coverage from very_good.yaml when the flag is not passed',
timeout: const Timeout(Duration(minutes: 2)),
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
final tempDirectory = Directory.systemTemp.createTempSync(
'very_good_config',
);
addTearDown(() => tempDirectory.deleteSync(recursive: true));

final fixture = Directory(
path.join(
Directory.current.path,
'test/commands/test/very_good_config/fixture',
),
);

await copyDirectory(fixture, tempDirectory);

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

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

await expectLater(
commandRunner.run(['test', '--coverage']),
completion(equals(ExitCode.unavailable.code)),
);
verify(
() => logger.err(any(that: contains('Expected coverage >= 100.00%'))),
).called(1);
}),
);

test(
'CLI --min-coverage takes precedence over very_good.yaml',
timeout: const Timeout(Duration(minutes: 2)),
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
final tempDirectory = Directory.systemTemp.createTempSync(
'very_good_config_override',
);
addTearDown(() => tempDirectory.deleteSync(recursive: true));

final fixture = Directory(
path.join(
Directory.current.path,
'test/commands/test/very_good_config/fixture',
),
);

await copyDirectory(fixture, tempDirectory);

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

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

await expectLater(
commandRunner.run([
'test',
'--coverage',
'--min-coverage',
'0',
]),
completion(equals(ExitCode.success.code)),
);
}),
);

test(
'fails with config exit code when very_good.yaml is malformed',
timeout: const Timeout(Duration(minutes: 2)),
withRunner((commandRunner, logger, updater, logs, progressLogs) async {
final tempDirectory = Directory.systemTemp.createTempSync(
'very_good_config_malformed',
);
addTearDown(() => tempDirectory.deleteSync(recursive: true));

final fixture = Directory(
path.join(
Directory.current.path,
'test/commands/test/very_good_config/malformed_fixture',
),
);

await copyDirectory(fixture, tempDirectory);

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

await expectLater(
commandRunner.run(['test']),
completion(equals(ExitCode.config.code)),
);
verify(
() => logger.err(
any(that: contains('Could not read `very_good.yaml`')),
),
).called(1);
}),
);
});
}
Loading
Loading