diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7be8fd29d..548a167127 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,6 +106,8 @@ jobs: ./cmd/tools/test_if_v_test_system_works - name: Self tests run: ./v -silent test-self + - name: Self tests (-Werror) + run: ./v -cflags "-Werror" test-self - name: Test time functions in a timezone UTC-12 run: TZ=Etc/GMT+12 ./v test vlib/time/ - name: Test time functions in a timezone UTC-3 @@ -289,6 +291,8 @@ jobs: ./v -silent test-self - name: Self tests (-prod) run: ./v -o vprod -prod cmd/v && ./vprod -silent test-self + - name: Self tests (-Werror) + run: ./v -cc gcc -cflags "-Werror" test-self - name: Build examples run: ./v build-examples - name: Build examples with -autofree @@ -358,9 +362,11 @@ jobs: ./v -o v2 cmd/v -cflags -fsanitize=memory ./v -o v3 cmd/v -cflags -fsanitize=thread ./v -o v4 cmd/v -cflags -fsanitize=undefined + ./v -o v5 cmd/v -cflags -fsanitize=address UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v4 -o v.c cmd/v + ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v5 -o v.c cmd/v - name: v self compilation run: ./v -o v2 cmd/v && ./v2 -o v3 cmd/v && ./v3 -o v4 cmd/v - name: v self with -usecache @@ -374,6 +380,8 @@ jobs: ./v -silent test-self - name: Self tests (-prod) run: ./v -o vprod -prod cmd/v && ./vprod -silent test-self + - name: Self tests (-Werror) + run: ./v -cflags "-Werror" test-self - name: Build examples run: ./v build-examples - name: Build examples with -autofree diff --git a/cmd/tools/vtest-self.v b/cmd/tools/vtest-self.v index 220b684655..4f65305d1d 100644 --- a/cmd/tools/vtest-self.v +++ b/cmd/tools/vtest-self.v @@ -6,55 +6,161 @@ import v.pref const ( skip_with_fsanitize_memory = [ - 'vlib/encoding/csv/reader_test.v', - 'vlib/net/tcp_test.v', 'vlib/net/tcp_simple_client_server_test.v', - 'vlib/net/udp_test.v', 'vlib/net/http/cookie_test.v', 'vlib/net/http/http_test.v', 'vlib/net/http/status_test.v', + 'vlib/net/http/http_httpbin_test.v', + 'vlib/net/udp_test.v', + 'vlib/net/tcp_test.v', 'vlib/orm/orm_test.v', 'vlib/sqlite/sqlite_test.v', - 'vlib/vweb/tests/vweb_test.v', - 'vlib/v/tests/unsafe_test.v', 'vlib/v/tests/orm_sub_struct_test.v', + 'vlib/vweb/tests/vweb_test.v', 'vlib/x/websocket/websocket_test.v', - 'vlib/net/http/http_httpbin_test.v', ] skip_with_fsanitize_address = [ - 'vlib/encoding/base64/base64_test.v', 'vlib/encoding/csv/reader_test.v', - 'vlib/flag/flag_test.v', - 'vlib/io/util/util_test.v', - 'vlib/io/reader_test.v', + 'vlib/encoding/base64/base64_test.v', 'vlib/json/json_test.v', - 'vlib/net/http/cookie_test.v', - 'vlib/os/inode_test.v', - 'vlib/os/os_test.v', 'vlib/regex/regex_test.v', - 'vlib/semver/semver_test.v', 'vlib/sync/channel_opt_propagate_test.v', - 'vlib/time/parse_test.v', - 'vlib/v/fmt/fmt_keep_test.v', - 'vlib/v/fmt/fmt_test.v', - 'vlib/v/tests/array_init_test.v', - 'vlib/v/doc/doc_test.v', - 'vlib/v/tests/const_test.v', - 'vlib/v/tests/fn_multiple_returns_test.v', - 'vlib/v/tests/inout/compiler_test.v', - 'vlib/v/tests/option_default_values_test.v', - 'vlib/v/tests/option_test.v', 'vlib/v/tests/ptr_arithmetic_test.v', - 'vlib/v/tests/str_gen_test.v', 'vlib/v/tests/unsafe_test.v', - 'vlib/v/tests/vmod_parser_test.v', - 'vlib/v/vcache/vcache_test.v', - 'vlib/x/json2/decoder_test.v', 'vlib/x/websocket/websocket_test.v', ] skip_with_fsanitize_undefined = [ 'vlib/encoding/csv/reader_test.v', ] + skip_with_werror = [ + 'vlib/builtin/array_test.v', + 'vlib/clipboard/clipboard_test.v', + 'vlib/cli/command_test.v', + 'vlib/cli/flag_test.v', + 'vlib/dl/example/use_test.v', + 'vlib/eventbus/eventbus_test.v', + 'vlib/gx/color_test.v', + 'vlib/io/reader_test.v', + 'vlib/json/json_test.v', + 'vlib/math/big/big_test.v', + 'vlib/net/ftp/ftp_test.v', + 'vlib/net/http/cookie_test.v', + 'vlib/net/http/http_httpbin_test.v', + 'vlib/net/smtp/smtp_test.v', + 'vlib/net/http/http_test.v', + 'vlib/net/http/status_test.v', + 'vlib/net/tcp_simple_client_server_test.v', + 'vlib/net/tcp_test.v', + 'vlib/net/udp_test.v', + 'vlib/orm/orm_test.v', + 'vlib/os/os_test.v', + 'vlib/dl/dl_test.v', + 'vlib/rand/mt19937/mt19937_test.v', + 'vlib/readline/readline_test.v', + 'vlib/regex/regex_test.v', + 'vlib/sqlite/sqlite_test.v', + 'vlib/strconv/atof_test.v', + 'vlib/strconv/f32_f64_to_string_test.v', + 'vlib/strconv/number_to_base_test.v', + 'vlib/sync/channel_1_test.v', + 'vlib/sync/channel_2_test.v', + 'vlib/sync/atomic2/atomic_test.v', + 'vlib/sync/channel_3_test.v', + 'vlib/sync/channel_4_test.v', + 'vlib/sync/channel_array_mut_test.v', + 'vlib/sync/channel_close_test.v', + 'vlib/sync/channel_fill_test.v', + 'vlib/sync/channel_push_or_1_test.v', + 'vlib/sync/channel_polling_test.v', + 'vlib/sync/channel_opt_propagate_test.v', + 'vlib/sync/channel_push_or_2_test.v', + 'vlib/sync/channel_select_2_test.v', + 'vlib/sync/channel_select_3_test.v', + 'vlib/sync/channel_select_4_test.v', + 'vlib/sync/channel_select_5_test.v', + 'vlib/sync/channel_select_test.v', + 'vlib/sync/channel_select_6_test.v', + 'vlib/sync/channel_try_unbuf_test.v', + 'vlib/sync/channel_try_buf_test.v', + 'vlib/sync/select_close_test.v', + 'vlib/sync/struct_chan_init_test.v', + 'vlib/sync/pool_test.v', + 'vlib/szip/szip_test.v', + 'vlib/v/compiler_errors_test.v', + 'vlib/v/ast/walker/walker_test.v', + 'vlib/v/tests/anon_fn_test.v', + 'vlib/v/tests/array_map_ref_test.v', + 'vlib/v/tests/array_test.v', + 'vlib/v/tests/assert_sumtype_test.v', + 'vlib/v/tests/autolock_array1_test.v', + 'vlib/v/tests/autolock_array2_test.v', + 'vlib/v/tests/blank_ident_test.v', + 'vlib/v/tests/comptime_at_test.v', + 'vlib/v/tests/comptime_call_test.v', + 'vlib/v/tests/comptime_if_expr_test.v', + 'vlib/v/tests/cstrings_test.v', + 'vlib/v/tests/enum_test.v', + 'vlib/v/tests/fixed_array_test.v', + 'vlib/v/tests/fn_shared_return_test.v', + 'vlib/v/tests/for_loops_2_test.v', + 'vlib/v/tests/fn_variadic_test.v', + 'vlib/v/tests/generic_chan_test.v', + 'vlib/v/tests/generics_method_test.v', + 'vlib/v/tests/go_wait_1_test.v', + 'vlib/v/tests/go_call_generic_fn_test.v', + 'vlib/v/tests/generics_test.v', + 'vlib/v/tests/go_wait_2_test.v', + 'vlib/v/tests/go_wait_3_test.v', + 'vlib/v/tests/interface_edge_cases/array_of_interfaces_test.v', + 'vlib/v/tests/in_expression_test.v', + 'vlib/v/tests/interface_edge_cases/array_of_interfaces_with_utility_fn_test.v', + 'vlib/v/tests/interface_edge_cases/assign_to_interface_field_test.v', + 'vlib/v/tests/interface_edge_cases/i1_test.v', + 'vlib/v/tests/interface_edge_cases/i3_test.v', + 'vlib/v/tests/interface_edge_cases/i2_test.v', + 'vlib/v/tests/interface_edge_cases/i7_test.v', + 'vlib/v/tests/interface_struct_test.v', + 'vlib/v/tests/interface_fields_test.v', + 'vlib/v/tests/interface_variadic_test.v', + 'vlib/v/tests/interface_test.v', + 'vlib/v/tests/module_test.v', + 'vlib/v/tests/operator_overloading_with_string_interpolation_test.v', + 'vlib/v/tests/orm_sub_struct_test.v', + 'vlib/v/tests/repl/repl_test.v', + 'vlib/v/tests/semaphore_test.v', + 'vlib/v/tests/shared_arg_test.v', + 'vlib/v/tests/semaphore_timed_test.v', + 'vlib/v/tests/shared_array_test.v', + 'vlib/v/tests/shared_autolock_test.v', + 'vlib/v/tests/shared_lock_2_test.v', + 'vlib/v/tests/shared_lock_3_test.v', + 'vlib/v/tests/shared_fn_return_test.v', + 'vlib/v/tests/shared_lock_4_test.v', + 'vlib/v/tests/shared_lock_5_test.v', + 'vlib/v/tests/shared_lock_6_test.v', + 'vlib/v/tests/shared_lock_expr_test.v', + 'vlib/v/tests/shared_lock_test.v', + 'vlib/v/tests/shared_map_test.v', + 'vlib/v/tests/shared_unordered_mixed_test.v', + 'vlib/v/tests/shift_test.v', + 'vlib/v/tests/str_gen_test.v', + 'vlib/v/tests/string_interpolation_multi_return_test.v', + 'vlib/v/tests/struct_allow_both_field_defaults_and_skip_flag_test.v', + 'vlib/v/tests/string_interpolation_test.v', + 'vlib/v/tests/struct_test.v', + 'vlib/v/tests/sum_type_test.v', + 'vlib/v/tests/type_name_test.v', + 'vlib/v/tests/unsafe_test.v', + 'vlib/v/tests/voidptr_to_u64_cast_a_test.v', + 'vlib/v/tests/voidptr_to_u64_cast_b_test.v', + 'vlib/v/tests/working_with_an_empty_struct_test.v', + 'vlib/vweb/tests/vweb_test.v', + 'vlib/x/json2/any_test.v', + 'vlib/x/json2/json2_test.v', + 'vlib/x/json2/decoder_test.v', + 'vlib/x/websocket/websocket_test.v', + 'vlib/x/ttf/ttf_test.v' + ] skip_test_files = []string{} skip_on_musl = [ 'vlib/v/tests/profile/profile_test.v', @@ -104,10 +210,14 @@ fn main() { mut tsession := testing.new_test_session(cmd_prefix) tsession.files << all_test_files tsession.skip_files << skip_test_files + mut werror := false mut sanitize_memory := false mut sanitize_address := false mut sanitize_undefined := false for arg in args { + if '-Werror' in arg { + werror = true + } if '-fsanitize=memory' in arg { sanitize_memory = true } @@ -118,6 +228,9 @@ fn main() { sanitize_undefined = true } } + if werror { + tsession.skip_files << skip_with_werror + } if sanitize_memory { tsession.skip_files << skip_with_fsanitize_memory }