From ae2d00126117d0b40628909d75c827a7743ae0c0 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 23 Mar 2020 20:30:16 +0100 Subject: [PATCH] tests: fix the new v2 output tests --- vlib/v/tests/compiler_test.v | 27 +++++++++++++++++---------- vlib/v/tests/hello.vv | 2 ++ vlib/v/tests/hello_devs.vv | 2 ++ vlib/v/tests/os.out | 5 ++++- vlib/v/tests/os.vv | 8 +++++--- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/vlib/v/tests/compiler_test.v b/vlib/v/tests/compiler_test.v index d8545b7437..6b8444134f 100644 --- a/vlib/v/tests/compiler_test.v +++ b/vlib/v/tests/compiler_test.v @@ -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) diff --git a/vlib/v/tests/hello.vv b/vlib/v/tests/hello.vv index 24c0d2aa24..e8597eaa0e 100644 --- a/vlib/v/tests/hello.vv +++ b/vlib/v/tests/hello.vv @@ -1,3 +1,5 @@ +import os + fn main() { println('hello world') } diff --git a/vlib/v/tests/hello_devs.vv b/vlib/v/tests/hello_devs.vv index 5ae559e979..683993db18 100644 --- a/vlib/v/tests/hello_devs.vv +++ b/vlib/v/tests/hello_devs.vv @@ -1,3 +1,5 @@ +import os + fn main() { areas := ['game', 'web', 'tools', 'science', 'systems', 'embedded'] for i :=0;i