2020-04-05 11:40:17 +02:00
|
|
|
module main
|
|
|
|
|
|
|
|
import os
|
|
|
|
import testing
|
2020-04-07 19:51:23 +02:00
|
|
|
import v.pref
|
2020-04-05 11:40:17 +02:00
|
|
|
|
2021-06-14 12:10:20 +02:00
|
|
|
const github_job = os.getenv('GITHUB_JOB')
|
|
|
|
|
2020-04-05 11:40:17 +02:00
|
|
|
const (
|
2021-04-15 08:28:33 +02:00
|
|
|
skip_test_files = [
|
|
|
|
'vlib/context/deadline_test.v' /* sometimes blocks */,
|
2021-07-23 11:33:55 +02:00
|
|
|
'vlib/mysql/mysql_orm_test.v' /* mysql not installed */,
|
2021-07-24 19:49:40 +02:00
|
|
|
'vlib/pg/pg_orm_test.v' /* pg not installed */,
|
2021-04-15 08:28:33 +02:00
|
|
|
]
|
2021-05-29 11:15:10 +02:00
|
|
|
skip_fsanitize_too_slow = [
|
|
|
|
// These tests are too slow to be run in the CI on each PR/commit
|
|
|
|
// in the sanitized modes:
|
|
|
|
'vlib/v/compiler_errors_test.v',
|
|
|
|
'vlib/v/doc/doc_test.v',
|
|
|
|
'vlib/v/fmt/fmt_test.v',
|
|
|
|
'vlib/v/fmt/fmt_keep_test.v',
|
|
|
|
'vlib/v/fmt/fmt_vlib_test.v',
|
|
|
|
'vlib/v/live/live_test.v',
|
|
|
|
'vlib/v/parser/v_parser_test.v',
|
|
|
|
'vlib/v/scanner/scanner_test.v',
|
|
|
|
'vlib/v/tests/inout/compiler_test.v',
|
|
|
|
'vlib/v/tests/prod_test.v',
|
|
|
|
'vlib/v/tests/profile/profile_test.v',
|
|
|
|
'vlib/v/tests/repl/repl_test.v',
|
|
|
|
'vlib/v/tests/valgrind/valgrind_test.v',
|
|
|
|
]
|
2020-12-29 19:27:57 +01:00
|
|
|
skip_with_fsanitize_memory = [
|
2020-12-29 06:46:54 +01:00
|
|
|
'vlib/net/tcp_simple_client_server_test.v',
|
|
|
|
'vlib/net/http/cookie_test.v',
|
|
|
|
'vlib/net/http/http_test.v',
|
|
|
|
'vlib/net/http/status_test.v',
|
2021-02-07 23:10:01 +01:00
|
|
|
'vlib/net/http/http_httpbin_test.v',
|
2021-02-27 22:54:27 +01:00
|
|
|
'vlib/net/http/header_test.v',
|
2021-08-19 10:19:49 +02:00
|
|
|
'vlib/net/http/server_test.v',
|
2021-02-07 23:10:01 +01:00
|
|
|
'vlib/net/udp_test.v',
|
|
|
|
'vlib/net/tcp_test.v',
|
2020-12-29 06:46:54 +01:00
|
|
|
'vlib/orm/orm_test.v',
|
|
|
|
'vlib/sqlite/sqlite_test.v',
|
2021-07-23 11:33:55 +02:00
|
|
|
'vlib/sqlite/sqlite_orm_test.v',
|
2021-02-04 20:28:33 +01:00
|
|
|
'vlib/v/tests/orm_sub_struct_test.v',
|
2021-05-04 11:35:18 +02:00
|
|
|
'vlib/v/tests/orm_sub_array_struct_test.v',
|
2021-02-07 23:10:01 +01:00
|
|
|
'vlib/vweb/tests/vweb_test.v',
|
2021-02-27 23:18:25 +01:00
|
|
|
'vlib/vweb/request_test.v',
|
2021-06-05 23:43:14 +02:00
|
|
|
'vlib/net/http/request_test.v',
|
2021-08-20 00:13:36 +02:00
|
|
|
'vlib/net/http/response_test.v',
|
2021-03-01 11:50:52 +01:00
|
|
|
'vlib/vweb/route_test.v',
|
2021-07-03 01:56:00 +02:00
|
|
|
'vlib/net/websocket/websocket_test.v',
|
2021-03-16 16:10:03 +01:00
|
|
|
'vlib/crypto/rand/crypto_rand_read_test.v',
|
2020-12-29 06:46:54 +01:00
|
|
|
]
|
2020-12-29 19:27:57 +01:00
|
|
|
skip_with_fsanitize_address = [
|
2021-07-03 01:56:00 +02:00
|
|
|
'vlib/net/websocket/websocket_test.v',
|
2021-02-07 23:10:01 +01:00
|
|
|
]
|
2021-04-15 08:28:33 +02:00
|
|
|
skip_with_fsanitize_undefined = [
|
|
|
|
'do_not_remove',
|
|
|
|
]
|
2021-02-07 23:10:01 +01:00
|
|
|
skip_with_werror = [
|
2021-07-20 18:34:16 +02:00
|
|
|
'do_not_remove',
|
2020-12-29 06:46:54 +01:00
|
|
|
]
|
2021-04-15 08:28:33 +02:00
|
|
|
skip_with_asan_compiler = [
|
|
|
|
'do_not_remove',
|
|
|
|
]
|
|
|
|
skip_with_msan_compiler = [
|
|
|
|
'do_not_remove',
|
|
|
|
]
|
2020-12-29 19:27:57 +01:00
|
|
|
skip_on_musl = [
|
2020-12-25 17:44:52 +01:00
|
|
|
'vlib/v/tests/profile/profile_test.v',
|
|
|
|
]
|
2020-12-29 19:27:57 +01:00
|
|
|
skip_on_ubuntu_musl = [
|
2021-03-01 13:54:49 +01:00
|
|
|
//'vlib/v/gen/js/jsgen_test.v',
|
2020-05-06 22:26:44 +02:00
|
|
|
'vlib/net/http/cookie_test.v',
|
2020-07-08 20:30:57 +02:00
|
|
|
'vlib/net/http/http_test.v',
|
2020-10-09 17:33:16 +02:00
|
|
|
'vlib/net/http/status_test.v',
|
2020-07-17 19:13:22 +02:00
|
|
|
'vlib/net/websocket/ws_test.v',
|
2020-06-07 17:51:28 +02:00
|
|
|
'vlib/sqlite/sqlite_test.v',
|
2021-07-23 11:33:55 +02:00
|
|
|
'vlib/sqlite/sqlite_orm_test.v',
|
2020-06-07 17:51:28 +02:00
|
|
|
'vlib/orm/orm_test.v',
|
2021-02-04 20:28:33 +01:00
|
|
|
'vlib/v/tests/orm_sub_struct_test.v',
|
2021-05-04 11:35:18 +02:00
|
|
|
'vlib/v/tests/orm_sub_array_struct_test.v',
|
2020-05-06 22:26:44 +02:00
|
|
|
'vlib/clipboard/clipboard_test.v',
|
2020-08-14 00:11:12 +02:00
|
|
|
'vlib/vweb/tests/vweb_test.v',
|
2021-02-27 23:18:25 +01:00
|
|
|
'vlib/vweb/request_test.v',
|
2021-06-05 23:43:14 +02:00
|
|
|
'vlib/net/http/request_test.v',
|
2021-03-01 11:50:52 +01:00
|
|
|
'vlib/vweb/route_test.v',
|
2021-07-03 01:56:00 +02:00
|
|
|
'vlib/net/websocket/websocket_test.v',
|
2021-01-05 11:40:48 +01:00
|
|
|
'vlib/net/http/http_httpbin_test.v',
|
2021-02-27 22:54:27 +01:00
|
|
|
'vlib/net/http/header_test.v',
|
2021-08-19 10:19:49 +02:00
|
|
|
'vlib/net/http/server_test.v',
|
2021-08-20 00:13:36 +02:00
|
|
|
'vlib/net/http/response_test.v',
|
2020-05-06 21:59:39 +02:00
|
|
|
]
|
2021-04-15 08:28:33 +02:00
|
|
|
skip_on_linux = [
|
|
|
|
'do_not_remove',
|
|
|
|
]
|
2020-12-29 19:27:57 +01:00
|
|
|
skip_on_non_linux = [
|
2021-04-15 08:28:33 +02:00
|
|
|
'do_not_remove',
|
2020-05-26 12:50:37 +02:00
|
|
|
]
|
2020-12-29 19:27:57 +01:00
|
|
|
skip_on_windows = [
|
2021-09-27 16:52:20 +02:00
|
|
|
'vlib/context/cancel_test.v',
|
|
|
|
'vlib/context/deadline_test.v',
|
|
|
|
'vlib/context/empty_test.v',
|
|
|
|
'vlib/context/value_test.v',
|
2020-06-07 17:51:28 +02:00
|
|
|
'vlib/orm/orm_test.v',
|
2021-02-04 20:28:33 +01:00
|
|
|
'vlib/v/tests/orm_sub_struct_test.v',
|
2021-08-10 20:27:15 +02:00
|
|
|
'vlib/v/tests/closure_test.v',
|
2020-06-09 15:06:07 +02:00
|
|
|
'vlib/net/websocket/ws_test.v',
|
2021-02-11 17:51:12 +01:00
|
|
|
'vlib/net/unix/unix_test.v',
|
2021-07-03 01:56:00 +02:00
|
|
|
'vlib/net/websocket/websocket_test.v',
|
2020-08-14 00:11:12 +02:00
|
|
|
'vlib/vweb/tests/vweb_test.v',
|
2021-02-27 23:18:25 +01:00
|
|
|
'vlib/vweb/request_test.v',
|
2021-06-05 23:43:14 +02:00
|
|
|
'vlib/net/http/request_test.v',
|
2021-03-01 11:50:52 +01:00
|
|
|
'vlib/vweb/route_test.v',
|
2020-06-07 17:51:28 +02:00
|
|
|
]
|
2021-04-15 08:28:33 +02:00
|
|
|
skip_on_non_windows = [
|
|
|
|
'do_not_remove',
|
|
|
|
]
|
|
|
|
skip_on_macos = [
|
|
|
|
'do_not_remove',
|
|
|
|
]
|
|
|
|
skip_on_non_macos = [
|
|
|
|
'do_not_remove',
|
|
|
|
]
|
2021-08-27 08:47:04 +02:00
|
|
|
skip_on_amd64 = [
|
|
|
|
'do_not_remove',
|
|
|
|
]
|
|
|
|
skip_on_non_amd64 = [
|
|
|
|
'vlib/v/tests/closure_test.v' /* not implemented yet */,
|
|
|
|
'do_not_remove',
|
|
|
|
]
|
2020-04-05 11:40:17 +02:00
|
|
|
)
|
|
|
|
|
2020-05-06 21:59:39 +02:00
|
|
|
// NB: musl misses openssl, thus the http tests can not be done there
|
|
|
|
// NB: http_httpbin_test.v: fails with 'cgen error: json: map_string_string is not struct'
|
2020-04-05 11:40:17 +02:00
|
|
|
fn main() {
|
2020-04-07 19:51:23 +02:00
|
|
|
vexe := pref.vexe_path()
|
|
|
|
vroot := os.dir(vexe)
|
2021-08-28 08:39:18 +02:00
|
|
|
os.chdir(vroot) or { panic(err) }
|
2020-12-20 15:33:55 +01:00
|
|
|
args := os.args.clone()
|
2020-04-05 11:40:17 +02:00
|
|
|
args_string := args[1..].join(' ')
|
2021-01-19 09:41:51 +01:00
|
|
|
cmd_prefix := args_string.all_before('test-self')
|
2021-03-16 17:46:11 +01:00
|
|
|
title := 'testing vlib'
|
2020-05-06 21:59:39 +02:00
|
|
|
all_test_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.v')
|
2020-04-05 11:40:17 +02:00
|
|
|
testing.eheader(title)
|
2021-05-08 12:32:29 +02:00
|
|
|
mut tsession := testing.new_test_session(cmd_prefix, true)
|
2021-06-02 21:13:53 +02:00
|
|
|
tsession.files << all_test_files.filter(!it.contains('testdata' + os.path_separator))
|
2020-04-07 19:51:23 +02:00
|
|
|
tsession.skip_files << skip_test_files
|
2021-06-14 12:10:20 +02:00
|
|
|
|
|
|
|
if github_job == 'windows-tcc' {
|
|
|
|
// TODO: fix these ASAP
|
|
|
|
tsession.skip_files << 'vlib/net/tcp_test.v'
|
|
|
|
tsession.skip_files << 'vlib/net/udp_test.v'
|
|
|
|
}
|
|
|
|
|
2021-02-07 23:10:01 +01:00
|
|
|
mut werror := false
|
2020-12-29 06:46:54 +01:00
|
|
|
mut sanitize_memory := false
|
|
|
|
mut sanitize_address := false
|
|
|
|
mut sanitize_undefined := false
|
2021-02-21 15:09:19 +01:00
|
|
|
mut asan_compiler := false
|
2021-03-22 23:05:48 +01:00
|
|
|
mut msan_compiler := false
|
2020-12-29 06:46:54 +01:00
|
|
|
for arg in args {
|
2021-03-23 12:36:50 +01:00
|
|
|
if arg.contains('-asan-compiler') {
|
2021-02-21 15:09:19 +01:00
|
|
|
asan_compiler = true
|
|
|
|
}
|
2021-03-23 12:36:50 +01:00
|
|
|
if arg.contains('-msan-compiler') {
|
2021-03-22 23:05:48 +01:00
|
|
|
msan_compiler = true
|
|
|
|
}
|
2021-04-19 14:38:48 +02:00
|
|
|
if arg.contains('-Werror') || arg.contains('-cstrict') {
|
2021-02-07 23:10:01 +01:00
|
|
|
werror = true
|
|
|
|
}
|
2021-03-23 12:36:50 +01:00
|
|
|
if arg.contains('-fsanitize=memory') {
|
2020-12-29 06:46:54 +01:00
|
|
|
sanitize_memory = true
|
|
|
|
}
|
2021-03-23 12:36:50 +01:00
|
|
|
if arg.contains('-fsanitize=address') {
|
2020-12-29 06:46:54 +01:00
|
|
|
sanitize_address = true
|
|
|
|
}
|
2021-03-23 12:36:50 +01:00
|
|
|
if arg.contains('-fsanitize=undefined') {
|
2020-12-29 19:27:57 +01:00
|
|
|
sanitize_undefined = true
|
2020-12-29 06:46:54 +01:00
|
|
|
}
|
|
|
|
}
|
2021-05-29 11:15:10 +02:00
|
|
|
if os.getenv('VTEST_RUN_FSANITIZE_TOO_SLOW').len == 0
|
|
|
|
&& (sanitize_undefined || sanitize_memory || sanitize_address) {
|
|
|
|
tsession.skip_files << skip_fsanitize_too_slow
|
|
|
|
}
|
2021-02-07 23:10:01 +01:00
|
|
|
if werror {
|
|
|
|
tsession.skip_files << skip_with_werror
|
|
|
|
}
|
2020-12-29 06:46:54 +01:00
|
|
|
if sanitize_memory {
|
|
|
|
tsession.skip_files << skip_with_fsanitize_memory
|
|
|
|
}
|
|
|
|
if sanitize_address {
|
|
|
|
tsession.skip_files << skip_with_fsanitize_address
|
|
|
|
}
|
|
|
|
if sanitize_undefined {
|
|
|
|
tsession.skip_files << skip_with_fsanitize_undefined
|
|
|
|
}
|
2021-02-21 15:09:19 +01:00
|
|
|
if asan_compiler {
|
|
|
|
tsession.skip_files << skip_with_asan_compiler
|
|
|
|
}
|
2021-03-22 23:05:48 +01:00
|
|
|
if msan_compiler {
|
|
|
|
tsession.skip_files << skip_with_msan_compiler
|
|
|
|
}
|
2021-01-05 17:13:38 +01:00
|
|
|
// println(tsession.skip_files)
|
2020-05-06 21:59:39 +02:00
|
|
|
if os.getenv('V_CI_MUSL').len > 0 {
|
|
|
|
tsession.skip_files << skip_on_musl
|
|
|
|
}
|
2020-07-08 20:30:57 +02:00
|
|
|
if os.getenv('V_CI_UBUNTU_MUSL').len > 0 {
|
|
|
|
tsession.skip_files << skip_on_ubuntu_musl
|
|
|
|
}
|
2021-08-27 08:47:04 +02:00
|
|
|
$if !amd64 {
|
|
|
|
tsession.skip_files << skip_on_non_amd64
|
|
|
|
}
|
|
|
|
$if amd64 {
|
|
|
|
tsession.skip_files << skip_on_amd64
|
|
|
|
}
|
2020-04-11 11:41:48 +02:00
|
|
|
$if !linux {
|
2020-05-06 21:59:39 +02:00
|
|
|
tsession.skip_files << skip_on_non_linux
|
2020-04-11 11:41:48 +02:00
|
|
|
}
|
2020-04-11 12:41:59 +02:00
|
|
|
$if linux {
|
2020-05-06 21:59:39 +02:00
|
|
|
tsession.skip_files << skip_on_linux
|
|
|
|
}
|
|
|
|
$if windows {
|
|
|
|
tsession.skip_files << skip_on_windows
|
|
|
|
}
|
|
|
|
$if !windows {
|
|
|
|
tsession.skip_files << skip_on_non_windows
|
|
|
|
}
|
|
|
|
$if macos {
|
|
|
|
tsession.skip_files << skip_on_macos
|
|
|
|
}
|
|
|
|
$if !macos {
|
|
|
|
tsession.skip_files << skip_on_non_macos
|
2020-04-11 12:41:59 +02:00
|
|
|
}
|
2020-04-05 11:40:17 +02:00
|
|
|
tsession.test()
|
|
|
|
eprintln(tsession.benchmark.total_message(title))
|
|
|
|
if tsession.benchmark.nfail > 0 {
|
2020-10-14 22:42:30 +02:00
|
|
|
eprintln('\nWARNING: failed $tsession.benchmark.nfail times.\n')
|
|
|
|
exit(1)
|
2020-04-05 14:20:28 +02:00
|
|
|
}
|
2020-04-05 11:40:17 +02:00
|
|
|
}
|