@@ -22,6 +22,8 @@ pub const github_job = os.getenv('GITHUB_JOB')
2222
2323pub const runner_os = os.getenv ('RUNNER_OS' ) // GitHub runner OS
2424
25+ pub const show_cmd = os.getenv ('VTEST_SHOW_CMD' ) == '1'
26+
2527pub const show_start = os.getenv ('VTEST_SHOW_START' ) == '1'
2628
2729pub const hide_skips = os.getenv ('VTEST_HIDE_SKIP' ) == '1'
@@ -226,6 +228,20 @@ pub fn (mut ts TestSession) print_messages() {
226228 }
227229}
228230
231+ pub fn (mut ts TestSession) execute (cmd string , mtc MessageThreadContext) os.Result {
232+ if show_cmd {
233+ ts.append_message (.info, '> execute cmd: ${cmd} ' , mtc)
234+ }
235+ return os.execute (cmd)
236+ }
237+
238+ pub fn (mut ts TestSession) system (cmd string , mtc MessageThreadContext) int {
239+ if show_cmd {
240+ ts.append_message (.info, '> system cmd: ${cmd} ' , mtc)
241+ }
242+ return os.system (cmd)
243+ }
244+
229245pub fn new_test_session (_vargs string , will_compile bool ) TestSession {
230246 mut skip_files := []string {}
231247 if will_compile {
@@ -511,8 +527,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
511527 if ts.show_stats {
512528 ts.append_message (.cmd_begin, cmd, mtc)
513529 d_cmd := time.new_stopwatch ()
514-
515- mut res := os.execute (cmd)
530+ mut res := ts.execute (cmd, mtc)
516531 if res.exit_code != 0 {
517532 eprintln (res.output)
518533 } else {
@@ -531,10 +546,9 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
531546 mtc)
532547 }
533548 os.setenv ('VTEST_RETRY' , '${retry} ' , true )
534-
535549 ts.append_message (.cmd_begin, cmd, mtc)
536550 d_cmd_2 := time.new_stopwatch ()
537- status = os .system (cmd)
551+ status = ts .system (cmd, mtc )
538552 cmd_duration = d_cmd_2 .elapsed ()
539553 ts.append_message_with_duration (.cmd_end, '' , cmd_duration, mtc)
540554
@@ -570,7 +584,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
570584 compile_d_cmd := time.new_stopwatch ()
571585 mut compile_r := os.Result{}
572586 for cretry in 0 .. max_compilation_retries {
573- compile_r = os .execute (cmd)
587+ compile_r = ts .execute (cmd, mtc )
574588 compile_cmd_duration = compile_d_cmd.elapsed ()
575589 // eprintln('>>>> cretry: $cretry | compile_r.exit_code: $compile_r.exit_code | compile_cmd_duration: ${compile_cmd_duration:8} | file: $normalised_relative_file')
576590 if compile_r.exit_code == 0 {
@@ -600,10 +614,10 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
600614 }
601615 //
602616 mut retry := 1
603- ts.append_message (.cmd_begin, run_cmd, mtc)
604617 mut failure_output := strings.new_builder (1024 )
618+ ts.append_message (.cmd_begin, run_cmd, mtc)
605619 d_cmd := time.new_stopwatch ()
606- mut r := os .execute (run_cmd)
620+ mut r := ts .execute (run_cmd, mtc )
607621 cmd_duration = d_cmd.elapsed ()
608622 ts.append_message_with_duration (.cmd_end, r.output, cmd_duration, mtc)
609623 if ts.show_asserts && r.exit_code == 0 {
@@ -627,10 +641,9 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
627641 mtc)
628642 }
629643 os.setenv ('VTEST_RETRY' , '${retry} ' , true )
630-
631644 ts.append_message (.cmd_begin, run_cmd, mtc)
632645 d_cmd_2 := time.new_stopwatch ()
633- r = os .execute (run_cmd)
646+ r = ts .execute (run_cmd, mtc )
634647 cmd_duration = d_cmd_2 .elapsed ()
635648 ts.append_message_with_duration (.cmd_end, r.output, cmd_duration, mtc)
636649
0 commit comments