|
| 1 | +// This test ensures the -new-generic-solver option, and its corresponding compiler stage, will not regress silently, |
| 2 | +// as V continues to change. If you make changes to the generics stage to improve it, once you spot a failure here, or |
| 3 | +// some of the expected tests starts passing (which will be also a failure as far as this _test.v file is concerned), |
| 4 | +// you have to edit new_generics_regression_test.v, and remove the corresponding entry inside `failing_tests`. You also |
| 5 | +// need to update the summary line too, so that it matches the current result of running: |
| 6 | +// `./v -new-generic-solver test vlib/v/tests/generics/` |
| 7 | +// on your local working branch. |
| 8 | +// TODO: investigate what exact test fails on msvc only and record it in a separate skip list. |
| 9 | +// TODO: remove this test, once -new-generic-solver has improved so much, that it becomes the new default, since it is slow (~32s on m1). |
| 10 | +import os |
| 11 | +import log |
| 12 | + |
| 13 | +const vexe = @VEXE |
| 14 | +const vroot = @VROOT |
| 15 | +const vtrace_output = os.getenv('VTRACE_OUTPUT').int() != 0 |
| 16 | + |
| 17 | +fn testsuite_begin() { |
| 18 | + os.chdir(@VROOT)! |
| 19 | + os.setenv('VJOBS', '1', true) |
| 20 | + os.setenv('VCOLORS', 'never', true) |
| 21 | +} |
| 22 | + |
| 23 | +fn test_new_generic_solver_does_not_regress_silently() { |
| 24 | + new_generic_test_cmd := '${os.quoted_path(vexe)} -new-generic-solver test vlib/v/tests/generics/' |
| 25 | + log.info('>>> running ${new_generic_test_cmd} ...') |
| 26 | + res := os.execute(new_generic_test_cmd) |
| 27 | + log.info('>>> done running ${new_generic_test_cmd} ; exit_code: ${res.exit_code}') |
| 28 | + assert res.exit_code != 0 |
| 29 | + |
| 30 | + res_lines := res.output.split_into_lines() |
| 31 | + if vtrace_output { |
| 32 | + for tline in res_lines { |
| 33 | + eprintln('>>>>> tline: ${tline}') |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + ok_lines := res_lines.filter(it.starts_with('OK ')) |
| 38 | + failure_lines := res_lines.filter(it.starts_with(' FAIL')) |
| 39 | + summary_lines := res_lines.filter(it.starts_with('Summary')) |
| 40 | + |
| 41 | + for idx, known in failing_tests { |
| 42 | + found_expected_failure := failure_lines.any(it.contains(known)) |
| 43 | + assert found_expected_failure, 'expected failing test ${known} , was not found.\nRun `v -new-generic-solver test vlib/v/tests/generics/` manually to verify, and then edit ${@FILE} to reflect the new state.' |
| 44 | + |
| 45 | + if vtrace_output { |
| 46 | + eprintln('>>>>> found_expected_failure ${idx + 1} ${known}, OK') |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + actual_expected_summary := $if msvc { |
| 51 | + expected_summsvc |
| 52 | + } $else { |
| 53 | + expected_summary |
| 54 | + } |
| 55 | + |
| 56 | + if !summary_lines.any(it.contains(actual_expected_summary)) { |
| 57 | + eprintln('----------------------------------------------------------------') |
| 58 | + eprintln('----------------------------------------------------------------') |
| 59 | + eprintln('----------------------------------------------------------------') |
| 60 | + for tline in res_lines { |
| 61 | + eprintln('>>>>> tline: ${tline}') |
| 62 | + } |
| 63 | + eprintln('----------------------------------------------------------------') |
| 64 | + eprintln('----------------------------------------------------------------') |
| 65 | + eprintln('----------------------------------------------------------------') |
| 66 | + eprintln('Could not find the actual_expected_summary in: ${summary_lines}') |
| 67 | + eprintln('actual_expected_summary: ${actual_expected_summary}') |
| 68 | + exit(1) |
| 69 | + } |
| 70 | + log.info('>>> Found the expected summary: ${expected_summary}, OK') |
| 71 | +} |
| 72 | + |
| 73 | +const expected_summsvc = 'Summary for all V _test.v files: 53 failed, 208 passed, 261 total.' |
| 74 | +const expected_summary = 'Summary for all V _test.v files: 52 failed, 209 passed, 261 total.' |
| 75 | +const failing_tests = [ |
| 76 | + 'vlib/v/tests/generics/concrete_type_as_generic_fn_type_1_test.v', |
| 77 | + 'vlib/v/tests/generics/default_type_with_ref_test.v', |
| 78 | + 'vlib/v/tests/generics/generic_alias_callback_test.v', |
| 79 | + 'vlib/v/tests/generics/generic_anon_fn_inside_generic_fn_test.v', |
| 80 | + 'vlib/v/tests/generics/generic_array_init_test.v', |
| 81 | + 'vlib/v/tests/generics/generic_array_ret_test.v', |
| 82 | + 'vlib/v/tests/generics/generic_complex_sumtype_test.v', |
| 83 | + 'vlib/v/tests/generics/generic_comptime_arg_test.v', |
| 84 | + 'vlib/v/tests/generics/generic_comptime_test.v', |
| 85 | + 'vlib/v/tests/generics/generic_default_expression_in_or_block_test.v', |
| 86 | + 'vlib/v/tests/generics/generic_fn_infer_fixed_array_test.v', |
| 87 | + 'vlib/v/tests/generics/generic_fn_infer_multi_paras_test.v', |
| 88 | + 'vlib/v/tests/generics/generic_fn_type_with_different_generic_type_test.v', |
| 89 | + 'vlib/v/tests/generics/generic_fn_typeof_name_test.v', |
| 90 | + 'vlib/v/tests/generics/generic_fn_with_comptime_for_test.v', |
| 91 | + 'vlib/v/tests/generics/generic_map_alias_test.v', |
| 92 | + 'vlib/v/tests/generics/generic_muls_test.v', |
| 93 | + 'vlib/v/tests/generics/generic_operator_overload_test.v', |
| 94 | + 'vlib/v/tests/generics/generic_options_with_reserved_ident_test.v', |
| 95 | + 'vlib/v/tests/generics/generic_receiver_embed_test.v', |
| 96 | + 'vlib/v/tests/generics/generic_resolve_test.v', |
| 97 | + 'vlib/v/tests/generics/generic_return_test.v', |
| 98 | + 'vlib/v/tests/generics/generic_selector_field_test.v', |
| 99 | + 'vlib/v/tests/generics/generic_selector_len_test.v', |
| 100 | + 'vlib/v/tests/generics/generic_spawn_test.v', |
| 101 | + 'vlib/v/tests/generics/generic_static_call_test.v', |
| 102 | + 'vlib/v/tests/generics/generic_struct_cstruct_test.v', |
| 103 | + 'vlib/v/tests/generics/generic_struct_test.v', |
| 104 | + 'vlib/v/tests/generics/generic_sumtype_cast_test.v', |
| 105 | + 'vlib/v/tests/generics/generic_sumtype_str_test.v', |
| 106 | + 'vlib/v/tests/generics/generic_sumtype_test.v', |
| 107 | + 'vlib/v/tests/generics/generic_typeof_idx_test.v', |
| 108 | + 'vlib/v/tests/generics/generic_typeof_test.v', |
| 109 | + 'vlib/v/tests/generics/generics_array_of_threads_test.v', |
| 110 | + 'vlib/v/tests/generics/generics_closure_fn_direct_call_test.v', |
| 111 | + 'vlib/v/tests/generics/generics_closure_fn_test.v', |
| 112 | + 'vlib/v/tests/generics/generics_closures_with_different_generic_types_test.v', |
| 113 | + 'vlib/v/tests/generics/generics_fn_variable_1_test.v', |
| 114 | + 'vlib/v/tests/generics/generics_fn_variable_2_test.v', |
| 115 | + 'vlib/v/tests/generics/generics_fn_variable_3_test.v', |
| 116 | + 'vlib/v/tests/generics/generics_for_in_iterate_test.v', |
| 117 | + 'vlib/v/tests/generics/generics_interface_method_test.v', |
| 118 | + 'vlib/v/tests/generics/generics_interface_with_generic_method_using_generic_struct_test.v', |
| 119 | + 'vlib/v/tests/generics/generics_interface_with_generic_sumtype_test.v', |
| 120 | + 'vlib/v/tests/generics/generics_map_with_reference_arg_test.v', |
| 121 | + 'vlib/v/tests/generics/generics_method_chaining_call_test.v', |
| 122 | + 'vlib/v/tests/generics/generics_method_with_sumtype_args_test.v', |
| 123 | + 'vlib/v/tests/generics/generics_return_closure_test.v', |
| 124 | + 'vlib/v/tests/generics/generics_struct_field_with_default_fn_type_test.v', |
| 125 | + 'vlib/v/tests/generics/generics_struct_with_inconsistent_generic_types_1_test.v', |
| 126 | + 'vlib/v/tests/generics/generics_test.v', |
| 127 | + 'vlib/v/tests/generics/generics_with_generics_fn_return_generics_map_type_test.v', |
| 128 | +]! |
0 commit comments