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