v/cmd/tools/vtest-self.v

185 lines
4.6 KiB
V
Raw Normal View History

module main
import os
import testing
import v.pref
const (
2021-04-15 08:28:33 +02:00
skip_test_files = [
'vlib/context/deadline_test.v' /* sometimes blocks */,
]
skip_with_fsanitize_memory = [
'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',
'vlib/net/http/header_test.v',
2021-02-07 23:10:01 +01:00
'vlib/net/udp_test.v',
'vlib/net/tcp_test.v',
'vlib/orm/orm_test.v',
'vlib/sqlite/sqlite_test.v',
2021-02-04 20:28:33 +01:00
'vlib/v/tests/orm_sub_struct_test.v',
2021-02-07 23:10:01 +01:00
'vlib/vweb/tests/vweb_test.v',
'vlib/vweb/request_test.v',
2021-03-01 11:50:52 +01:00
'vlib/vweb/route_test.v',
'vlib/x/websocket/websocket_test.v',
'vlib/crypto/rand/crypto_rand_read_test.v',
]
skip_with_fsanitize_address = [
2021-02-07 23:10:01 +01:00
'vlib/x/websocket/websocket_test.v',
]
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 = [
// -Wduplicated-branches
'vlib/v/tests/match_in_fn_call_test.v',
'vlib/v/tests/match_test.v',
'vlib/v/tests/unsafe_test.v',
]
2021-04-15 08:28:33 +02:00
skip_with_asan_compiler = [
'do_not_remove',
]
skip_with_msan_compiler = [
'do_not_remove',
]
skip_on_musl = [
'vlib/v/tests/profile/profile_test.v',
]
skip_on_ubuntu_musl = [
2021-03-01 13:54:49 +01:00
//'vlib/v/gen/js/jsgen_test.v',
'vlib/net/http/cookie_test.v',
'vlib/net/http/http_test.v',
2020-10-09 17:33:16 +02:00
'vlib/net/http/status_test.v',
'vlib/net/websocket/ws_test.v',
'vlib/sqlite/sqlite_test.v',
'vlib/orm/orm_test.v',
2021-02-04 20:28:33 +01:00
'vlib/v/tests/orm_sub_struct_test.v',
'vlib/clipboard/clipboard_test.v',
'vlib/vweb/tests/vweb_test.v',
'vlib/vweb/request_test.v',
2021-03-01 11:50:52 +01:00
'vlib/vweb/route_test.v',
'vlib/x/websocket/websocket_test.v',
2021-01-05 11:40:48 +01:00
'vlib/net/http/http_httpbin_test.v',
'vlib/net/http/header_test.v',
]
2021-04-15 08:28:33 +02:00
skip_on_linux = [
'do_not_remove',
]
skip_on_non_linux = [
2021-04-15 08:28:33 +02:00
'do_not_remove',
2020-05-26 12:50:37 +02:00
]
skip_on_windows = [
'vlib/orm/orm_test.v',
2021-02-04 20:28:33 +01:00
'vlib/v/tests/orm_sub_struct_test.v',
2020-06-09 15:06:07 +02:00
'vlib/net/websocket/ws_test.v',
'vlib/net/unix/unix_test.v',
'vlib/x/websocket/websocket_test.v',
'vlib/vweb/tests/vweb_test.v',
'vlib/vweb/request_test.v',
2021-03-01 11:50:52 +01:00
'vlib/vweb/route_test.v',
]
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',
]
)
// 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'
fn main() {
vexe := pref.vexe_path()
vroot := os.dir(vexe)
os.chdir(vroot)
args := os.args.clone()
args_string := args[1..].join(' ')
cmd_prefix := args_string.all_before('test-self')
2021-03-16 17:46:11 +01:00
title := 'testing vlib'
all_test_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.v')
testing.eheader(title)
mut tsession := testing.new_test_session(cmd_prefix)
tsession.files << all_test_files
tsession.skip_files << skip_test_files
2021-02-07 23:10:01 +01:00
mut werror := false
mut sanitize_memory := false
mut sanitize_address := false
mut sanitize_undefined := false
mut asan_compiler := false
mut msan_compiler := false
for arg in args {
if arg.contains('-asan-compiler') {
asan_compiler = true
}
if arg.contains('-msan-compiler') {
msan_compiler = true
}
if arg.contains('-Werror') || arg.contains('-cstrict') {
2021-02-07 23:10:01 +01:00
werror = true
}
if arg.contains('-fsanitize=memory') {
sanitize_memory = true
}
if arg.contains('-fsanitize=address') {
sanitize_address = true
}
if arg.contains('-fsanitize=undefined') {
sanitize_undefined = true
}
}
2021-02-07 23:10:01 +01:00
if werror {
tsession.skip_files << skip_with_werror
}
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
}
if asan_compiler {
tsession.skip_files << skip_with_asan_compiler
}
if msan_compiler {
tsession.skip_files << skip_with_msan_compiler
}
// println(tsession.skip_files)
if os.getenv('V_CI_MUSL').len > 0 {
tsession.skip_files << skip_on_musl
}
if os.getenv('V_CI_UBUNTU_MUSL').len > 0 {
tsession.skip_files << skip_on_ubuntu_musl
}
2020-04-11 11:41:48 +02:00
$if !linux {
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 {
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
}
tsession.test()
eprintln(tsession.benchmark.total_message(title))
if tsession.benchmark.nfail > 0 {
eprintln('\nWARNING: failed $tsession.benchmark.nfail times.\n')
exit(1)
2020-04-05 14:20:28 +02:00
}
}