Support coverage in neotest #972

Open
opened 2025-12-28 17:14:48 +00:00 by sami · 4 comments
Owner

Originally created by @fyrchik on GitHub (Aug 22, 2022).

It would be nice to check that contract tests cover all possible branches.

So basically there are 2 parts:

  1. Execute VM, while tracking executed opcodes and mapping them to the source code lines using DebugInfo. It has a lot of runtime overhead, but we can have a separate package which contains all the logic and use it only with certain test flags.
  2. Create custom coverage file.

As a nice consequence, we can use this to check for the presence of dead-code which can be used to optimize the compiler itself.

The most difficult part of this is to figure out clean interface without a lot of overhead.

Another difficulty (optional feature) is to have nice green lines displayed by GoLand, so far this was my biggest issue.

Originally created by @fyrchik on GitHub (Aug 22, 2022). It would be nice to check that contract tests cover all possible branches. So basically there are 2 parts: 1. Execute VM, while tracking executed opcodes and mapping them to the source code lines using `DebugInfo`. It has a lot of runtime overhead, but we can have a separate package which contains all the logic and use it only with certain test flags. 2. Create custom coverage file. As a nice consequence, we can use this to check for the presence of dead-code which can be used to optimize the compiler itself. The most difficult part of this is to figure out clean interface without a lot of overhead. Another difficulty (optional feature) is to have nice green lines displayed by GoLand, so far this was my biggest issue.
Author
Owner

@roman-khimov commented on GitHub (Aug 22, 2022):

Yeah, that'd be really cool, but I think it can only be done properly at the VM level and it won't be trivial.

@roman-khimov commented on GitHub (Aug 22, 2022): Yeah, that'd be really cool, but I think it can only be done properly at the VM level and it won't be trivial.
Author
Owner

@fyrchik commented on GitHub (Aug 22, 2022):

The thing I had in mind is to leave VM as it is: make custom Execute which executes code step-by-step and updates seen opcodes/lines. The vm.Run is rather simple so it can be copied with minimum changes.

@fyrchik commented on GitHub (Aug 22, 2022): The thing I had in mind is to leave VM as it is: make custom `Execute` which executes code step-by-step and updates seen opcodes/lines. The `vm.Run` is rather simple so it can be copied with minimum changes.
Author
Owner

@AnnaShaleva commented on GitHub (Dec 28, 2022):

We have POC written by @fyrchik in https://github.com/nspcc-dev/neo-go/tree/neotest-coverage, so let's keep this branch linked for now.

@AnnaShaleva commented on GitHub (Dec 28, 2022): We have POC written by @fyrchik in https://github.com/nspcc-dev/neo-go/tree/neotest-coverage, so let's keep this branch linked for now.
Author
Owner

@roman-khimov commented on GitHub (Dec 28, 2024):

Still relevant?

@roman-khimov commented on GitHub (Dec 28, 2024): Still relevant?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neo-go#972
No description provided.