@@ -22,6 +22,7 @@ const (
2222 show_progress = os.getenv ('GITHUB_JOB' ) == '' && '-silent' ! in os.args
2323 non_option_args = cmdline.only_non_options (os.args[2 ..])
2424 is_verbose = os.getenv ('VERBOSE' ) != ''
25+ vcheckfolder = os.join_path_single (os.temp_dir (), 'vcheck_$os.getuid ()' )
2526)
2627
2728struct CheckResult {
@@ -57,6 +58,10 @@ fn main() {
5758 if term_colors {
5859 os.setenv ('VCOLORS' , 'always' , true )
5960 }
61+ os.mkdir_all (vcheckfolder) or {}
62+ defer {
63+ os.rmdir_all (vcheckfolder) or {}
64+ }
6065 for i := 0 ; i < files_paths.len; i++ {
6166 file_path := files_paths[i]
6267 if os.is_dir (file_path) {
@@ -427,8 +432,9 @@ fn (mut f MDFile) check_examples() CheckResult {
427432 }
428433 fname := os.base (f.path).replace ('.md' , '_md' )
429434 uid := rand.ulid ()
430- cfile := os.join_path (os.temp_dir (), '${uid} .c' )
431- vfile := os.join_path (os.temp_dir (), 'check_${fname} _example_${e.sline} __${e.eline} __${uid} .v' )
435+ cfile := os.join_path (vcheckfolder, '${uid} .c' )
436+ vfile := os.join_path (vcheckfolder, 'check_${fname} _example_${e.sline} __${e.eline} __${uid} .v' )
437+ efile := os.join_path (vcheckfolder, 'check_${fname} _example_${e.sline} __${e.eline} __${uid} .exe' )
432438 mut should_cleanup_vfile := true
433439 // eprintln('>>> checking example $vfile ...')
434440 vcontent := e.text.join ('\n ' ) + '\n '
@@ -440,7 +446,7 @@ fn (mut f MDFile) check_examples() CheckResult {
440446 fmt_res := if nofmt { 0 } else { get_fmt_exit_code (vfile, vexe) }
441447 match command {
442448 'compile' {
443- res := cmdexecute ('${os.quoted_path(vexe)} -w -Wfatal-errors ${os.quoted_path(vfile)} ' )
449+ res := cmdexecute ('${os.quoted_path(vexe)} -w -Wfatal-errors -o ${os.quoted_path(efile)} ${os.quoted_path(vfile)} ' )
444450 if res != 0 || fmt_res != 0 {
445451 if res != 0 {
446452 eprintln (eline (f.path, e.sline, 0 , 'example failed to compile' ))
@@ -457,7 +463,6 @@ fn (mut f MDFile) check_examples() CheckResult {
457463 }
458464 'cgen' {
459465 res := cmdexecute ('${os.quoted_path(vexe)} -w -Wfatal-errors -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)} ' )
460- os.rm (cfile) or {}
461466 if res != 0 || fmt_res != 0 {
462467 if res != 0 {
463468 eprintln (eline (f.path, e.sline, 0 , 'example failed to generate C code' ))
@@ -474,7 +479,6 @@ fn (mut f MDFile) check_examples() CheckResult {
474479 }
475480 'globals' {
476481 res := cmdexecute ('${os.quoted_path(vexe)} -w -Wfatal-errors -enable-globals -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)} ' )
477- os.rm (cfile) or {}
478482 if res != 0 || fmt_res != 0 {
479483 if res != 0 {
480484 eprintln (eline (f.path, e.sline, 0 , '`example failed to compile with -enable-globals' ))
@@ -491,7 +495,6 @@ fn (mut f MDFile) check_examples() CheckResult {
491495 }
492496 'live' {
493497 res := cmdexecute ('${os.quoted_path(vexe)} -w -Wfatal-errors -live -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)} ' )
494- os.rm (cfile) or {}
495498 if res != 0 || fmt_res != 0 {
496499 if res != 0 {
497500 eprintln (eline (f.path, e.sline, 0 , 'example failed to compile with -live' ))
@@ -508,7 +511,6 @@ fn (mut f MDFile) check_examples() CheckResult {
508511 }
509512 'failcompile' {
510513 res := silent_cmdexecute ('${os.quoted_path(vexe)} -w -Wfatal-errors -o ${os.quoted_path(cfile)} ${os.quoted_path(vfile)} ' )
511- os.rm (cfile) or {}
512514 if res == 0 || fmt_res != 0 {
513515 if res == 0 {
514516 eprintln (eline (f.path, e.sline, 0 , '`failcompile` example compiled' ))
@@ -558,6 +560,8 @@ fn (mut f MDFile) check_examples() CheckResult {
558560 }
559561 }
560562 }
563+ os.rm (cfile) or {}
564+ os.rm (efile) or {}
561565 if should_cleanup_vfile {
562566 os.rm (vfile) or { panic (err) }
563567 }
0 commit comments