v/vlib/compiler/tests/repl/repl_test.v

44 lines
1.1 KiB
V
Raw Normal View History

module main
2019-08-18 17:21:48 +02:00
import os
import compiler.tests.repl.runner
import benchmark
fn test_the_v_compiler_can_be_invoked() {
vexec := runner.full_path_to_v(5)
println('vexecutable: $vexec')
assert vexec != ''
vcmd := '"$vexec" --version'
2019-12-30 05:23:54 +01:00
r := os.exec(vcmd) or {
panic(err)
}
// println('"$vcmd" exit_code: $r.exit_code | output: $r.output')
assert r.exit_code == 0
vcmd_error := '"$vexec" nonexisting.v'
2019-12-30 05:23:54 +01:00
r_error := os.exec(vcmd_error) or {
panic(err)
}
// println('"$vcmd_error" exit_code: $r_error.exit_code | output: $r_error.output')
assert r_error.exit_code == 1
assert r_error.output == '`nonexisting.v` does not exist'
}
fn test_all_v_repl_files() {
options := runner.new_options()
mut bmark := benchmark.new_benchmark()
for file in options.files {
bmark.step()
fres := runner.run_repl_file(options.wd, options.vexec, file) or {
bmark.fail()
2019-12-30 05:23:54 +01:00
eprintln(bmark.step_message_fail(err))
assert false
continue
}
bmark.ok()
2019-12-30 05:23:54 +01:00
println(bmark.step_message_ok(fres))
assert true
}
bmark.stop()
2019-12-30 05:23:54 +01:00
println(bmark.total_message('total time spent running REPL files'))
}