Skip to content

Commit d32fe2b

Browse files
committed
tools: make reproduction of failed examples easier (make sure that all the checked sources have an ending \n)
1 parent 8645d43 commit d32fe2b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/tools/vdoc/run_examples.v

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,14 @@ fn (mut vd VDoc) run_examples(dn doc.DocNode) {
6262
vsource_path := os.join_path(efolder, 'example_${rand.ulid()}.v')
6363
// eprintln('>>> example dn.file_path: ${dn.file_path} | mod_name: ${mod_name} | vsource_path: ${vsource_path} | code: `${code}`')
6464
import_clause := if mod_name in ['builtin', ''] { '' } else { 'import ${mod_name}\n' }
65-
source := if import_clause != '' && !code.contains('import ') {
65+
mut source := if import_clause != '' && !code.contains('import ') {
6666
'${import_clause}fn main() {\n\t${code}\n}\n'
6767
} else {
6868
code
6969
}
70+
if !source.ends_with('\n') {
71+
source += '\n'
72+
}
7073
os.write_file(vsource_path, source) or { continue }
7174
vd.vprintln('>>> vd.example_oks: ${vd.example_oks:5} | vd.example_failures: ${vd.example_failures:5} | examples.len: ${examples.len} | source.len: ${source.len:5} | dn.name: ${dn.name}')
7275
cmd := '${os.quoted_path(vexe)} ${voptions} ${os.quoted_path(vsource_path)}'

0 commit comments

Comments
 (0)