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

View File

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

View File

@ -1,3 +1,5 @@
import os
fn main() { fn main() {
areas := ['game', 'web', 'tools', 'science', 'systems', 'embedded'] areas := ['game', 'web', 'tools', 'science', 'systems', 'embedded']
for i :=0;i<areas.len; i++{ 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 import os
fn main() { 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 { for file in files {
if file.ends_with('_test.v') { if file.ends_with('.md') {
println(file) println(file)
} }
} }
} }