Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed May 24, 2024
1 parent 791d7ba commit a561426
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions vlib/v/gen/c/coverage.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module c

import v.token
import os
import rand { ulid }

@[inline]
Expand Down Expand Up @@ -39,11 +40,11 @@ fn (mut g Gen) write_coverage_stats() {
build_hash := ulid()

g.cov_declarations.writeln('void vprint_coverage_stats() {')

g.cov_declarations.writeln('time_t rawtime;')
g.cov_declarations.writeln('char cov_filename[120];')
g.cov_declarations.writeln('time(&rawtime);')
g.cov_declarations.writeln('snprintf(cov_filename, 120, "vcover.%s.%s", "${build_hash}", vcoverage_fnv1a(asctime(localtime(&rawtime))));')
g.cov_declarations.writeln('\ttime_t rawtime;')
g.cov_declarations.writeln('\tchar cov_filename[120];')
g.cov_declarations.writeln('\ttime(&rawtime);')
g.cov_declarations.writeln('\tchar *cov_dir = getenv("VCOVDIR") != NULL ? getenv("VCOVDIR") : "${os.real_path(g.pref.coverage_dir)}";')
g.cov_declarations.writeln('\tsnprintf(cov_filename, 120, "%s/vcover.%s.%s", cov_dir, "${build_hash}", vcoverage_fnv1a(asctime(localtime(&rawtime))));')
g.cov_declarations.writeln('\tFILE *fp = fopen(cov_filename, "w+");')
g.cov_declarations.writeln('\tfprintf(fp, "[");')
g.cov_declarations.writeln('\tint t_counter = 0;')
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/pref/pref.v
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub mut:
eval_argument string // `println(2+2)` on `v -e "println(2+2)"`. Note that this source code, will be evaluated in vsh mode, so 'v -e 'println(ls(".")!)' is valid.
test_runner string // can be 'simple' (fastest, but much less detailed), 'tap', 'normal'
profile_file string // the profile results will be stored inside profile_file
coverage_file string // the coverage results will be stored inside coverage_file
coverage_dir string // the coverage files will be stored inside coverage_dir
profile_no_inline bool // when true, [inline] functions would not be profiled
profile_fns []string // when set, profiling will be off by default, but inside these functions (and what they call) it will be on.
translated bool // `v translate doom.v` are we running V code translated from C? allow globals, ++ expressions, etc
Expand Down Expand Up @@ -604,9 +604,9 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
i++
}
'-cov', '-coverage' {
res.coverage_file = cmdline.option(args[i..], arg, '-')
res.coverage_dir = cmdline.option(args[i..], arg, '-')
res.is_coverage = true
res.build_options << '${arg} ${res.coverage_file}'
res.build_options << '${arg} ${res.coverage_dir}'
i++
}
'-profile-fns' {
Expand Down

0 comments on commit a561426

Please sign in to comment.