ci: move the test cases in unknown_options_test.v to pref_test.v, to minimise false positives (both compiled and ran examples/hello_world.v in parallel)

This commit is contained in:
Delyan Angelov 2024-06-10 14:06:41 +03:00
parent 65503edb4e
commit 53ac41ff06
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 38 additions and 39 deletions

View File

@ -63,3 +63,41 @@ fn test_v_cmds_and_flags() {
no_bm_files_res := os.execute('${vexe} build-module')
assert no_bm_files_res.output.trim_space() == 'v build-module: no module specified'
}
const tfile = os.join_path(os.vtmp_dir(), 'unknown_options_output.c')
fn test_unknown_option_flags_no_run() {
os.chdir(os.dir(@VEXE))!
os.rm(tfile) or {}
res1 := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(tfile)} examples/hello_world.v --an-unknown-option')
assert res1.exit_code == 1, res1.output
assert res1.output.starts_with('Unknown argument')
assert res1.output.contains('--an-unknown-option')
assert !os.exists(tfile)
res2 := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(tfile)} --an-unknown-option examples/hello_world.v')
assert res2.exit_code == 1, res2.output
assert res2.output.starts_with('Unknown argument')
assert res2.output.contains('--an-unknown-option')
assert !os.exists(tfile)
}
fn test_unknown_option_flags_with_run() {
res_run_o := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(tfile)} run examples/hello_world.v --an-unknown-option')
assert res_run_o.exit_code == 0, res_run_o.output
assert res_run_o.output == '' // because of -o, there should not be an actual run, since compilation stopped after generating the .c file
assert os.exists(tfile)
os.rm(tfile) or {}
res_run_no_o_unknown_before_run := os.execute('${os.quoted_path(@VEXE)} --an-unknown-option run examples/hello_world.v ')
assert res_run_no_o_unknown_before_run.exit_code == 1, res_run_no_o_unknown_before_run.output
assert res_run_no_o_unknown_before_run.output.starts_with('Unknown argument')
assert res_run_no_o_unknown_before_run.output.contains('--an-unknown-option')
assert !os.exists(tfile)
res_run_no_o := os.execute('${os.quoted_path(@VEXE)} run examples/hello_world.v --an-unknown-option')
assert res_run_no_o.exit_code == 0, res_run_no_o.output
assert res_run_no_o.output.trim_space() == 'Hello, World!'
assert !os.exists(tfile)
}

View File

@ -1,39 +0,0 @@
import os
const tfile = os.join_path(os.vtmp_dir(), 'unknown_options_output.c')
fn test_unknown_option_flags_no_run() {
os.chdir(os.dir(@VEXE))!
os.rm(tfile) or {}
res1 := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(tfile)} examples/hello_world.v --an-unknown-option')
assert res1.exit_code == 1, res1.output
assert res1.output.starts_with('Unknown argument')
assert res1.output.contains('--an-unknown-option')
assert !os.exists(tfile)
res2 := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(tfile)} --an-unknown-option examples/hello_world.v')
assert res2.exit_code == 1, res2.output
assert res2.output.starts_with('Unknown argument')
assert res2.output.contains('--an-unknown-option')
assert !os.exists(tfile)
}
fn test_unknown_option_flags_with_run() {
res_run_o := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(tfile)} run examples/hello_world.v --an-unknown-option')
assert res_run_o.exit_code == 0, res_run_o.output
assert res_run_o.output == '' // because of -o, there should not be an actual run, since compilation stopped after generating the .c file
assert os.exists(tfile)
os.rm(tfile) or {}
res_run_no_o_unknown_before_run := os.execute('${os.quoted_path(@VEXE)} --an-unknown-option run examples/hello_world.v ')
assert res_run_no_o_unknown_before_run.exit_code == 1, res_run_no_o_unknown_before_run.output
assert res_run_no_o_unknown_before_run.output.starts_with('Unknown argument')
assert res_run_no_o_unknown_before_run.output.contains('--an-unknown-option')
assert !os.exists(tfile)
res_run_no_o := os.execute('${os.quoted_path(@VEXE)} run examples/hello_world.v --an-unknown-option')
assert res_run_no_o.exit_code == 0, res_run_no_o.output
assert res_run_no_o.output.trim_space() == 'Hello, World!'
assert !os.exists(tfile)
}