v / cmd / tools
Raw file | 453 loc (443 sloc) | 13.22 KB | Latest commit hash b5b1efbb7
1module main
2
3import os
4import testing
5
6const github_job = os.getenv('GITHUB_JOB')
7
8const just_essential = os.getenv('VTEST_JUST_ESSENTIAL') != ''
9
10const (
11 essential_list = [
12 'cmd/tools/vvet/vet_test.v',
13 'vlib/arrays/arrays_test.v',
14 'vlib/bitfield/bitfield_test.v',
15 //
16 'vlib/builtin/int_test.v',
17 'vlib/builtin/array_test.v',
18 'vlib/builtin/array_sorted_test.v',
19 'vlib/builtin/float_test.v',
20 'vlib/builtin/byte_test.v',
21 'vlib/builtin/rune_test.v',
22 'vlib/builtin/builtin_test.v',
23 'vlib/builtin/map_of_floats_test.v',
24 'vlib/builtin/string_int_test.v',
25 'vlib/builtin/utf8_test.v',
26 'vlib/builtin/map_test.v',
27 'vlib/builtin/string_test.v',
28 'vlib/builtin/sorting_test.v',
29 'vlib/builtin/gated_array_string_test.v',
30 'vlib/builtin/array_shrinkage_test.v',
31 'vlib/builtin/isnil_test.v',
32 'vlib/builtin/string_match_glob_test.v',
33 'vlib/builtin/string_strip_margin_test.v',
34 //
35 'vlib/cli/command_test.v',
36 'vlib/crypto/md5/md5_test.v',
37 'vlib/dl/dl_test.v',
38 'vlib/encoding/base64/base64_test.v',
39 'vlib/encoding/utf8/encoding_utf8_test.v',
40 'vlib/encoding/utf8/utf8_util_test.v',
41 'vlib/flag/flag_test.v',
42 'vlib/json/json_decode_test.v',
43 'vlib/math/math_test.v',
44 'vlib/net/tcp_test.v',
45 'vlib/net/http/http_test.v',
46 'vlib/net/http/server_test.v',
47 'vlib/net/http/request_test.v',
48 'vlib/io/io_test.v',
49 'vlib/io/os_file_reader_test.v',
50 'vlib/os/process_test.v',
51 'vlib/os/file_test.v',
52 'vlib/os/notify/notify_test.v',
53 'vlib/os/filepath_test.v',
54 'vlib/os/environment_test.v',
55 'vlib/os/glob_test.v',
56 'vlib/os/os_test.v',
57 'vlib/rand/random_numbers_test.v',
58 'vlib/rand/wyrand/wyrand_test.v',
59 'vlib/runtime/runtime_test.v',
60 'vlib/semver/semver_test.v',
61 'vlib/sync/stdatomic/atomic_test.v',
62 'vlib/sync/thread_test.v',
63 'vlib/sync/waitgroup_test.v',
64 'vlib/sync/pool/pool_test.v',
65 'vlib/strings/builder_test.v',
66 'vlib/strconv/atof_test.v',
67 'vlib/strconv/atoi_test.v',
68 'vlib/strconv/f32_f64_to_string_test.v',
69 'vlib/strconv/format_test.v',
70 'vlib/strconv/number_to_base_test.v',
71 'vlib/time/time_test.v',
72 'vlib/toml/tests/toml_test.v',
73 'vlib/v/compiler_errors_test.v',
74 'vlib/v/doc/doc_test.v',
75 'vlib/v/eval/interpret_test.v',
76 'vlib/v/fmt/fmt_keep_test.v',
77 'vlib/v/fmt/fmt_test.v',
78 'vlib/v/gen/c/coutput_test.v',
79 'vlib/v/gen/js/program_test.v',
80 'vlib/v/gen/native/macho_test.v',
81 'vlib/v/gen/native/tests/native_test.v',
82 'vlib/v/pkgconfig/pkgconfig_test.v',
83 'vlib/v/slow_tests/inout/compiler_test.v',
84 'vlib/x/json2/json2_test.v',
85 ]
86 skip_test_files = [
87 'do_not_remove',
88 'cmd/tools/vdoc/html_tag_escape_test.v', // can't locate local module: markdown
89 'cmd/tools/vdoc/tests/vdoc_file_test.v', // fails on Windows; order of output is not as expected
90 'vlib/context/deadline_test.v', // sometimes blocks
91 'vlib/context/onecontext/onecontext_test.v', // backtrace_symbols is missing
92 'vlib/db/mysql/mysql_orm_test.v', // mysql not installed
93 'vlib/db/mysql/mysql_test.v', // mysql not installed
94 'vlib/db/pg/pg_orm_test.v', // pg not installed
95 ]
96 // These tests are too slow to be run in the CI on each PR/commit
97 // in the sanitized modes:
98 skip_fsanitize_too_slow = [
99 'do_not_remove',
100 'vlib/v/compiler_errors_test.v',
101 'vlib/v/doc/doc_test.v',
102 'vlib/v/fmt/fmt_test.v',
103 'vlib/v/fmt/fmt_keep_test.v',
104 'vlib/v/fmt/fmt_vlib_test.v',
105 'vlib/v/live/live_test.v',
106 'vlib/v/parser/v_parser_test.v',
107 'vlib/v/scanner/scanner_test.v',
108 'vlib/v/slow_tests/inout/compiler_test.v',
109 'vlib/v/slow_tests/prod_test.v',
110 'vlib/v/slow_tests/profile/profile_test.v',
111 'vlib/v/slow_tests/repl/repl_test.v',
112 'vlib/v/slow_tests/valgrind/valgrind_test.v',
113 ]
114 skip_with_fsanitize_memory = [
115 'do_not_remove',
116 'vlib/net/tcp_simple_client_server_test.v',
117 'vlib/net/http/cookie_test.v',
118 'vlib/net/http/http_test.v',
119 'vlib/net/http/status_test.v',
120 'vlib/net/http/http_httpbin_test.v',
121 'vlib/net/http/header_test.v',
122 'vlib/net/http/server_test.v',
123 'vlib/net/udp_test.v',
124 'vlib/net/tcp_test.v',
125 'vlib/orm/orm_test.v',
126 'vlib/orm/orm_sql_or_blocks_test.v',
127 'vlib/orm/orm_create_and_drop_test.v',
128 'vlib/orm/orm_insert_test.v',
129 'vlib/orm/orm_insert_reserved_name_test.v',
130 'vlib/orm/orm_fn_calls_test.v',
131 'vlib/orm/orm_last_id_test.v',
132 'vlib/orm/orm_string_interpolation_in_where_test.v',
133 'vlib/orm/orm_interface_test.v',
134 'vlib/orm/orm_mut_db_test.v',
135 'vlib/orm/orm_result_test.v',
136 'vlib/orm/orm_custom_operators_test.v',
137 'vlib/orm/orm_fk_test.v',
138 'vlib/orm/orm_references_test.v',
139 'vlib/db/sqlite/sqlite_test.v',
140 'vlib/db/sqlite/sqlite_orm_test.v',
141 'vlib/db/sqlite/sqlite_vfs_lowlevel_test.v',
142 'vlib/v/tests/orm_enum_test.v',
143 'vlib/v/tests/orm_sub_struct_test.v',
144 'vlib/v/tests/orm_sub_array_struct_test.v',
145 'vlib/v/tests/orm_joined_tables_select_test.v',
146 'vlib/v/tests/sql_statement_inside_fn_call_test.v',
147 'vlib/v/tests/orm_stmt_wrong_return_checking_test.v',
148 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
149 'vlib/vweb/tests/vweb_test.v',
150 'vlib/vweb/csrf/csrf_test.v',
151 'vlib/vweb/request_test.v',
152 'vlib/net/http/request_test.v',
153 'vlib/net/http/response_test.v',
154 'vlib/vweb/route_test.v',
155 'vlib/net/websocket/websocket_test.v',
156 'vlib/crypto/rand/crypto_rand_read_test.v',
157 'vlib/net/smtp/smtp_test.v',
158 'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
159 'vlib/v/tests/fn_literal_type_test.v',
160 ]
161 skip_with_fsanitize_address = [
162 'do_not_remove',
163 'vlib/net/websocket/websocket_test.v',
164 'vlib/orm/orm_create_and_drop_test.v',
165 'vlib/orm/orm_insert_test.v',
166 'vlib/orm/orm_insert_reserved_name_test.v',
167 'vlib/orm/orm_references_test.v',
168 'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
169 'vlib/v/tests/orm_enum_test.v',
170 'vlib/v/tests/orm_sub_array_struct_test.v',
171 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
172 ]
173 skip_with_fsanitize_undefined = [
174 'do_not_remove',
175 'vlib/orm/orm_create_and_drop_test.v',
176 'vlib/orm/orm_insert_test.v',
177 'vlib/orm/orm_insert_reserved_name_test.v',
178 'vlib/orm/orm_references_test.v',
179 'vlib/v/tests/orm_enum_test.v',
180 'vlib/v/tests/orm_sub_array_struct_test.v',
181 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
182 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.v', // fails compilation with: undefined reference to vtable for __cxxabiv1::__function_type_info'
183 ]
184 skip_with_werror = [
185 'do_not_remove',
186 'vlib/v/embed_file/tests/embed_file_test.v',
187 ]
188 skip_with_asan_compiler = [
189 'do_not_remove',
190 ]
191 skip_with_msan_compiler = [
192 'do_not_remove',
193 ]
194 skip_on_musl = [
195 'do_not_remove',
196 'vlib/v/slow_tests/profile/profile_test.v',
197 'vlib/gg/draw_fns_api_test.v',
198 'vlib/v/tests/skip_unused/gg_code.vv',
199 'vlib/v/tests/c_struct_with_reserved_field_name_test.v',
200 ]
201 skip_on_ubuntu_musl = [
202 'do_not_remove',
203 //'vlib/v/gen/js/jsgen_test.v',
204 'vlib/net/http/cookie_test.v',
205 'vlib/net/http/http_test.v',
206 'vlib/net/http/status_test.v',
207 'vlib/net/websocket/ws_test.v',
208 'vlib/db/sqlite/sqlite_test.v',
209 'vlib/db/sqlite/sqlite_orm_test.v',
210 'vlib/db/sqlite/sqlite_vfs_lowlevel_test.v',
211 'vlib/orm/orm_test.v',
212 'vlib/orm/orm_sql_or_blocks_test.v',
213 'vlib/orm/orm_create_and_drop_test.v',
214 'vlib/orm/orm_insert_test.v',
215 'vlib/orm/orm_insert_reserved_name_test.v',
216 'vlib/orm/orm_fn_calls_test.v',
217 'vlib/orm/orm_last_id_test.v',
218 'vlib/orm/orm_string_interpolation_in_where_test.v',
219 'vlib/orm/orm_interface_test.v',
220 'vlib/orm/orm_mut_db_test.v',
221 'vlib/orm/orm_result_test.v',
222 'vlib/orm/orm_custom_operators_test.v',
223 'vlib/orm/orm_fk_test.v',
224 'vlib/orm/orm_references_test.v',
225 'vlib/v/tests/orm_enum_test.v',
226 'vlib/v/tests/orm_sub_struct_test.v',
227 'vlib/v/tests/orm_sub_array_struct_test.v',
228 'vlib/v/tests/orm_joined_tables_select_test.v',
229 'vlib/v/tests/orm_stmt_wrong_return_checking_test.v',
230 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
231 'vlib/v/tests/sql_statement_inside_fn_call_test.v',
232 'vlib/clipboard/clipboard_test.v',
233 'vlib/vweb/tests/vweb_test.v',
234 'vlib/vweb/request_test.v',
235 'vlib/vweb/csrf/csrf_test.v',
236 'vlib/net/http/request_test.v',
237 'vlib/vweb/route_test.v',
238 'vlib/net/websocket/websocket_test.v',
239 'vlib/net/http/http_httpbin_test.v',
240 'vlib/net/http/header_test.v',
241 'vlib/net/http/server_test.v',
242 'vlib/net/http/response_test.v',
243 'vlib/builtin/js/array_test.js.v',
244 'vlib/net/smtp/smtp_test.v',
245 'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
246 'vlib/v/tests/fn_literal_type_test.v',
247 ]
248 skip_on_linux = [
249 'do_not_remove',
250 ]
251 skip_on_non_linux = [
252 'do_not_remove',
253 ]
254 skip_on_windows_msvc = [
255 'do_not_remove',
256 'vlib/v/tests/const_fixed_array_containing_references_to_itself_test.v', // error C2099: initializer is not a constant
257 'vlib/v/tests/const_and_global_with_same_name_test.v', // error C2099: initializer is not a constant
258 'vlib/v/tests/sumtype_as_cast_test.v', // error: cannot support compound statement expression ({expr; expr; expr;})
259 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.v', // TODO
260 ]
261 skip_on_windows = [
262 'do_not_remove',
263 'vlib/orm/orm_test.v',
264 'vlib/v/tests/orm_sub_struct_test.v',
265 'vlib/v/tests/orm_joined_tables_select_test.v',
266 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
267 'vlib/net/websocket/ws_test.v',
268 'vlib/net/unix/unix_test.v',
269 'vlib/net/unix/use_net_and_net_unix_together_test.v',
270 'vlib/net/websocket/websocket_test.v',
271 'vlib/net/openssl/openssl_compiles_test.v',
272 'vlib/net/http/request_test.v',
273 'vlib/net/smtp/smtp_test.v',
274 'vlib/net/ssl/ssl_compiles_test.v',
275 'vlib/net/mbedtls/mbedtls_compiles_test.v',
276 'vlib/vweb/tests/vweb_test.v',
277 'vlib/vweb/request_test.v',
278 'vlib/vweb/route_test.v',
279 'vlib/sync/many_times_test.v',
280 'vlib/sync/once_test.v',
281 'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
282 'vlib/v/tests/fn_literal_type_test.v',
283 ]
284 skip_on_non_windows = [
285 'do_not_remove',
286 ]
287 skip_on_macos = [
288 'do_not_remove',
289 ]
290 skip_on_non_macos = [
291 'do_not_remove',
292 ]
293 skip_on_amd64 = [
294 'do_not_remove',
295 ]
296 skip_on_arm64 = [
297 'do_not_remove',
298 ]
299 skip_on_non_amd64_or_arm64 = [
300 'do_not_remove',
301 // closures aren't implemented yet:
302 'vlib/v/tests/closure_test.v',
303 'vlib/context/cancel_test.v',
304 'vlib/context/deadline_test.v',
305 'vlib/context/empty_test.v',
306 'vlib/context/value_test.v',
307 'vlib/context/onecontext/onecontext_test.v',
308 'vlib/sync/once_test.v',
309 'vlib/sync/many_times_test.v',
310 'do_not_remove',
311 ]
312)
313
314// Note: musl misses openssl, thus the http tests can not be done there
315// Note: http_httpbin_test.v: fails with 'cgen error: json: map_string_string is not struct'
316fn main() {
317 vexe := os.real_path(os.getenv_opt('VEXE') or { @VEXE })
318 vroot := os.dir(vexe)
319 os.chdir(vroot) or { panic(err) }
320 args := os.args.clone()
321 args_string := args[1..].join(' ')
322 cmd_prefix := args_string.all_before('test-self')
323 title := 'testing vlib'
324 mut all_test_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.v')
325 all_test_files << os.walk_ext(os.join_path(vroot, 'cmd'), '_test.v')
326 test_js_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.js.v')
327 all_test_files << test_js_files
328
329 if just_essential {
330 rooted_essential_list := essential_list.map(os.join_path(vroot, it))
331 all_test_files = all_test_files.filter(rooted_essential_list.contains(it))
332 }
333 testing.eheader(title)
334 mut tsession := testing.new_test_session(cmd_prefix, true)
335 tsession.files << all_test_files.filter(!it.contains('testdata' + os.path_separator))
336 tsession.skip_files << skip_test_files
337
338 if !testing.is_node_present {
339 testroot := vroot + os.path_separator
340 tsession.skip_files << test_js_files.map(it.replace(testroot, ''))
341 }
342 testing.find_started_process('mysqld') or {
343 tsession.skip_files << 'vlib/db/mysql/mysql_orm_test.v'
344 tsession.skip_files << 'vlib/db/mysql/mysql_test.v'
345 }
346 testing.find_started_process('postgres') or {
347 tsession.skip_files << 'vlib/db/pg/pg_orm_test.v'
348 }
349
350 if github_job == 'windows-tcc' {
351 tsession.skip_files << 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.v'
352 // TODO: fix these ASAP
353 tsession.skip_files << 'vlib/net/tcp_test.v'
354 tsession.skip_files << 'vlib/net/udp_test.v'
355 }
356
357 if !os.exists('cmd/tools/builders/wasm_builder') {
358 tsession.skip_files << 'vlib/v/gen/wasm/tests/wasm_test.v'
359 }
360
361 mut werror := false
362 mut sanitize_memory := false
363 mut sanitize_address := false
364 mut sanitize_undefined := false
365 mut asan_compiler := false
366 mut msan_compiler := false
367 for arg in args {
368 if arg.contains('-asan-compiler') {
369 asan_compiler = true
370 }
371 if arg.contains('-msan-compiler') {
372 msan_compiler = true
373 }
374 if arg.contains('-Werror') || arg.contains('-cstrict') {
375 werror = true
376 }
377 if arg.contains('-fsanitize=memory') {
378 sanitize_memory = true
379 }
380 if arg.contains('-fsanitize=address') {
381 sanitize_address = true
382 }
383 if arg.contains('-fsanitize=undefined') {
384 sanitize_undefined = true
385 }
386 }
387 if os.getenv('VTEST_RUN_FSANITIZE_TOO_SLOW').len == 0
388 && ((sanitize_undefined || sanitize_memory || sanitize_address)
389 || (msan_compiler || asan_compiler)) {
390 tsession.skip_files << skip_fsanitize_too_slow
391 }
392 if werror {
393 tsession.skip_files << skip_with_werror
394 }
395 if sanitize_memory {
396 tsession.skip_files << skip_with_fsanitize_memory
397 }
398 if sanitize_address {
399 tsession.skip_files << skip_with_fsanitize_address
400 }
401 if sanitize_undefined {
402 tsession.skip_files << skip_with_fsanitize_undefined
403 }
404 if asan_compiler {
405 tsession.skip_files << skip_with_asan_compiler
406 }
407 if msan_compiler {
408 tsession.skip_files << skip_with_msan_compiler
409 }
410 // println(tsession.skip_files)
411 if os.getenv('V_CI_MUSL').len > 0 {
412 tsession.skip_files << skip_on_musl
413 }
414 if os.getenv('V_CI_UBUNTU_MUSL').len > 0 {
415 tsession.skip_files << skip_on_ubuntu_musl
416 }
417 $if !amd64 && !arm64 {
418 tsession.skip_files << skip_on_non_amd64
419 }
420 $if amd64 {
421 tsession.skip_files << skip_on_amd64
422 }
423 $if arm64 {
424 tsession.skip_files << skip_on_arm64
425 }
426 $if !linux {
427 tsession.skip_files << skip_on_non_linux
428 }
429 $if linux {
430 tsession.skip_files << skip_on_linux
431 }
432 $if windows {
433 tsession.skip_files << skip_on_windows
434 $if msvc {
435 tsession.skip_files << skip_on_windows_msvc
436 }
437 }
438 $if !windows {
439 tsession.skip_files << skip_on_non_windows
440 }
441 $if macos {
442 tsession.skip_files << skip_on_macos
443 }
444 $if !macos {
445 tsession.skip_files << skip_on_non_macos
446 }
447 tsession.test()
448 eprintln(tsession.benchmark.total_message(title))
449 if tsession.benchmark.nfail > 0 {
450 eprintln('\nWARNING: failed ${tsession.benchmark.nfail} times.\n')
451 exit(1)
452 }
453}