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

cgen,pref: add -coverage support #21154

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

felipensp
Copy link
Member

@felipensp felipensp commented Mar 31, 2024

Enable using v -cov output-file run file.v or v -coverage output-file run file.v.

Currently it is working with one file only.

@felipensp felipensp marked this pull request as ready for review May 13, 2024 23:47
@spytheman spytheman changed the title v: code coverage cgen,pref: add -coverage support May 14, 2024
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman
Copy link
Member

spytheman commented May 14, 2024

@felipensp, I've tested running this:

if true {
	println('branch 1')
	if true {
		println('branch 1.1')
		if true {
			println('branch 1.1.1')
		} else {
			println('branch 1.1.2')
		}
	} else {
		println('branch 1.2')
		if true {
			println('branch 1.2.1')
		} else {
			println('branch 1.2.2')
		}
	}
} else {
	println('branch 2')
	if true {
		println('branch 2.1')
		if true {
			println('branch 2.1.1')
		} else {
			println('branch 2.1.2')
		}
	} else {
		println('branch 2.2')
		if true {
			println('branch 2.2.1')
		} else {
			println('branch 2.2.2')
		}
	}
}

with: v -coverage - run branches.v, and I got:

#0 13:07:08 ^ v_coverage /v/oo>v -coverage - run branches.v
branch 1
branch 1.1
branch 1.1.1
V coverage
--------------------------------------------------
[   0.00%]    0 /   98 | /space/v/oo/vlib/strings/builder.c.v
[   0.00%]    0 /   43 | /space/v/oo/vlib/strings/similarity.v
[   0.00%]    0 /   18 | /space/v/oo/vlib/strings/strings.c.v
[   0.00%]    0 /   59 | /space/v/oo/vlib/strings/strings.v
[   0.00%]    0 /  152 | /space/v/oo/vlib/math/bits/bits.v
[   0.00%]    0 /    0 | /space/v/oo/vlib/math/bits/bits_tables.v
[   0.00%]    0 /    8 | /space/v/oo/vlib/math/bits/unsafe_bits.v
[   0.00%]    0 /  191 | /space/v/oo/vlib/strconv/atof.c.v
[   0.00%]    0 /   60 | /space/v/oo/vlib/strconv/atofq.c.v
[   0.00%]    0 /  104 | /space/v/oo/vlib/strconv/atoi.v
[   0.00%]    0 /  176 | /space/v/oo/vlib/strconv/f32_str.c.v
[   0.00%]    0 /  198 | /space/v/oo/vlib/strconv/f64_str.c.v
[   0.00%]    0 /    0 | /space/v/oo/vlib/strconv/f64_str.v
[   0.00%]    0 /   13 | /space/v/oo/vlib/strconv/format.v
[   0.00%]    0 /  269 | /space/v/oo/vlib/strconv/format_mem.c.v
[   0.00%]    0 /    4 | /space/v/oo/vlib/strconv/ftoa.c.v
[   0.00%]    0 /   38 | /space/v/oo/vlib/strconv/number_to_base.c.v
[   0.00%]    0 /    0 | /space/v/oo/vlib/strconv/tables.v
[   0.00%]    0 /  166 | /space/v/oo/vlib/strconv/utilities.c.v
[   0.00%]    0 /   98 | /space/v/oo/vlib/strconv/utilities.v
[   0.00%]    0 /  433 | /space/v/oo/vlib/strconv/vprintf.c.v
[   0.00%]    0 /    9 | /space/v/oo/vlib/builtin/array.v
[   3.36%]    4 /  119 | /space/v/oo/vlib/builtin/array_d_gcboehm_opt.v
[   0.00%]    0 /    4 | /space/v/oo/vlib/builtin/backtraces.c.v
[   0.00%]    0 /   21 | /space/v/oo/vlib/builtin/backtraces_nix.c.v
[  18.48%]   39 /  211 | /space/v/oo/vlib/builtin/builtin.c.v
[   0.00%]    0 /   28 | /space/v/oo/vlib/builtin/builtin.v
[  14.29%]    1 /    7 | /space/v/oo/vlib/builtin/builtin_d_gcboehm.c.v
[  33.33%]    2 /    6 | /space/v/oo/vlib/builtin/builtin_nix.c.v
[  20.00%]    3 /   15 | /space/v/oo/vlib/builtin/cfns_wrapper.c.v
[   0.00%]    0 /    2 | /space/v/oo/vlib/builtin/chan.v
[   0.00%]    0 /   11 | /space/v/oo/vlib/builtin/character_inout.c.v
[   0.00%]    0 /   69 | /space/v/oo/vlib/builtin/float.c.v
[   0.00%]    0 /  207 | /space/v/oo/vlib/builtin/int.v
[   0.00%]    0 /   34 | /space/v/oo/vlib/builtin/map.c.v
[   0.00%]    0 /  306 | /space/v/oo/vlib/builtin/map.v
[   0.00%]    0 /   38 | /space/v/oo/vlib/builtin/map_d_gcboehm_opt.v
[   0.00%]    0 /    3 | /space/v/oo/vlib/builtin/option.c.v
[   0.00%]    0 /    8 | /space/v/oo/vlib/builtin/option.v
[   0.00%]    0 /   15 | /space/v/oo/vlib/builtin/result.v
[   0.00%]    0 /   24 | /space/v/oo/vlib/builtin/rune.v
[   0.00%]    0 /  206 | /space/v/oo/vlib/builtin/sorted_map.v
[   0.00%]    0 /  951 | /space/v/oo/vlib/builtin/string.v
[   0.00%]    0 /    9 | /space/v/oo/vlib/builtin/string_charptr_byteptr_helpers.v
[   0.00%]    0 /  364 | /space/v/oo/vlib/builtin/string_interpolation.v
[   0.00%]    0 /   18 | /space/v/oo/vlib/builtin/utf8.c.v
[   0.00%]    0 /   69 | /space/v/oo/vlib/builtin/utf8.v
[  54.55%]    6 /   11 | branches.v
--------------------------------------------------
Total coverage: 48 files, 1.12% coverage
#0 13:07:41 ^ v_coverage /v/oo>

Why does it print all the .v files for all modules (used in the program), given that for most programs, most of their functionality, will not be used?

I think that skipping all the ones, for which there is 0 coverage will be more useful and more compact.

@felipensp felipensp marked this pull request as draft May 14, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants