2020-12-15 19:22:07 +03:00
|
|
|
module main
|
|
|
|
|
|
|
|
import os
|
|
|
|
import dl
|
|
|
|
|
|
|
|
const (
|
|
|
|
vexe = os.real_path(os.getenv('VEXE'))
|
|
|
|
cfolder = os.dir(@FILE)
|
|
|
|
so_ext = dl.dl_ext
|
2021-02-23 10:46:28 +03:00
|
|
|
library_file_name = os.join_path(cfolder, dl.get_libname('library'))
|
2020-12-15 19:22:07 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
fn test_vexe() {
|
2021-03-08 19:21:43 +03:00
|
|
|
dump(vexe)
|
2020-12-15 19:22:07 +03:00
|
|
|
assert vexe != ''
|
2021-03-08 19:21:43 +03:00
|
|
|
dump(os.executable())
|
|
|
|
dump(@FILE)
|
|
|
|
dump(cfolder)
|
|
|
|
dump(so_ext)
|
|
|
|
dump(library_file_name)
|
2020-12-15 19:22:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_can_compile_library() {
|
|
|
|
os.chdir(cfolder)
|
2021-01-26 17:43:10 +03:00
|
|
|
os.rm(library_file_name) or { }
|
2021-03-08 19:21:43 +03:00
|
|
|
res := v_compile('-d no_backtrace -o library -shared modules/library/library.v')
|
|
|
|
dump(res)
|
2020-12-15 19:22:07 +03:00
|
|
|
assert os.is_file(library_file_name)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_can_compile_main_program() {
|
|
|
|
os.chdir(cfolder)
|
|
|
|
assert os.is_file(library_file_name)
|
|
|
|
result := v_compile('run use.v')
|
2021-03-08 19:21:43 +03:00
|
|
|
dump(result)
|
2020-12-15 19:22:07 +03:00
|
|
|
assert result.output.contains('res: 4')
|
2021-01-26 17:43:10 +03:00
|
|
|
os.rm(library_file_name) or { }
|
2020-12-15 19:22:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn v_compile(vopts string) os.Result {
|
|
|
|
cmd := '"$vexe" -showcc $vopts'
|
2021-03-08 19:21:43 +03:00
|
|
|
dump(cmd)
|
2021-03-01 02:18:14 +03:00
|
|
|
res := os.exec(cmd) or { panic(err) }
|
2021-03-08 19:21:43 +03:00
|
|
|
dump(res)
|
2020-12-15 19:22:07 +03:00
|
|
|
// assert res.exit_code == 0
|
|
|
|
$if !windows {
|
2021-01-20 08:04:59 +03:00
|
|
|
os.system('ls -al $cfolder')
|
2020-12-15 19:22:07 +03:00
|
|
|
} $else {
|
|
|
|
os.system('dir $cfolder /a')
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|