2019-12-14 15:57:28 +03:00
|
|
|
module main
|
|
|
|
|
2019-08-18 18:21:48 +03:00
|
|
|
import os
|
2019-09-15 18:08:16 +03:00
|
|
|
import compiler.tests.repl.runner
|
2019-09-16 17:29:06 +03:00
|
|
|
import benchmark
|
2019-08-26 13:51:48 +03:00
|
|
|
|
|
|
|
fn test_the_v_compiler_can_be_invoked() {
|
2019-11-09 19:35:26 +03:00
|
|
|
vexec := runner.full_path_to_v(5)
|
2019-08-26 13:51:48 +03:00
|
|
|
println('vexecutable: $vexec')
|
|
|
|
assert vexec != ''
|
|
|
|
|
2019-10-16 02:49:51 +03:00
|
|
|
vcmd := '"$vexec" --version'
|
2019-08-26 13:51:48 +03:00
|
|
|
r := os.exec(vcmd) or { panic(err) }
|
|
|
|
//println('"$vcmd" exit_code: $r.exit_code | output: $r.output')
|
|
|
|
assert r.exit_code == 0
|
|
|
|
|
2019-10-16 02:49:51 +03:00
|
|
|
vcmd_error := '"$vexec" nonexisting.v'
|
2019-08-26 13:51:48 +03: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'
|
|
|
|
}
|
|
|
|
|
2019-09-15 18:08:16 +03:00
|
|
|
fn test_all_v_repl_files() {
|
|
|
|
options := runner.new_options()
|
2019-09-16 17:29:06 +03:00
|
|
|
mut bmark := benchmark.new_benchmark()
|
2019-09-15 18:08:16 +03:00
|
|
|
for file in options.files {
|
2019-09-16 17:29:06 +03:00
|
|
|
bmark.step()
|
2019-09-15 18:08:16 +03:00
|
|
|
fres := runner.run_repl_file(options.wd, options.vexec, file) or {
|
2019-09-16 17:29:06 +03:00
|
|
|
bmark.fail()
|
|
|
|
eprintln( bmark.step_message(err) )
|
2019-08-26 13:51:48 +03:00
|
|
|
assert false
|
2019-09-15 18:08:16 +03:00
|
|
|
continue
|
2019-08-26 13:51:48 +03:00
|
|
|
}
|
2019-09-16 17:29:06 +03:00
|
|
|
bmark.ok()
|
|
|
|
println( bmark.step_message(fres) )
|
2019-09-15 18:08:16 +03:00
|
|
|
assert true
|
2019-08-26 13:51:48 +03:00
|
|
|
}
|
2019-09-16 17:29:06 +03:00
|
|
|
bmark.stop()
|
|
|
|
println( bmark.total_message('total time spent running REPL files') )
|
2019-08-22 14:15:11 +03:00
|
|
|
}
|
2019-09-15 18:08:16 +03:00
|
|
|
|