| 1 | import os |
| 2 | import time |
| 3 | import v.ast |
| 4 | import v.parser |
| 5 | import v.pref |
| 6 | import v.util |
| 7 | |
| 8 | fn run_true_exit_code() int { |
| 9 | return os.execute('true').exit_code |
| 10 | } |
| 11 | |
| 12 | fn spawn_execute_elapsed_ms() (i64, int) { |
| 13 | sw := time.new_stopwatch() |
| 14 | t := spawn run_true_exit_code() |
| 15 | exit_code := t.wait() |
| 16 | return sw.elapsed().milliseconds(), exit_code |
| 17 | } |
| 18 | |
| 19 | fn test_parse_file_does_not_poison_spawn_execute_on_macos() { |
| 20 | $if !macos { |
| 21 | return |
| 22 | } |
| 23 | util.timing_set_should_print(false) |
| 24 | before_ms, before_exit_code := spawn_execute_elapsed_ms() |
| 25 | assert before_exit_code == 0 |
| 26 | mut table := ast.new_table() |
| 27 | prefs := pref.new_preferences() |
| 28 | _ := parser.parse_file(@FILE, mut table, .skip_comments, prefs) |
| 29 | after_ms, after_exit_code := spawn_execute_elapsed_ms() |
| 30 | assert after_exit_code == 0 |
| 31 | assert after_ms < 5000, 'spawn + os.execute slowed down from ${before_ms}ms to ${after_ms}ms' |
| 32 | } |
| 33 | |