tools: cleanup generated executables by `v test-all`

pull/10468/head
Delyan Angelov 2021-06-15 14:22:18 +03:00
parent 48b3ab831b
commit af60eba5e6
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 29 additions and 6 deletions

2
.gitignore vendored
View File

@ -23,6 +23,8 @@ a.out
/v.c
/v.*.c
/v.c.out
/v_old
/v_old.exe
.vrepl_temp.v
fns.txt
.noprefix.vrepl_temp.v

View File

@ -4,12 +4,15 @@ import os
import term
import time
const (
vexe = os.getenv('VEXE')
vroot = os.dir(vexe)
args_string = os.args[1..].join(' ')
vargs = args_string.all_before('test-all')
)
const vexe = os.getenv('VEXE')
const vroot = os.dir(vexe)
const args_string = os.args[1..].join(' ')
const vargs = args_string.all_before('test-all')
const vtest_nocleanup = os.getenv('VTEST_NOCLEANUP').bool()
fn main() {
mut commands := get_all_commands()
@ -44,6 +47,7 @@ mut:
ecode int
okmsg string
errmsg string
rmfile string
}
fn get_all_commands() []Command {
@ -51,26 +55,32 @@ fn get_all_commands() []Command {
res << Command{
line: '$vexe examples/hello_world.v'
okmsg: 'V can compile hello world.'
rmfile: 'examples/hello_world'
}
res << Command{
line: '$vexe -o vtmp cmd/v'
okmsg: 'V can compile itself.'
rmfile: 'vtmp'
}
res << Command{
line: '$vexe -o vtmp_werror -cstrict cmd/v'
okmsg: 'V can compile itself with -cstrict.'
rmfile: 'vtmp_werror'
}
res << Command{
line: '$vexe -o vtmp_autofree -autofree cmd/v'
okmsg: 'V can compile itself with -autofree.'
rmfile: 'vtmp_autofree'
}
res << Command{
line: '$vexe -o vtmp_prealloc -prealloc cmd/v'
okmsg: 'V can compile itself with -prealloc.'
rmfile: 'vtmp_prealloc'
}
res << Command{
line: '$vexe -o vtmp_unused -skip-unused cmd/v'
okmsg: 'V can compile itself with -skip-unused.'
rmfile: 'vtmp_unused'
}
res << Command{
line: '$vexe $vargs -progress test-cleancode'
@ -107,12 +117,14 @@ fn get_all_commands() []Command {
res << Command{
line: '$vexe -usecache examples/tetris/tetris.v'
okmsg: '`v -usecache` works.'
rmfile: 'examples/tetris/tetris'
}
$if macos {
res << Command{
line: '$vexe -o v.c cmd/v && cc -Werror v.c && rm -rf v.c'
label: 'v.c should be buildable with no warnings...'
okmsg: 'v.c can be compiled without warnings. This is good :)'
rmfile: 'v.c'
}
}
return res
@ -129,6 +141,15 @@ fn (mut cmd Command) run() {
cmd.ecode = os.system(cmd.line)
spent := sw.elapsed().milliseconds()
println(term_highlight('> Running: "$cmd.line" took: $spent ms.'))
if vtest_nocleanup {
return
}
if cmd.rmfile != '' {
os.rm(cmd.rmfile) or {}
if os.user_os() == 'windows' {
os.rm(cmd.rmfile + '.exe') or {}
}
}
}
fn term_highlight(s string) string {