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-04-12 09:24:07 +03:00
|
|
|
// dump(vexe)
|
2020-12-15 19:22:07 +03:00
|
|
|
assert vexe != ''
|
2021-04-12 09:24:07 +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-04-12 09:24:07 +03:00
|
|
|
os.rm(library_file_name) or {}
|
|
|
|
v_compile('-d no_backtrace -o library -shared modules/library/library.v')
|
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-04-12 09:24:07 +03:00
|
|
|
// dump(result)
|
2020-12-15 19:22:07 +03:00
|
|
|
assert result.output.contains('res: 4')
|
2021-04-12 09:24:07 +03:00
|
|
|
os.rm(library_file_name) or {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_can_compile_and_use_library_with_skip_unused() {
|
|
|
|
os.chdir(cfolder)
|
|
|
|
os.rm(library_file_name) or {}
|
|
|
|
v_compile('-skip-unused -d no_backtrace -o library -shared modules/library/library.v')
|
|
|
|
assert os.is_file(library_file_name)
|
|
|
|
result := v_compile('run use.v')
|
|
|
|
assert result.output.contains('res: 4')
|
|
|
|
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-04-12 09:24:07 +03:00
|
|
|
// dump(cmd)
|
2021-03-08 21:52:13 +03:00
|
|
|
res := os.execute_or_panic(cmd)
|
2021-04-12 09:24:07 +03:00
|
|
|
// dump(res)
|
|
|
|
assert res.exit_code == 0
|
2020-12-15 19:22:07 +03:00
|
|
|
return res
|
|
|
|
}
|