Skip to content

Commit

Permalink
refactor: update coverage output paths to use 'coverage_data' directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruv-Maradiya committed Jan 29, 2025
1 parent fcfca3f commit c085b13
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 17 deletions.
29 changes: 17 additions & 12 deletions pkgs/coverage/test/collect_coverage_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ void main() {
expect(collectedCoverage.functionCoverage, isTrue);
expect(collectedCoverage.branchCoverage, isFalse);
expect(path.canonicalize(collectedCoverage.out!),
path.canonicalize('test/test_coverage_options/coverage/coverage.json'));
path.canonicalize(
'test/test_coverage_options/coverage_data/coverage.json'));

// Verify format coverage yaml values
expect(path.canonicalize(formattedCoverage.output!),
path.canonicalize('test/test_coverage_options/coverage/lcov.info'));
path.canonicalize(
'test/test_coverage_options/coverage_data/lcov.info'));
expect(path.canonicalize(formattedCoverage.packagePath),
path.canonicalize('test/test_files'));

Expand All @@ -75,7 +77,7 @@ void main() {
path.canonicalize('test/test_files'));
expect(testCoverage.packageName, 'My Dart Package');
expect(path.canonicalize(testCoverage.outDir),
path.canonicalize('test/test_coverage_options/coverage'));
path.canonicalize('test/test_coverage_options/coverage_data'));
expect(testCoverage.testScript, 'test1');
expect(testCoverage.functionCoverage, isTrue);
expect(testCoverage.branchCoverage, isFalse);
Expand All @@ -99,13 +101,13 @@ void main() {
expect(
path.canonicalize(collectedCoverage.out!),
path.canonicalize(
'test/test_coverage_options/coverage/custom_coverage/coverage.json'));
'test/test_coverage_options/coverage_data/custom_coverage/coverage.json'));
expect(collectedCoverage.scopedOutput, ['lib', 'test']);
expect(collectedCoverage.functionCoverage, isFalse);
expect(
path.canonicalize(formattedCoverage.output!),
path.canonicalize(
'test/test_coverage_options/coverage/custom_coverage/lcov.info'));
'test/test_coverage_options/coverage_data/custom_coverage/lcov.info'));
expect(testCoverage.packageName, 'Custom Dart Package');
expect(testCoverage.scopeOutput, ['lib', 'test']);
});
Expand All @@ -130,20 +132,21 @@ void main() {
expect(
path.canonicalize(collectedCoverage.out!),
path.canonicalize(
'test/test_coverage_options/coverage/custom_lcov/coverage.json'));
'test/test_coverage_options/coverage_data/custom_lcov/coverage.json'));

// Verify format coverage yaml values
expect(
path.canonicalize(formattedCoverage.output!),
path.canonicalize(
'test/test_coverage_options/coverage/custom_lcov/lcov.info'));
'test/test_coverage_options/coverage_data/custom_lcov/lcov.info'));
expect(path.canonicalize(formattedCoverage.packagePath),
path.canonicalize('test/test_coverage_options'));

// Verify test with coverage yaml values
expect(testCoverage.packageName, 'coverage');
expect(path.canonicalize(testCoverage.outDir),
path.canonicalize('test/test_coverage_options/coverage/custom_lcov'));
path.canonicalize(
'test/test_coverage_options/coverage_data/custom_lcov'));
expect(testCoverage.testScript, 'custom_test');
expect(testCoverage.functionCoverage, isTrue);
});
Expand All @@ -157,13 +160,13 @@ void main() {

// Parse arguments with command line args
final collectedCoverage = collect_coverage.parseArgs([
'--out=/test/test_coverage_options/coverage/coverage.json',
'--out=/test/test_coverage_options/coverage_data/coverage.json',
'--scope-output=lib',
'--no-function-coverage',
'--branch-coverage',
], configuredOptions);
final formattedCoverage = format_coverage.parseArgs([
'--out=/test/test_coverage_options/coverage/out_test.info',
'--out=/test/test_coverage_options/coverage_data/out_test.info',
'--package=../code_builder',
], configuredOptions);
final testCoverage = await test_with_coverage.parseArgs([
Expand All @@ -175,14 +178,16 @@ void main() {

// Verify collect coverage command line args
expect(collectedCoverage.out,
path.normalize('/test/test_coverage_options/coverage/coverage.json'));
path.normalize(
'/test/test_coverage_options/coverage_data/coverage.json'));
expect(collectedCoverage.scopedOutput, ['lib']);
expect(collectedCoverage.functionCoverage, isFalse);
expect(collectedCoverage.branchCoverage, isTrue);

// Verify format coverage command line args
expect(formattedCoverage.output,
path.normalize('/test/test_coverage_options/coverage/out_test.info'));
path.normalize(
'/test/test_coverage_options/coverage_data/out_test.info'));
expect(formattedCoverage.packagePath, '../code_builder');

// Verify test with coverage command line args
Expand Down
2 changes: 1 addition & 1 deletion pkgs/coverage/test/test_coverage_options/all_field.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output-directory: "coverage"
output-directory: "coverage_data"
scope-output: ["lib", "src"]
function-coverage: true
branch-coverage: false
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output-directory: 'coverage/custom_coverage'
output-directory: 'coverage_data/custom_coverage'
scope-output:
- 'lib'
- 'test'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ scope-output:
- 'lib'
- 'tools'
branch-coverage: false
output-directory: 'coverage/custom_lcov'
output-directory: 'coverage_data/custom_lcov'
package-directory: '.'
test_script: 'custom_test'
function-coverage: true
2 changes: 1 addition & 1 deletion pkgs/coverage/test/test_file_locator/pkg1/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
name: pkg1
name: pkg1
2 changes: 1 addition & 1 deletion pkgs/coverage/test/test_file_locator/pkg2/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
name: pkg2
name: pkg2

0 comments on commit c085b13

Please sign in to comment.