diff --git a/vlib/v/checker/tests/inout/void_fn_as_value.out b/vlib/v/checker/tests/inout/void_fn_as_value.out index 32b6cd2f7f..88ff9daff4 100644 --- a/vlib/v/checker/tests/inout/void_fn_as_value.out +++ b/vlib/v/checker/tests/inout/void_fn_as_value.out @@ -1,7 +1,7 @@ -vlib/v/checker/tests/inout/void_fn_as_value.v:5:8: error: unknown fn: x +vlib/v/checker/tests/inout/void_fn_as_value.v:5:8: error: unknown funciton: x 3| fn main() { 4| mut a := 'aa' 5| a += x('a','b') ~~~~~~~~~~ 6| mut b := 'abcdef' - 7| } \ No newline at end of file + 7| } diff --git a/vlib/v/gen/x64/tests/hello.vv b/vlib/v/gen/x64/tests/hello.vv new file mode 100644 index 0000000000..606fe42ec0 --- /dev/null +++ b/vlib/v/gen/x64/tests/hello.vv @@ -0,0 +1,3 @@ +fn main() { + println('hello from x64') +} diff --git a/vlib/v/gen/x64/tests/hello.vv.out b/vlib/v/gen/x64/tests/hello.vv.out new file mode 100644 index 0000000000..985a7456fb --- /dev/null +++ b/vlib/v/gen/x64/tests/hello.vv.out @@ -0,0 +1 @@ +hello from x64 diff --git a/vlib/v/gen/x64/tests/x64_test.v b/vlib/v/gen/x64/tests/x64_test.v new file mode 100644 index 0000000000..653523bf27 --- /dev/null +++ b/vlib/v/gen/x64/tests/x64_test.v @@ -0,0 +1,74 @@ +import os +import benchmark +import term + +// TODO some logic copy pasted from valgrind_test.v and compiler_test.v, move to a module +fn test_x64() { + if false && os.user_os() != 'linux' { + eprintln('x64 tests can only be run on Linux for now.') + exit(0) + } + var bench := benchmark.new_benchmark() + vexe := os.getenv('VEXE') + vroot := os.dir(vexe) + dir := os.join_path(vroot, 'vlib/v/gen/x64/tests') + files := os.ls(dir) or { + panic(err) + } + // + wrkdir := os.join_path(os.temp_dir(), 'vtests', 'x64') + os.mkdir_all(wrkdir) + os.chdir(wrkdir) + tests := files.filter(it.ends_with('.vv')) + if tests.len == 0 { + println('no x64 tests found') + assert false + } + bench.set_total_expected_steps(tests.len) + for test in tests { + bench.step() + full_test_path := os.real_path(test) + println('x.v: $wrkdir/x.v') + os.system('cp ${dir}/${test} $wrkdir/x.v') // cant run .vv file + x := os.exec('$vexe -o exe -x64 $wrkdir/x.v') or { + bench.fail() + eprintln(bench.step_message_fail('x64 $test failed')) + continue + } + res := os.exec('./exe') or { + bench.fail() + continue + } + if res.exit_code != 0 { + bench.fail() + eprintln(bench.step_message_fail('$full_test_path failed to run')) + eprintln(res.output) + continue + } + var expected := os.read_file('$dir/${test}.out') or { + panic(err) + } + expected = expected.trim_space().trim('\n').replace('\r\n', '\n') + found := res.output.trim_space().trim('\n').replace('\r\n', '\n') + if expected != found { + println(term.red('FAIL')) + println('============') + println('expected:') + println(expected) + println('============') + println('found:') + println(found) + println('============\n') + bench.fail() + continue + } + bench.ok() + eprintln(bench.step_message_ok('testing file: $test')) + } + bench.stop() + eprintln(term.h_divider('-')) + eprintln(bench.total_message('x64')) + if bench.nfail > 0 { + exit(1) + } +}