|
| 1 | +import os |
| 2 | + |
| 3 | +const tfile = os.join_path(os.vtmp_dir(), 'unknown_options_output.c') |
| 4 | + |
| 5 | +fn test_unknown_option_flags_no_run() { |
| 6 | + os.chdir(os.dir(@VEXE))! |
| 7 | + os.rm(tfile) or {} |
| 8 | + |
| 9 | + res1 := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(tfile)} examples/hello_world.v --an-unknown-option') |
| 10 | + assert res1.exit_code == 1 |
| 11 | + assert res1.output.starts_with('Unknown argument') |
| 12 | + assert res1.output.contains('--an-unknown-option') |
| 13 | + assert !os.exists(tfile) |
| 14 | + |
| 15 | + res2 := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(tfile)} --an-unknown-option examples/hello_world.v') |
| 16 | + assert res2.exit_code == 1 |
| 17 | + assert res2.output.starts_with('Unknown argument') |
| 18 | + assert res2.output.contains('--an-unknown-option') |
| 19 | + assert !os.exists(tfile) |
| 20 | +} |
| 21 | + |
| 22 | +fn test_unknown_option_flags_with_run() { |
| 23 | + res_run_o := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(tfile)} run examples/hello_world.v --an-unknown-option') |
| 24 | + assert res_run_o.exit_code == 0 |
| 25 | + assert res_run_o.output == '' // because of -o, there should not be an actual run, since compilation stopped after generating the .c file |
| 26 | + assert os.exists(tfile) |
| 27 | + os.rm(tfile) or {} |
| 28 | + |
| 29 | + res_run_no_o_unknown_before_run := os.execute('${os.quoted_path(@VEXE)} --an-unknown-option run examples/hello_world.v ') |
| 30 | + assert res_run_no_o_unknown_before_run.exit_code == 1 |
| 31 | + assert res_run_no_o_unknown_before_run.output.starts_with('Unknown argument') |
| 32 | + assert res_run_no_o_unknown_before_run.output.contains('--an-unknown-option') |
| 33 | + assert !os.exists(tfile) |
| 34 | + |
| 35 | + res_run_no_o := os.execute('${os.quoted_path(@VEXE)} run examples/hello_world.v --an-unknown-option') |
| 36 | + assert res_run_no_o.exit_code == 0 |
| 37 | + assert res_run_no_o.output.trim_space() == 'Hello, World!' |
| 38 | + assert !os.exists(tfile) |
| 39 | +} |
0 commit comments