@@ -19,6 +19,14 @@ fn c(cfn fn (string) string, s string) string {
1919 return term.colorize (cfn, s)
2020}
2121
22+ const hline = '-' .repeat (80 )
23+
24+ fn show_failure_output (output string ) {
25+ eprintln (hline)
26+ eprint (output)
27+ eprintln (hline)
28+ }
29+
2230const max_fail_percent = 100 * 1000
2331const max_time = 60 * 1000 // ms
2432
7078 nmaxs int // number of maximums to discard
7179 ignore_failed bool // ignore commands that exit with != 0 exit code
7280 no_vexe_setenv bool // do not change the VEXE variable
81+
82+ fail_count map [string ]int // how many times a command has failed so far. Only the first failure output is shown.
7383}
7484
7585fn new_aints (ovals []i64 , extreme_mins int , extreme_maxs int ) Aints {
@@ -192,13 +202,18 @@ fn (mut context Context) run() {
192202 mut sw := time.new_stopwatch ()
193203 res := os.execute (cmd)
194204 duration = i64 (sw.elapsed ().microseconds ())
205+ mut should_show_fail_output := false
195206 if res.exit_code != 0 && ! context.ignore_failed {
196- eprintln ('' )
197- eprintln ('Command exited with exit code: ${res .exit_code } in ${f64 (duration ) / 1000 :6.1 f }ms .' )
198- eprintln ('The failed command was: `${cmd }` .' )
207+ if context.fail_count[cmd] == 0 {
208+ should_show_fail_output = true
209+ }
210+ context.fail_count[cmd]++
211+ }
212+ if should_show_fail_output {
213+ eprintln ('\n Command exited with exit code: ${res .exit_code } in ${f64 (duration ) / 1000 :6.1 f }ms .' )
199214 eprintln ('Use -e or --ignore to ignore the failed commands.' )
200- eprintln ('' )
201- continue
215+ eprintln ('The failed cmd was: `${ cmd }` ; cmd output: ' )
216+ show_failure_output (res.output)
202217 }
203218 }
204219 }
@@ -207,9 +222,12 @@ fn (mut context Context) run() {
207222 res := os.execute (cmd)
208223 duration = i64 (sw.elapsed ().microseconds ())
209224 //
225+ mut should_show_fail_output := false
210226 if res.exit_code != 0 && ! context.ignore_failed {
211- eprintln ('${i + 1 :10 } non 0 exit code for cmd: ${cmd }' )
212- continue
227+ if context.fail_count[cmd] == 0 {
228+ should_show_fail_output = true
229+ }
230+ context.fail_count[cmd]++
213231 }
214232 sum + = duration
215233 runs++
@@ -227,6 +245,10 @@ fn (mut context Context) run() {
227245 }
228246 context.results[icmd].timings << duration
229247 oldres = res.output.replace ('\n ' , ' ' )
248+ if should_show_fail_output {
249+ eprintln ('\n ${i + 1 :10 } non 0 exit code for cmd: ${cmd }; cmd output:' )
250+ show_failure_output (res.output)
251+ }
230252 }
231253 context.results[icmd].cmd = cmd
232254 context.results[icmd].icmd = icmd
0 commit comments