tests: detect missing -o v.c files earlier

pull/10791/head
Delyan Angelov 2021-07-13 22:24:38 +03:00
parent 24f5d0afc4
commit 5322a25690
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 19 additions and 3 deletions

View File

@ -57,6 +57,11 @@ fn get_all_commands() []Command {
okmsg: 'V can compile hello world.'
rmfile: 'examples/hello_world'
}
res << Command{
line: '$vexe -o hhww.c examples/hello_world.v'
okmsg: 'V can output a .c file, without compiling further.'
rmfile: 'hhww.c'
}
res << Command{
line: '$vexe -o vtmp cmd/v'
okmsg: 'V can compile itself.'
@ -126,7 +131,7 @@ fn get_all_commands() []Command {
okmsg: '`v -usecache` works.'
rmfile: 'examples/tetris/tetris'
}
$if macos {
$if macos || linux {
res << Command{
line: '$vexe -o v.c cmd/v && cc -Werror v.c && rm -rf a.out'
label: 'v.c should be buildable with no warnings...'
@ -152,13 +157,24 @@ fn (mut cmd Command) run() {
return
}
if cmd.rmfile != '' {
os.rm(cmd.rmfile) or {}
mut file_existed := rm_existing(cmd.rmfile)
if os.user_os() == 'windows' {
os.rm(cmd.rmfile + '.exe') or {}
file_existed = file_existed || rm_existing(cmd.rmfile + '.exe')
}
if !file_existed {
eprintln('Expected file did not exist: $cmd.rmfile')
cmd.ecode = 999
}
}
}
// try to remove a file, return if it existed before the removal attempt
fn rm_existing(path string) bool {
existed := os.exists(path)
os.rm(path) or {}
return existed
}
fn term_highlight(s string) string {
return term.colorize(term.yellow, term.colorize(term.bold, s))
}