1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tests: fix the new v2 output tests

This commit is contained in:
Alexander Medvednikov 2020-03-23 20:30:16 +01:00
parent 67ba56c65c
commit ae2d001261
5 changed files with 30 additions and 14 deletions

View File

@ -2,24 +2,30 @@ import os
import term
fn test_all() {
files := os.ls('.') or {
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
dir := os.join_path(vroot,'vlib/v/tests')
files := os.ls(dir) or {
panic(err)
}
for file in files {
if !file.ends_with('.vv') {
continue
}
print(file + ' ')
program := file.replace('.vv', '.v')
os.cp(file, program) or {
println(files)
tests := files.filter(it.ends_with('.vv'))
if tests.len == 0 {
println('no compiler tests found')
assert false
}
for test in tests {
path := os.join_path(dir,test)
print(test + ' ')
program := path.replace('.vv', '.v')
os.cp(path, program) or {
panic(err)
}
os.rm('exe')
x := os.exec('v -o exe -cflags "-w" -cg -backend experimental $program') or {
panic(err)
}
println(x.output.limit(30))
os.rm(program)
// os.rm(program)
res := os.exec('./exe') or {
println('nope')
panic(err)
@ -34,6 +40,7 @@ fn test_all() {
found := res.output.trim_space()
if expected != found {
println(term.red('FAIL'))
println(x.output.limit(30))
println('============')
println('expected:')
println(expected)

View File

@ -1,3 +1,5 @@
import os
fn main() {
println('hello world')
}

View File

@ -1,3 +1,5 @@
import os
fn main() {
areas := ['game', 'web', 'tools', 'science', 'systems', 'embedded']
for i :=0;i<areas.len; i++{

View File

@ -1 +1,4 @@
compiler_test.v
CODE_OF_CONDUCT.md
CHANGELOG.md
README.md
CONTRIBUTING.md

View File

@ -1,10 +1,12 @@
import os
fn main() {
files := os.ls('.') or { panic(err) }
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
files := os.ls(vroot) or { panic(err) }
for file in files {
if file.ends_with('_test.v') {
if file.ends_with('.md') {
println(file)
}
}
}
}