2019-12-01 12:50:13 +03:00
|
|
|
module main
|
|
|
|
|
2020-04-26 09:32:05 +03:00
|
|
|
import os
|
|
|
|
import testing
|
|
|
|
import benchmark
|
|
|
|
import v.pref
|
2019-12-01 12:50:13 +03:00
|
|
|
|
|
|
|
fn main() {
|
2020-12-20 20:01:02 +03:00
|
|
|
args_string := os.args[1..].join(' ')
|
2019-12-01 12:50:13 +03:00
|
|
|
v_test_compiler(args_string.all_before('test-compiler'))
|
|
|
|
}
|
|
|
|
|
2019-12-25 15:54:48 +03:00
|
|
|
fn v_test_compiler(vargs string) {
|
2020-02-20 13:33:01 +03:00
|
|
|
vexe := pref.vexe_path()
|
2020-03-08 00:26:26 +03:00
|
|
|
parent_dir := os.dir(vexe)
|
2019-12-25 15:54:48 +03:00
|
|
|
testing.vlib_should_be_present(parent_dir)
|
2019-12-01 12:50:13 +03:00
|
|
|
// Changing the current directory is needed for some of the compiler tests,
|
2020-05-22 10:11:12 +03:00
|
|
|
// vlib/v/tests/local_test.v and vlib/v/tests/repl/repl_test.v
|
2019-12-25 15:54:48 +03:00
|
|
|
os.chdir(parent_dir)
|
2019-12-01 12:50:13 +03:00
|
|
|
/*
|
2019-12-04 23:03:12 +03:00
|
|
|
if !os.exists(parent_dir + '/v.v') {
|
2019-12-01 16:12:51 +03:00
|
|
|
eprintln('v.v is missing, it must be next to the V executable')
|
2019-12-01 12:50:13 +03:00
|
|
|
exit(1)
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
// Make sure v.c can be compiled without warnings
|
2019-12-05 14:22:54 +03:00
|
|
|
$if macos {
|
2020-02-09 12:08:04 +03:00
|
|
|
if os.exists('/cmd/v') {
|
|
|
|
os.system('$vexe -o v.c cmd/v')
|
2019-12-01 12:50:13 +03:00
|
|
|
if os.system('cc -Werror v.c') != 0 {
|
2019-12-01 16:12:51 +03:00
|
|
|
eprintln('cc failed to build v.c without warnings')
|
2019-12-01 12:50:13 +03:00
|
|
|
exit(1)
|
|
|
|
}
|
2019-12-01 16:12:51 +03:00
|
|
|
eprintln('v.c can be compiled without warnings. This is good :)')
|
2019-12-01 12:50:13 +03:00
|
|
|
}
|
|
|
|
}
|
2021-01-08 13:25:22 +03:00
|
|
|
building_tools_failed := os.system('"$vexe" build-tools') != 0
|
2020-02-08 19:01:10 +03:00
|
|
|
eprintln('')
|
|
|
|
testing.eheader('Testing all _test.v files...')
|
2019-12-25 15:54:48 +03:00
|
|
|
mut compiler_test_session := testing.new_test_session(vargs)
|
2019-12-01 12:50:13 +03:00
|
|
|
compiler_test_session.files << os.walk_ext(parent_dir, '_test.v')
|
|
|
|
compiler_test_session.test()
|
2019-12-25 15:54:48 +03:00
|
|
|
eprintln(compiler_test_session.benchmark.total_message('running V tests'))
|
2019-12-01 16:12:51 +03:00
|
|
|
eprintln('')
|
2019-12-01 12:50:13 +03:00
|
|
|
building_examples_failed := testing.v_build_failing(vargs, 'examples')
|
2019-12-05 14:22:54 +03:00
|
|
|
eprintln('')
|
2020-10-14 18:20:19 +03:00
|
|
|
building_live_failed := testing.v_build_failing(vargs + '-live', os.join_path('examples',
|
|
|
|
'hot_reload'))
|
2019-12-01 16:12:51 +03:00
|
|
|
eprintln('')
|
2020-10-14 18:20:19 +03:00
|
|
|
//
|
|
|
|
testing.setup_new_vtmp_folder()
|
2019-12-01 12:50:13 +03:00
|
|
|
v_module_install_cmd := '$vexe install nedpals.args'
|
2020-02-08 19:01:10 +03:00
|
|
|
eprintln('')
|
|
|
|
testing.eheader('Installing a v module with: $v_module_install_cmd')
|
2019-12-01 12:50:13 +03:00
|
|
|
mut vmark := benchmark.new_benchmark()
|
|
|
|
ret := os.system(v_module_install_cmd)
|
|
|
|
if ret != 0 {
|
2019-12-01 16:12:51 +03:00
|
|
|
eprintln('failed to run v install')
|
2019-12-01 12:50:13 +03:00
|
|
|
}
|
2020-10-14 18:20:19 +03:00
|
|
|
desired_path := os.join_path(pref.default_module_path, 'nedpals', 'args')
|
|
|
|
if !(os.exists(desired_path) && os.is_dir(desired_path)) {
|
2019-12-01 16:12:51 +03:00
|
|
|
eprintln('v failed to install a test module')
|
2019-12-01 12:50:13 +03:00
|
|
|
}
|
|
|
|
vmark.stop()
|
2019-12-25 15:54:48 +03:00
|
|
|
eprintln('Installing a v module took: ' + vmark.total_duration().str() + 'ms')
|
2020-10-14 18:20:19 +03:00
|
|
|
//
|
2019-12-25 15:54:48 +03:00
|
|
|
if building_tools_failed || compiler_test_session.failed || building_examples_failed || building_live_failed {
|
2019-12-01 12:50:13 +03:00
|
|
|
exit(1)
|
|
|
|
}
|
2019-12-22 02:22:32 +03:00
|
|
|
}
|