checker_test: remove generated .v files, when a test is OK

pull/4644/head
Delyan Angelov 2020-04-29 11:48:51 +03:00
parent 117649f40d
commit dd3434598c
6 changed files with 10 additions and 32 deletions

View File

@ -1,10 +1,15 @@
import os import os
import term import term
fn clean_line_endings(s string) string {
return s.trim_space().replace(' \n', '\n').replace(' \r\n', '\n').replace('\r\n', '\n').trim('\n')
}
fn test_all() { fn test_all() {
mut total_errors := 0 mut total_errors := 0
vexe := os.getenv('VEXE') vexe := os.getenv('VEXE')
// vroot := os.dir(vexe) vroot := os.dir(vexe)
os.chdir(vroot)
dir := 'vlib/v/checker/tests' dir := 'vlib/v/checker/tests'
files := os.ls(dir) or { files := os.ls(dir) or {
panic(err) panic(err)
@ -16,8 +21,8 @@ fn test_all() {
} }
for test in tests { for test in tests {
path := os.join_path(dir, test).replace('\\', '/') path := os.join_path(dir, test).replace('\\', '/')
print(test + ' ')
program := path.replace('.vv', '.v') program := path.replace('.vv', '.v')
print(program + ' ')
os.cp(path, program) or { os.cp(path, program) or {
panic(err) panic(err)
} }
@ -28,10 +33,8 @@ fn test_all() {
mut expected := os.read_file(program.replace('.v', '') + '.out') or { mut expected := os.read_file(program.replace('.v', '') + '.out') or {
panic(err) panic(err)
} }
expected = expected.trim_space().replace(' \n', '\n').replace(' \r\n', '\n').replace('\r\n', expected = clean_line_endings(expected)
'\n').trim('\n') found := clean_line_endings(res.output)
found := res.output.trim_space().replace(' \n', '\n').replace(' \r\n', '\n').replace('\r\n',
'\n').trim('\n')
if expected != found { if expected != found {
println(term.red('FAIL')) println(term.red('FAIL'))
println('============') println('============')
@ -44,6 +47,7 @@ fn test_all() {
total_errors++ total_errors++
} else { } else {
println(term.green('OK')) println(term.green('OK'))
os.rm( program )
} }
} }
assert total_errors == 0 assert total_errors == 0

View File

@ -1,7 +0,0 @@
fn foo(foo int) {
foo(foo + 1)
}
fn main() {
foo(5)
}

View File

@ -1,8 +0,0 @@
fn foo() {
foo := 1
foo(foo)
}
fn main() {
foo()
}

View File

@ -1,3 +0,0 @@
fn main() {
println(1.0/0.0)
}

View File

@ -1,3 +0,0 @@
fn main() {
println(1/0)
}

View File

@ -1,5 +0,0 @@
struct A {
a int
a string
}
fn main(){}