| 1 | module main |
| 2 | |
| 3 | import os |
| 4 | import testing |
| 5 | |
| 6 | struct Config { |
| 7 | run_just_essential bool = '${os.getenv('VTEST_JUST_ESSENTIAL')}${os.getenv('VTEST_SANDBOXED_PACKAGING')}' != '' |
| 8 | is_musl_ci bool = os.getenv('V_CI_MUSL') != '' |
| 9 | is_ubuntu_musl_ci bool = os.getenv('V_CI_UBUNTU_MUSL') != '' |
| 10 | is_sandboxed_packaging bool = os.getenv('VTEST_SANDBOXED_PACKAGING') != '' |
| 11 | github_job string = os.getenv('GITHUB_JOB') |
| 12 | mut: |
| 13 | test_dirs []string = ['cmd', 'vlib'] |
| 14 | is_asan_compiler bool |
| 15 | is_msan_compiler bool |
| 16 | is_ubsan_compiler bool |
| 17 | // Options relating to the v command itself (passed in the prefix) `v [...args] test-self`. |
| 18 | werror bool |
| 19 | sanitize_memory bool |
| 20 | sanitize_address bool |
| 21 | sanitize_undefined bool |
| 22 | } |
| 23 | |
| 24 | const vroot = os.dir(os.real_path(os.getenv_opt('VEXE') or { @VEXE })) |
| 25 | |
| 26 | const essential_list = [ |
| 27 | 'cmd/tools/vvet/vet_test.v', |
| 28 | 'cmd/tools/vdoc/document/doc_test.v', |
| 29 | 'vlib/arrays/arrays_test.v', |
| 30 | 'vlib/bitfield/bitfield_test.v', |
| 31 | // |
| 32 | 'vlib/builtin/int_test.v', |
| 33 | 'vlib/builtin/array_test.v', |
| 34 | 'vlib/builtin/float_test.v', |
| 35 | 'vlib/builtin/byte_test.v', |
| 36 | 'vlib/builtin/rune_test.v', |
| 37 | 'vlib/builtin/builtin_test.c.v', |
| 38 | 'vlib/builtin/map_of_floats_test.v', |
| 39 | 'vlib/builtin/string_int_test.v', |
| 40 | 'vlib/builtin/utf8_test.v', |
| 41 | 'vlib/builtin/map_test.v', |
| 42 | 'vlib/builtin/string_test.v', |
| 43 | 'vlib/builtin/sorting_test.v', |
| 44 | 'vlib/builtin/gated_array_string_test.v', |
| 45 | 'vlib/builtin/isnil_test.v', |
| 46 | 'vlib/builtin/string_match_glob_test.v', |
| 47 | 'vlib/builtin/string_strip_margin_test.v', |
| 48 | // |
| 49 | 'vlib/cli/command_test.v', |
| 50 | 'vlib/crypto/md5/md5_test.v', |
| 51 | 'vlib/dl/dl_test.v', |
| 52 | 'vlib/encoding/base64/base64_test.v', |
| 53 | 'vlib/encoding/utf8/validate/encoding_utf8_test.v', |
| 54 | 'vlib/encoding/utf8/utf8_util_test.v', |
| 55 | 'vlib/flag/flag_test.v', |
| 56 | 'vlib/json/tests/json_decode_test.v', |
| 57 | 'vlib/math/math_test.v', |
| 58 | 'vlib/net/tcp_test.v', |
| 59 | 'vlib/net/http/http_test.v', |
| 60 | 'vlib/net/http/server_test.v', |
| 61 | 'vlib/net/http/request_test.v', |
| 62 | 'vlib/io/io_test.v', |
| 63 | 'vlib/io/os_file_reader_test.v', |
| 64 | 'vlib/os/process_test.v', |
| 65 | 'vlib/os/file_test.v', |
| 66 | 'vlib/os/notify/notify_test.c.v', |
| 67 | 'vlib/os/filepath_test.v', |
| 68 | 'vlib/os/environment_test.v', |
| 69 | 'vlib/os/glob_test.v', |
| 70 | 'vlib/os/os_test.c.v', |
| 71 | 'vlib/rand/random_numbers_test.v', |
| 72 | 'vlib/rand/wyrand/wyrand_test.v', |
| 73 | 'vlib/runtime/runtime_test.v', |
| 74 | 'vlib/semver/semver_test.v', |
| 75 | 'vlib/sync/stdatomic/atomic_test.v', |
| 76 | 'vlib/sync/thread_test.v', |
| 77 | 'vlib/sync/waitgroup_test.v', |
| 78 | 'vlib/sync/pool/pool_test.v', |
| 79 | 'vlib/strings/builder_test.v', |
| 80 | 'vlib/strconv/atof_test.c.v', |
| 81 | 'vlib/strconv/atoi_test.v', |
| 82 | 'vlib/strconv/f32_f64_to_string_test.v', |
| 83 | 'vlib/strconv/format_test.v', |
| 84 | 'vlib/strconv/number_to_base_test.v', |
| 85 | 'vlib/time/time_test.v', |
| 86 | 'vlib/toml/tests/toml_test.v', |
| 87 | 'vlib/v/compiler_errors_test.v', |
| 88 | 'vlib/v/fmt/fmt_keep_test.v', |
| 89 | 'vlib/v/fmt/fmt_test.v', |
| 90 | 'vlib/v/gen/c/coutput_test.v', |
| 91 | 'vlib/v/gen/js/program_test.v', |
| 92 | 'vlib/v/pkgconfig/pkgconfig_test.v', |
| 93 | 'vlib/v/slow_tests/inout/compiler_test.v', |
| 94 | 'vlib/x/json2/tests/json2_test.v', |
| 95 | ] |
| 96 | const skip_with_fsanitize_memory = [ |
| 97 | 'do_not_remove', |
| 98 | 'cmd/tools/vpm/dependency_test.v', // known flaky, for fsanitize_memory, due to using mbedtls |
| 99 | 'cmd/tools/vpm/install_test.v', // known flaky, for fsanitize_memory, due to using mbedtls |
| 100 | 'cmd/tools/vpm/install_version_input_test.v', // known flaky, for fsanitize_memory, due to using mbedtls |
| 101 | 'cmd/tools/vpm/install_version_test.v', // known flaky, for fsanitize_memory, due to using mbedtls |
| 102 | 'cmd/tools/vpm/update_test.v', // known flaky, for fsanitize_memory, due to using mbedtls |
| 103 | 'vlib/net/tcp_simple_client_server_test.v', |
| 104 | 'vlib/net/http/cookie_test.v', |
| 105 | 'vlib/net/http/http_test.v', |
| 106 | 'vlib/net/http/http_proxy_test.v', |
| 107 | 'vlib/net/http/status_test.v', |
| 108 | 'vlib/net/http/header_test.v', |
| 109 | 'vlib/net/http/server_test.v', |
| 110 | 'vlib/net/mbedtls/mbedtls_head_with_content_length_test.v', |
| 111 | 'vlib/net/ssl/ssl_read_all_test.v', |
| 112 | 'vlib/net/udp_test.v', |
| 113 | 'vlib/net/tcp_test.v', |
| 114 | 'vlib/orm/orm_test.v', |
| 115 | 'vlib/orm/orm_sql_or_blocks_test.v', |
| 116 | 'vlib/orm/orm_create_and_drop_test.v', |
| 117 | 'vlib/orm/orm_dynamic_test.v', |
| 118 | 'vlib/orm/orm_insert_test.v', |
| 119 | 'vlib/orm/orm_insert_reserved_name_test.v', |
| 120 | 'vlib/orm/orm_sum_type_insert_test.v', |
| 121 | 'vlib/orm/orm_fn_calls_test.v', |
| 122 | 'vlib/orm/orm_last_id_test.v', |
| 123 | 'vlib/orm/orm_string_interpolation_in_where_test.v', |
| 124 | 'vlib/orm/orm_interface_test.v', |
| 125 | 'vlib/orm/orm_mut_db_test.v', |
| 126 | 'vlib/orm/orm_null_test.v', |
| 127 | 'vlib/orm/orm_result_test.v', |
| 128 | 'vlib/orm/orm_custom_operators_test.v', |
| 129 | 'vlib/orm/orm_fk_test.v', |
| 130 | 'vlib/orm/orm_nested_struct_test.v', |
| 131 | 'vlib/orm/orm_references_test.v', |
| 132 | 'vlib/orm/orm_option_array_test.v', |
| 133 | 'vlib/orm/orm_option_time_test.v', |
| 134 | 'vlib/orm/orm_order_by_custom_field_test.v', |
| 135 | 'vlib/orm/orm_serial_attribute_test.v', |
| 136 | 'vlib/orm/orm_option_subselect_test.v', |
| 137 | 'vlib/orm/orm_save_test.v', |
| 138 | 'vlib/orm/orm_upsert_test.v', |
| 139 | 'vlib/orm/orm_func_test.v', |
| 140 | 'vlib/db/sqlite/sqlite_test.v', |
| 141 | 'vlib/db/sqlite/sqlite_orm_test.v', |
| 142 | 'vlib/db/sqlite/sqlite_comptime_field_test.v', |
| 143 | 'vlib/db/sqlite/parent_child_test.v', |
| 144 | 'vlib/db/sqlite/sqlite_vfs_lowlevel_test.v', |
| 145 | 'vlib/db/sqlite/sqlite_f32_test.v', |
| 146 | 'vlib/v/tests/orm_enum_test.v', |
| 147 | 'vlib/v/tests/orm_sub_struct_test.v', |
| 148 | 'vlib/v/tests/orm_sub_array_struct_test.v', |
| 149 | 'vlib/v/tests/orm_generic_struct_select_test.v', |
| 150 | 'vlib/v/tests/orm_joined_tables_select_test.v', |
| 151 | 'vlib/v/tests/orm_if_expr_value_test.v', |
| 152 | 'vlib/v/tests/orm_option_field_issue_18333_test.v', |
| 153 | 'vlib/v/tests/sql_statement_inside_fn_call_test.v', |
| 154 | 'vlib/v/tests/orm_stmt_wrong_return_checking_test.v', |
| 155 | 'vlib/v/tests/orm_table_name_test.v', |
| 156 | 'vlib/v/tests/orm_array_field_test.v', |
| 157 | 'vlib/v/tests/orm_bulk_insert_update_test.v', // MSan flags uninstrumented sqlite3BtreeOpen in libsqlite3.so |
| 158 | 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v', |
| 159 | 'vlib/v/tests/orm_create_several_tables_test.v', |
| 160 | 'vlib/v/tests/orm_update_test.v', |
| 161 | 'vlib/v/tests/orm_or_test.v', |
| 162 | 'vlib/net/http/request_test.v', |
| 163 | 'vlib/net/http/response_test.v', |
| 164 | 'vlib/net/websocket/websocket_test.v', |
| 165 | 'vlib/net/smtp/smtp_test.v', |
| 166 | 'vlib/v/tests/websocket_logger_interface_should_compile_test.v', |
| 167 | 'vlib/v/tests/fns/fn_literal_type_test.v', |
| 168 | 'vlib/v/tests/unions/union_implementing_interface_test.v', |
| 169 | 'vlib/x/async/timeout_test.v', // spawn + channels + IError default field; tripped by MSan padding tracking |
| 170 | 'vlib/x/sessions/tests/db_store_test.v', |
| 171 | ] |
| 172 | const skip_with_fsanitize_address = [ |
| 173 | 'do_not_remove', |
| 174 | 'vlib/compress/zstd/zstd_test.v', // ASan reports leaks from zstd library |
| 175 | 'vlib/crypto/argon2/argon2_test.v', // ASan flags large alloc on test setup |
| 176 | 'vlib/gg/text_rendering_test.v', // depends on freetype/font assets not available under sanitize CI |
| 177 | 'vlib/json/tests/json_decode_with_sumtype_test.v', // ASan flake on sumtype decode buffer reuse |
| 178 | 'vlib/net/mbedtls/mbedtls_read_timeout_test.v', // network timing test, ASan-incompatible |
| 179 | 'vlib/net/websocket/websocket_test.v', |
| 180 | 'vlib/orm/orm_create_and_drop_test.v', |
| 181 | 'vlib/orm/orm_insert_test.v', |
| 182 | 'vlib/orm/orm_insert_reserved_name_test.v', |
| 183 | 'vlib/orm/orm_sum_type_insert_test.v', |
| 184 | 'vlib/orm/orm_references_test.v', |
| 185 | 'vlib/v/tests/websocket_client_default_read_timeout_test.v', // network timing |
| 186 | 'vlib/v/tests/websocket_logger_interface_should_compile_test.v', |
| 187 | 'vlib/v/tests/orm_enum_test.v', |
| 188 | 'vlib/v/tests/orm_sub_array_struct_test.v', |
| 189 | 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v', |
| 190 | 'vlib/v/tests/orm_create_several_tables_test.v', |
| 191 | 'vlib/v/tests/orm_update_test.v', |
| 192 | 'vlib/v/tests/orm_or_test.v', |
| 193 | 'vlib/v/tests/shared_library_system_link_test.v', // ASan keeps Boehm GC symbols visible, breaking the export-symbol assertion |
| 194 | 'vlib/veb/sse/sse_test.v', // long-lived event stream + sockets, ASan flake |
| 195 | 'vlib/v2/gen/cleanc/flag_enum_codegen_test.v', // v2 self-host, ASan-incompatible |
| 196 | 'vlib/v2/gen/x64/x64_backend_runtime_regression_manual_test.v', // V2 x64 backend runtime regression manual tests, ASan-incompatible |
| 197 | ] |
| 198 | const skip_with_fsanitize_undefined = [ |
| 199 | 'do_not_remove', |
| 200 | 'vlib/crypto/argon2/argon2_test.v', // UBSan flags shift in argon2 reference impl |
| 201 | 'vlib/orm/orm_create_and_drop_test.v', |
| 202 | 'vlib/orm/orm_insert_test.v', |
| 203 | 'vlib/orm/orm_insert_reserved_name_test.v', |
| 204 | 'vlib/orm/orm_sum_type_insert_test.v', |
| 205 | 'vlib/orm/orm_references_test.v', |
| 206 | 'vlib/v/tests/orm_enum_test.v', |
| 207 | 'vlib/v/tests/orm_sub_array_struct_test.v', |
| 208 | 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v', |
| 209 | 'vlib/v/tests/orm_create_several_tables_test.v', |
| 210 | 'vlib/v/tests/orm_update_test.v', |
| 211 | 'vlib/v/tests/orm_or_test.v', |
| 212 | 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.c.v', // fails compilation with: undefined reference to vtable for __cxxabiv1::__function_type_info' |
| 213 | 'vlib/v/tests/shared_library_system_link_test.v', // UBSan keeps Boehm GC symbols visible, breaking the export-symbol assertion |
| 214 | 'vlib/v2/gen/cleanc/flag_enum_codegen_test.v', // v2 self-host, UBSan-incompatible |
| 215 | 'vlib/v2/gen/x64/x64_backend_runtime_regression_manual_test.v', // V2 x64 backend runtime regression manual tests, UBSan-incompatible |
| 216 | 'vlib/v2/transformer/transformer_test.v', // v2 transformer, UBSan-incompatible |
| 217 | 'vlib/yaml/yaml_conformance_test.v', // upstream libyaml-style integer overflow flagged by UBSan |
| 218 | ] |
| 219 | const skip_on_ubuntu_musl = [ |
| 220 | 'do_not_remove', |
| 221 | 'vlib/arrays/parallel/parallel_test.v', |
| 222 | 'vlib/builtin/js/array_test.js.v', |
| 223 | 'vlib/db/pg_sqlite_consistency_test.v', // pg + sqlite dev headers pull in glibc-only sys/cdefs.h on musl-gcc |
| 224 | 'vlib/db/sqlite/sqlite_test.v', |
| 225 | 'vlib/db/sqlite/sqlite_orm_test.v', |
| 226 | 'vlib/db/sqlite/sqlite_comptime_field_test.v', |
| 227 | 'vlib/db/sqlite/sqlite_vfs_lowlevel_test.v', |
| 228 | 'vlib/db/sqlite/parent_child_test.v', |
| 229 | 'vlib/db/sqlite/sqlite_f32_test.v', |
| 230 | 'vlib/gg/draw_rect_empty_test.v', // sokol.sapp needs X11/Xlib.h, not installed in the musl Docker image |
| 231 | 'vlib/gg/text_rendering_test.v', |
| 232 | 'vlib/orm/orm_test.v', |
| 233 | 'vlib/orm/orm_sql_or_blocks_test.v', |
| 234 | 'vlib/orm/orm_create_and_drop_test.v', |
| 235 | 'vlib/orm/orm_dynamic_test.v', |
| 236 | 'vlib/orm/orm_insert_test.v', |
| 237 | 'vlib/orm/orm_insert_reserved_name_test.v', |
| 238 | 'vlib/orm/orm_sum_type_insert_test.v', |
| 239 | 'vlib/orm/orm_fn_calls_test.v', |
| 240 | 'vlib/orm/orm_null_test.v', |
| 241 | 'vlib/orm/orm_last_id_test.v', |
| 242 | 'vlib/orm/orm_string_interpolation_in_where_test.v', |
| 243 | 'vlib/orm/orm_interface_test.v', |
| 244 | 'vlib/orm/orm_mut_db_test.v', |
| 245 | 'vlib/orm/orm_result_test.v', |
| 246 | 'vlib/orm/orm_custom_operators_test.v', |
| 247 | 'vlib/orm/orm_fk_test.v', |
| 248 | 'vlib/orm/orm_nested_struct_test.v', |
| 249 | 'vlib/orm/orm_references_test.v', |
| 250 | 'vlib/orm/orm_option_array_test.v', |
| 251 | 'vlib/orm/orm_option_time_test.v', |
| 252 | 'vlib/orm/orm_order_by_custom_field_test.v', |
| 253 | 'vlib/orm/orm_serial_attribute_test.v', |
| 254 | 'vlib/orm/orm_option_subselect_test.v', |
| 255 | 'vlib/orm/orm_func_test.v', |
| 256 | 'vlib/orm/orm_where_in_test.v', |
| 257 | 'vlib/sokol/gfx/gfx_test.v', // sokol_app.h needs GL/gl.h, not installed in the musl Docker image |
| 258 | 'vlib/v/gen/c/sql_assert_temp_var_test.v', // sqlite header dependency pulls in glibc sys/cdefs.h on musl-gcc |
| 259 | 'vlib/v/tests/concurrency/shared_nested_lock_runtime_test.v', // nested shared lock times out on the musl image |
| 260 | 'vlib/v/tests/orm_bulk_insert_update_test.v', |
| 261 | 'vlib/v/tests/orm_enum_test.v', |
| 262 | 'vlib/v/tests/orm_if_expr_value_test.v', |
| 263 | 'vlib/v/tests/orm_sub_struct_test.v', |
| 264 | 'vlib/v/tests/orm_sub_array_struct_test.v', |
| 265 | 'vlib/v/tests/orm_joined_tables_select_test.v', |
| 266 | 'vlib/v/tests/orm_stmt_wrong_return_checking_test.v', |
| 267 | 'vlib/v/tests/orm_table_name_test.v', |
| 268 | 'vlib/v/tests/orm_array_field_test.v', |
| 269 | 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v', |
| 270 | 'vlib/v/tests/orm_create_several_tables_test.v', |
| 271 | 'vlib/v/tests/orm_update_test.v', |
| 272 | 'vlib/v/tests/orm_or_test.v', |
| 273 | 'vlib/v/tests/shared_library_system_link_test.v', // musl libc.so is not a regular DSO; -lc shared link fails with hidden atexit |
| 274 | 'vlib/v/tests/sql_statement_inside_fn_call_test.v', |
| 275 | 'vlib/v/tests/websocket_logger_interface_should_compile_test.v', |
| 276 | 'vlib/v/tests/fns/fn_literal_type_test.v', |
| 277 | 'vlib/clipboard/clipboard_test.v', |
| 278 | 'vlib/net/http/request_test.v', |
| 279 | 'vlib/net/http/http_proxy_test.v', // pulls in libssl headers that include glibc-only sys/cdefs.h |
| 280 | 'vlib/net/websocket/websocket_test.v', |
| 281 | 'vlib/net/http/header_test.v', |
| 282 | 'vlib/net/http/server_test.v', |
| 283 | 'vlib/net/http/response_test.v', |
| 284 | 'vlib/net/smtp/smtp_test.v', |
| 285 | 'vlib/net/http/cookie_test.v', |
| 286 | 'vlib/net/http/status_test.v', |
| 287 | 'vlib/x/sessions/tests/db_store_test.v', |
| 288 | 'vlib/veb/tests/veb_app_test.v', |
| 289 | 'vlib/ncurses/ncurses_test.v', |
| 290 | 'vlib/v/tests/fixed_array_update_c_struct_alias_test.v', |
| 291 | 'vlib/x/crypto/mldsa/mldsa_test.v', |
| 292 | ] |
| 293 | |
| 294 | fn Config.init(vargs []string, targs []string) !Config { |
| 295 | mut cfg := Config{} |
| 296 | for arg in vargs { |
| 297 | match arg { |
| 298 | '-Werror', '-cstrict' { cfg.werror = true } |
| 299 | else {} |
| 300 | } |
| 301 | |
| 302 | // Match -fsanitize prefix, since CI may pass combined values like |
| 303 | // `-fsanitize=address,pointer-compare,pointer-subtract`. |
| 304 | if arg.starts_with('-fsanitize=') { |
| 305 | vals := arg.all_after('=').split(',') |
| 306 | if 'memory' in vals { |
| 307 | cfg.sanitize_memory = true |
| 308 | } |
| 309 | if 'address' in vals { |
| 310 | cfg.sanitize_address = true |
| 311 | } |
| 312 | if 'undefined' in vals { |
| 313 | cfg.sanitize_undefined = true |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | if targs.len == 0 { |
| 318 | return cfg |
| 319 | } |
| 320 | mut tdirs := []string{} |
| 321 | mut errs := []string{} |
| 322 | for arg in targs { |
| 323 | match arg { |
| 324 | '-asan-compiler', '--asan-compiler' { |
| 325 | cfg.is_asan_compiler = true |
| 326 | } |
| 327 | '-msan-compiler', '--msan-compiler' { |
| 328 | cfg.is_msan_compiler = true |
| 329 | } |
| 330 | '-ubsan-compiler', '--ubsan-compiler' { |
| 331 | cfg.is_ubsan_compiler = true |
| 332 | } |
| 333 | else { |
| 334 | if arg.starts_with('-') { |
| 335 | errs << 'error: unknown flag `${arg}`' |
| 336 | continue |
| 337 | } |
| 338 | if !os.is_dir(os.join_path(vroot, arg)) { |
| 339 | errs << 'error: failed to find directory `${arg}`' |
| 340 | continue |
| 341 | } |
| 342 | tdirs << arg |
| 343 | } |
| 344 | } |
| 345 | } |
| 346 | if errs.len > 0 { |
| 347 | return error(errs.join_lines()) |
| 348 | } |
| 349 | if tdirs.len > 0 { |
| 350 | cfg.test_dirs = tdirs |
| 351 | } |
| 352 | return cfg |
| 353 | } |
| 354 | |
| 355 | fn main() { |
| 356 | unbuffer_stdout() |
| 357 | os.chdir(vroot)! |
| 358 | args_idx := os.args.index('test-self') |
| 359 | if args_idx < 0 { |
| 360 | eprintln('vtest-self: could not find `test-self` in os.args: ${os.args}') |
| 361 | exit(1) |
| 362 | } |
| 363 | vargs := os.args[1..args_idx] |
| 364 | targs := os.args#[args_idx + 1..] |
| 365 | cfg := Config.init(vargs, targs) or { |
| 366 | eprintln(err) |
| 367 | exit(1) |
| 368 | } |
| 369 | // dump(cfg) |
| 370 | title := 'testing: ${cfg.test_dirs.join(', ')}' |
| 371 | mut tpaths := map[string]bool{} |
| 372 | mut tpaths_ref := &tpaths |
| 373 | for dir in cfg.test_dirs { |
| 374 | os.walk(os.join_path(vroot, dir), fn [mut tpaths_ref] (p string) { |
| 375 | if p.ends_with('_test.v') || p.ends_with('_test.c.v') |
| 376 | || (testing.is_node_present && p.ends_with('_test.js.v')) { |
| 377 | unsafe { |
| 378 | tpaths_ref[p] = true |
| 379 | } |
| 380 | } |
| 381 | }) |
| 382 | } |
| 383 | mut all_test_files := tpaths.keys() |
| 384 | if cfg.run_just_essential { |
| 385 | all_test_files = essential_list.map(os.join_path(vroot, it)) |
| 386 | } |
| 387 | mut tsession := testing.new_test_session(vargs.join(' '), true) |
| 388 | tsession.exec_mode = .compile_and_run |
| 389 | tsession.files << all_test_files.filter(!it.contains('testdata' + os.path_separator)) |
| 390 | // v2 has its own driver at `cmd/v2/test_all.sh` and is still under heavy |
| 391 | // development, so its tests are excluded from `v test-self`. |
| 392 | v2_dir_fragment := '${os.path_separator}vlib${os.path_separator}v2${os.path_separator}' |
| 393 | tsession.skip_files << tsession.files.filter(it.contains(v2_dir_fragment)) |
| 394 | if cfg.werror { |
| 395 | tsession.custom_defines << 'self_werror' |
| 396 | } |
| 397 | if cfg.sanitize_memory { |
| 398 | tsession.skip_files << skip_with_fsanitize_memory |
| 399 | tsession.custom_defines << 'self_sanitize_memory' |
| 400 | } |
| 401 | if cfg.sanitize_address { |
| 402 | tsession.skip_files << skip_with_fsanitize_address |
| 403 | tsession.custom_defines << 'self_sanitize_address' |
| 404 | } |
| 405 | if cfg.sanitize_undefined { |
| 406 | tsession.skip_files << skip_with_fsanitize_undefined |
| 407 | tsession.custom_defines << 'self_sanitize_undefined' |
| 408 | } |
| 409 | if cfg.is_asan_compiler { |
| 410 | tsession.custom_defines << 'self_asan_compiler' |
| 411 | } |
| 412 | if cfg.is_msan_compiler { |
| 413 | tsession.custom_defines << 'self_msan_compiler' |
| 414 | } |
| 415 | if cfg.is_ubsan_compiler { |
| 416 | tsession.custom_defines << 'self_ubsan_compiler' |
| 417 | } |
| 418 | if cfg.is_sandboxed_packaging { |
| 419 | tsession.custom_defines << 'self_sandboxed_packaging' |
| 420 | } |
| 421 | if cfg.is_ubuntu_musl_ci { |
| 422 | tsession.skip_files << skip_on_ubuntu_musl |
| 423 | tsession.custom_defines << 'self_ubuntu_musl_ci' |
| 424 | } |
| 425 | // dump(tsession.skip_files) |
| 426 | mut unavailable_files := tsession.files.filter(!os.exists(it)) |
| 427 | unavailable_files << tsession.skip_files.filter(it != 'do_not_remove' && !os.exists(it)) |
| 428 | if unavailable_files.len > 0 { |
| 429 | for f in unavailable_files { |
| 430 | eprintln('error: failed to find file: ${f}') |
| 431 | } |
| 432 | exit(1) |
| 433 | } |
| 434 | tsession.skip_files = tsession.skip_files.map(os.abs_path) |
| 435 | tsession.session_start(title) |
| 436 | tsession.test() |
| 437 | tsession.session_stop(title) |
| 438 | flush_stdout() |
| 439 | if tsession.benchmark.nfail > 0 { |
| 440 | eprintln('\nError: failed ${tsession.benchmark.nfail} times.\n') |
| 441 | exit(1) |
| 442 | } |
| 443 | } |
| 444 | |