Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle --coverage-report with dafny translate (or legacy compilation option) #4965

Open
codyroux opened this issue Jan 9, 2024 · 6 comments
Assignees
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny

Comments

@codyroux
Copy link

codyroux commented Jan 9, 2024

Summary

Currently there is no way to generate coverage report with separately compiled Dafny.

Background and Motivation

To compile tests, I call (legacy)
dafny -spillTargetCode:3 -out:/some/runtime/folder -runAllTests:1 ...

and run it with
dotnet run ...

This does not enable passing in the option --coverage-report. Calling dafny test DafnyFile.dfy is difficult since the {:extern} functions need to be linked via some fiddly C# compilation configuration.

Proposed Feature

We propose adding the ability for dafny -spillTargetCode:3 or dafny translate cs (ideally the former for now) to handle the --coverage-report flag, which would behave as if one called dafny test --coverage-report:some-folder directly, when running the emitted code with dotnet run.

Alternatives

I'm not sure what the alternative is, possibly enabling linking C# externs more easily in the dafny test configuration.

@codyroux codyroux added the kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny label Jan 9, 2024
@robin-aws robin-aws self-assigned this Jan 9, 2024
@robin-aws
Copy link
Member

I'm not sure what the alternative is, possibly enabling linking C# externs more easily in the dafny test configuration.

Correct me if I'm wrong, but this is particularly tricky because you don't just have a few C# files to pass into dafny test (which isn't currently possible since only dafny run takes the --input option, but that could be fixed easily), but you also have a dependency on a Nuget package you'd have to fetch the DLL for and pass in, which is even more awkward.

@codyroux
Copy link
Author

codyroux commented Jan 9, 2024

That's correct, yes.

@keyboardDrummer
Copy link
Member

keyboardDrummer commented Jan 10, 2024

@codyroux It sounds like you're saying there's an option --coverage-report that can be used with dafny test, but you can't use it because you're not using dafny test directly. However, there is no --coverage-report option for dafny test. There is one for dafny generate-tests, but I don't see how the semantics of that option could translate to dafny test or dafny translate, since they relate to verification based test generation.

@codyroux
Copy link
Author

I'm referring to this feature: 4d7bdf5

I think it's referenced here: http:https://dafny.org/dafny/DafnyRef/DafnyRef#sec-dafny-test

@keyboardDrummer keyboardDrummer changed the title Handle --coverage-report with dafny translate (or legacy compilation option) Handle --verification-coverage-report with dafny translate (or legacy compilation option) Jan 10, 2024
@keyboardDrummer keyboardDrummer changed the title Handle --verification-coverage-report with dafny translate (or legacy compilation option) Handle --coverage-report with dafny translate (or legacy compilation option) Jan 10, 2024
@keyboardDrummer
Copy link
Member

Ah, I see. Sorry for my mistake! I was looking at Dafny 4.3 options.

@keyboardDrummer
Copy link
Member

keyboardDrummer commented Jan 11, 2024

I think what we can do is change dafny translate --include-test-runner --coverage-report=<file> so that when the translated code is run, using non-Dafny implementations of externs and other configuration you provide to it, the resulting binary will write a code coverage report that follows some standard, like the Cobertura coverage format, to the <file> location that was specified when running dafny translate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny
Projects
None yet
Development

No branches or pull requests

3 participants