This repository was archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Add lines key to v1 source coverage JSON
#2718
Merged
ranweiler
merged 7 commits into
microsoft:main
from
ranweiler:source-coverage-lines-key
Dec 21, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ffaf013
Rename binary coverage integration test
ranweiler 92832a5
Add `lines` subkey to v1 source coverage JSON
ranweiler 569e546
Merge branch 'main' into source-coverage-lines-key
ranweiler dee86b1
Lint
ranweiler 9247694
Merge branch 'source-coverage-lines-key' of github.com:ranweiler/onef…
ranweiler 36bb1f7
Derive `Eq`
ranweiler 9bda942
Merge branch 'main' into source-coverage-lines-key
ranweiler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
src/agent/onefuzz-file-format/tests/files/source-coverage.v0.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [ | ||
| { | ||
| "file": "src/bin/main.c", | ||
| "locations": [ | ||
| { "line": 4, "column": 1, "count": 1 }, | ||
| { "line": 9, "column": 2, "count": 0 }, | ||
| { "line": 12, "column": 3, "count": 5 } | ||
| ] | ||
| }, | ||
| { | ||
| "file": "src/lib/common.c", | ||
| "locations": [ | ||
| { "line": 5, "column": null, "count": 0 }, | ||
| { "line": 5, "column": null, "count": 1 }, | ||
| { "line": 8, "column": null, "count": 0 } | ||
| ] | ||
| } | ||
| ] |
15 changes: 15 additions & 0 deletions
15
src/agent/onefuzz-file-format/tests/files/source-coverage.v1.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "src/bin/main.c": { | ||
| "lines": { | ||
| "4": 1, | ||
| "9": 0, | ||
| "12": 5 | ||
| } | ||
| }, | ||
| "src/lib/common.c": { | ||
| "lines": { | ||
| "5": 1, | ||
| "8": 0 | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| use pretty_assertions::assert_eq; | ||
|
|
||
| use anyhow::Result; | ||
| use coverage::source::{Count, Line, SourceCoverage}; | ||
| use debuggable_module::path::FilePath; | ||
| use onefuzz_file_format::coverage::source::{v0, v1}; | ||
|
|
||
| fn expected_source_coverage() -> Result<SourceCoverage> { | ||
| let main_path = FilePath::new("src/bin/main.c")?; | ||
| let common_path = FilePath::new("src/lib/common.c")?; | ||
|
|
||
| let mut source = SourceCoverage::default(); | ||
|
|
||
| let main = source.files.entry(main_path).or_default(); | ||
| main.lines.insert(Line::new(4)?, Count(1)); | ||
| main.lines.insert(Line::new(9)?, Count(0)); | ||
| main.lines.insert(Line::new(12)?, Count(5)); | ||
|
|
||
| let common = source.files.entry(common_path).or_default(); | ||
| common.lines.insert(Line::new(5)?, Count(1)); | ||
| common.lines.insert(Line::new(8)?, Count(0)); | ||
|
|
||
| Ok(source) | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_source_coverage_formats() -> Result<()> { | ||
| let expected = expected_source_coverage()?; | ||
|
|
||
| let v0_text = include_str!("files/source-coverage.v0.json"); | ||
| let v0_json: v0::SourceCoverageJson = serde_json::from_str(v0_text)?; | ||
| let from_v0 = SourceCoverage::try_from(v0_json)?; | ||
| assert_eq!(from_v0, expected); | ||
|
|
||
| let v1_text = include_str!("files/source-coverage.v1.json"); | ||
| let v1_json: v1::SourceCoverageJson = serde_json::from_str(v1_text)?; | ||
| let from_v1 = SourceCoverage::try_from(v1_json)?; | ||
| assert_eq!(from_v1, expected); | ||
|
|
||
| Ok(()) | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.