From ca3e49b907caea7bb72d0cd0d782f165a283cc9b Mon Sep 17 00:00:00 2001 From: Matt Jolly Date: Sun, 19 Jan 2025 13:49:09 +1000 Subject: [PATCH] meson: auto test case script, update checked in test/meson.build --- test/meson.build | 1422 ++++++++++++++++++------- test/src/generate_meson_test_cases.py | 120 ++- 2 files changed, 1128 insertions(+), 414 deletions(-) mode change 100644 => 100755 test/src/generate_meson_test_cases.py diff --git a/test/meson.build b/test/meson.build index ed1a015bc..b1f1dca97 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,545 +1,1138 @@ +# This file can be regenerated with generate_meson_test_cases.py + py3 = find_program('python3', required: true) test_args = ['../test/src/check.py', '../test/src/tester.py', c3c_exe] -# Define the test suites so that we can programmatically generate the tests - abi = [ - 'aarch64_args', - 'aarch64_hfa_args', - 'avx512fp16-abi', - 'darwin_arg', - 'darwin_return_boolarray', - 'darwin64_avx', - 'darwin64_avx512', - 'darwin64_sret', - 'darwin64_sse', - 'darwinx64_1', - 'darwinx64_2', - 'literal_load_aarch64', - 'literal_load_mingw', - 'literal_load', - 'macho_section', - 'pass_large_aarch', - 'riscv32-ilp32-abi', - 'riscv32-ilp32-ilp32f-abi-1', - 'riscv32-ilp32-ilp32f-abi-2', - 'riscv32-ilp32-ilp32f-ilp32d-abi-1', - 'riscv32-ilp32-ilp32f-ilp32d-abi-2', - 'riscv32-ilp32-ilp32f-ilp32d-abi-3', - 'riscv32-ilp32d-abi', - 'riscv32-ilp32f-abi', - 'riscv32-ilp32f-ilp32d-abi-1', - 'riscv32-ilp32f-ilp32d-abi-2', - 'riscv64-lp64-abi', - 'riscv64-lp64-lp64f-abi-1', - 'riscv64-lp64-lp64f-abi-2', - 'riscv64-lp64-lp64f-lp64d-abi-1', - 'riscv64-lp64-lp64f-lp64d-abi-2', - 'riscv64-lp64-lp64f-lp64d-abi-3', - 'riscv64-lp64d-abi', - 'riscv64-lp64f-lp64d-abi-1', - 'riscv64-lp64f-lp64d-abi-2', - 'small_struct_x64', - 'sysv_abi_avx', - 'sysv_abi_noavx', - 'sysv_direct_coerce', - 'test_sret', - 'union_x64', - 'vec2_aarch64', - 'vec2_wasm', - 'vec2_x64', - 'wasm_extern', - 'x64alignarray', -] - -any = ['any_in_any', 'variant_assign', 'variant_switch', 'variant_test'] + 'aarch64_args.c3t', + 'aarch64_hfa_args.c3t', + 'aarch_ret_small_struct.c3t', + 'avx512fp16-abi.c3t', + 'darwin64_avx.c3t', + 'darwin64_avx512.c3t', + 'darwin64_sret.c3t', + 'darwin64_sse.c3t', + 'darwin_arg.c3t', + 'darwin_return_boolarray.c3t', + 'darwinx64_1.c3t', + 'darwinx64_2.c3t', + 'linking_extern.c3t', + 'literal_load.c3t', + 'literal_load_aarch64.c3t', + 'literal_load_mingw.c3t', + 'macho_section.c3t', + 'macho_section_attributes.c3', + 'pass_large_aarch.c3t', + 'riscv32-ilp32-abi.c3t', + 'riscv32-ilp32-ilp32f-abi-1.c3t', + 'riscv32-ilp32-ilp32f-abi-2.c3t', + 'riscv32-ilp32-ilp32f-ilp32d-abi-1.c3t', + 'riscv32-ilp32-ilp32f-ilp32d-abi-2.c3t', + 'riscv32-ilp32-ilp32f-ilp32d-abi-3.c3t', + 'riscv32-ilp32d-abi.c3t', + 'riscv32-ilp32f-abi.c3t', + 'riscv32-ilp32f-ilp32d-abi-1.c3t', + 'riscv32-ilp32f-ilp32d-abi-2.c3t', + 'riscv64-lp64-abi.c3t', + 'riscv64-lp64-lp64f-abi-1.c3t', + 'riscv64-lp64-lp64f-abi-2.c3t', + 'riscv64-lp64-lp64f-lp64d-abi-1.c3t', + 'riscv64-lp64-lp64f-lp64d-abi-2.c3t', + 'riscv64-lp64-lp64f-lp64d-abi-3.c3t', + 'riscv64-lp64d-abi.c3t', + 'riscv64-lp64f-lp64d-abi-1.c3t', + 'riscv64-lp64f-lp64d-abi-2.c3t', + 'small_struct_x64.c3t', + 'sysv_abi_avx.c3t', + 'sysv_abi_noavx.c3t', + 'sysv_direct_coerce.c3t', + 'test_sret.c3t', + 'union_x64.c3t', + 'vec2_aarch64.c3t', + 'vec2_wasm.c3t', + 'vec2_x64.c3t', + 'wasm_extern.c3t', + 'x64alignarray.c3t', +] + +any = [ + 'any_in_any.c3t', + 'casting_voidptr_to_any.c3', + 'interface_no_fn.c3', + 'interface_no_method_body_1536.c3', + 'interface_ptr.c3', + 'variant_assign.c3t', + 'variant_switch.c3t', + 'variant_test.c3t', +] arrays = [ - 'array_bounds_check', - 'array_casts', - 'array_comparison_2', - 'array_comparison', - 'array_literal', - 'array_struct', - 'complex_array_const', - 'complex_inferred_array', - 'global_init', - 'index_from_back', - 'index_into_global', - 'inferred_array_optional', + 'array_bounds_check.c3t', + 'array_casts.c3t', + 'array_comparison.c3t', + 'array_comparison_2.c3t', + 'array_indexing.c3', + 'array_invalid_casts.c3', + 'array_literal.c3t', + 'array_struct.c3t', + 'complex_array_const.c3t', + 'complex_inferred_array.c3t', + 'global_array_non_const.c3', + 'global_init.c3t', + 'global_init_array_out_of_range.c3', + 'index_from_back.c3t', + 'index_into_global.c3t', + 'inferred_array_err.c3', + 'inferred_array_err2.c3', + 'inferred_array_optional.c3t', + 'inferred_subarray.c3', + 'negative_array.c3', + 'slice.c3', ] asm = [ - 'asm_ops_x64_1', - 'asm_ops_x64_2', - 'asm_regression', - 'naked', - 'sideeffect', - 'syscall', + 'asm_bit_rv.c3t', + 'asm_imm_err_rv.c3', + 'asm_intr_rv.c3t', + 'asm_jump_rv.c3t', + 'asm_load_rv.c3t', + 'asm_load_rv64.c3t', + 'asm_math_rv.c3t', + 'asm_ops_x64_1.c3t', + 'asm_ops_x64_2.c3t', + 'asm_regression.c3t', + 'asm_set_rv.c3t', + 'asm_shift_rv.c3t', + 'asm_store_rv.c3t', + 'naked.c3t', + 'sideeffect.c3t', + 'syscall.c3t', ] assert = [ - 'assert_variants', - 'assertf', - 'unreachable', + 'assert_variants.c3t', + 'assert_with_void.c3', + 'assertf.c3t', + 'global_static_assert_not_constant.c3', + 'local_static_assert_not_constant.c3', + 'static_assert.c3', + 'unreachable.c3t', + 'unreachable_in_macro.c3t', ] assignment = [ - 'alignment_index', - 'int_assign', - 'var_variable', + 'alignment_index.c3t', + 'int_assign.c3t', + 'var_variable.c3t', ] attributes = [ - 'attribute_visibility', - 'user_defined_attributes', + 'attr_link_err.c3', + 'attr_not_imported.c3', + 'attribute_params.c3', + 'attribute_path.c3', + 'attribute_visibility.c3t', + 'attributes_repeat_param.c3t', + 'call_attribute_error_eos.c3', + 'recursive_attributes.c3', + 'user_defined_attributes.c3t', + 'wasm_import.c3t', + 'wasm_module.c3', ] bitstruct = [ - 'array_with_boolean', - 'bitfield_access', - 'bitstruct_access_signed', - 'bitstruct_anon_in_struct_ok', - 'bitstruct_arrays_be', - 'bitstruct_arrays', - 'bitstruct_be', - 'bitstruct_cast_const_init', - 'bitstruct_in_subarray', - 'bitstruct_init_bool', - 'bitstruct_initializer', - 'bitstruct_intcontainer', - 'bitstruct_ops', - 'bitstruct_to_int', - 'designated_initializer_with_bitstruct', - 'embedded_bitstruct', - 'param_bitstruct', + 'address_of_bitstruct.c3', + 'anon_bitstruct_name_overlap.c3', + 'array_with_boolean.c3t', + 'bistruct_cast_wrong_size.c3', + 'bitfield_access.c3t', + 'bitstruct_access_signed.c3t', + 'bitstruct_anon_in_struct_ok.c3t', + 'bitstruct_arrays.c3t', + 'bitstruct_arrays_be.c3t', + 'bitstruct_be.c3t', + 'bitstruct_bool.c3t', + 'bitstruct_cast_and_back.c3', + 'bitstruct_cast_const_init.c3t', + 'bitstruct_direct_in_struct.c3t', + 'bitstruct_general.c3', + 'bitstruct_in_subarray.c3t', + 'bitstruct_init.c3', + 'bitstruct_init_bool.c3t', + 'bitstruct_initializer.c3t', + 'bitstruct_intcontainer.c3t', + 'bitstruct_ops.c3t', + 'bitstruct_overlap.c3', + 'bitstruct_simple.c3', + 'bitstruct_simple_err_decl.c3', + 'bitstruct_single_error.c3', + 'bitstruct_to_int.c3t', + 'designated_initializer_with_bitstruct.c3t', + 'embedded_bitstruct.c3t', + 'invalid_bitstruct_member_types.c3', + 'invalid_bitstruct_name_other_ident.c3', + 'invalid_bitstruct_type.c3', + 'invalid_empty_struct_union.c3', + 'missing_bitstruct_type.c3', + 'param_bitstruct.c3t', ] builtins = [ - 'builtin_vector_abs', - 'builtin_vector_min_max', - 'exacts', - 'mem', - 'overflows', - 'prefetch', - 'reduce_arithmetics', - 'reverse_builtin', - 'rounding_builtins', - 'sat_builtins', - 'shufflevector', - 'simple_builtins', + 'builtin_vector_abs.c3t', + 'builtin_vector_min_max.c3t', + 'builtin_with_optional.c3', + 'exacts.c3t', + 'mem.c3t', + 'overflows.c3t', + 'prefetch.c3t', + 'reduce_arithmetics.c3t', + 'reverse_builtin.c3t', + 'rounding_builtins.c3t', + 'sat_builtins.c3t', + 'shufflevector.c3t', + 'simple_builtins.c3t', + 'trap.c3t', + 'unaligned_load_store.c3t', ] cast = [ - 'cast_bitstruct_etc', - 'cast_from_ptr', - 'cast_narrow_alias', - 'cast_subarray', - 'implicit_infer_len_cast', - 'top_down_casts', + 'cast_bitstruct_etc.c3t', + 'cast_from_ptr.c3t', + 'cast_narrow_alias.c3t', + 'cast_ok.c3', + 'cast_parse_fails.c3', + 'cast_parse_fails2.c3', + 'cast_ptr_vec_to_bool.c3t', + 'cast_rcast.c3', + 'cast_slice_implicit.c3', + 'cast_string_to_infered_array.c3', + 'cast_struct.c3', + 'cast_struct_fails.c3', + 'cast_subarray.c3t', + 'cast_to_failable.c3', + 'cast_untyped_list_error.c3', + 'implicit_array_ptr_conv.c3', + 'implicit_infer_len_cast.c3t', + 'implicit_void_ptr_deep.c3', + 'inner_type_cast.c3', + 'top_down_cast_fails.c3', + 'top_down_casts.c3t', ] clang = [ - '2002-01_02', - '2002-03', - '2002-04', - '2002-07', + '2002-01_02.c3t', + '2002-03.c3t', + '2002-04.c3t', + '2002-07.c3t', +] + +comments = [ + 'simple_comments.c3', ] compile_time = [ - 'compile_time_access_subscript', - 'compile_time_array_ref', - 'compile_time_array', - 'compile_time_bitops', - 'compile_time_pointers', - 'compile_time_ptr_ref', - 'ct_builtin_time_date', - 'ct_enum_values', - 'ct_eval', - 'ct_for', - 'ct_foreach', - 'ct_func', - 'ct_funcptr', - 'ct_if', - 'ct_memberof', - 'ct_switch_top_level', - 'ct_switch_type_check', - 'ct_switch', - 'ct_through_constant', - 'ct_value_from_access', - 'cttype_reassign', - 'stringify', - 'stringify2', - 'ternary_folding', - 'typed_ct_vars', - 'typefrom_errors', - 'typefrom', - 'typeof_example', - 'untyped_conversions', + 'add_to_ct_undefined.c3', + 'compile_time_access_subscript.c3t', + 'compile_time_array.c3t', + 'compile_time_array_ref.c3t', + 'compile_time_bitops.c3t', + 'compile_time_pointers.c3t', + 'compile_time_ptr_ref.c3t', + 'compile_time_utf32.c3', + 'comptime_array_folding.c3t', + 'concat_append.c3t', + 'concat_slice_array.c3', + 'concat_slice_bytes.c3t', + 'concat_test.c3t', + 'concat_test_cases.c3', + 'ct_and_or.c3', + 'ct_assert_bug.c3', + 'ct_builtin_time_date.c3t', + 'ct_else_else.c3', + 'ct_enum_values.c3t', + 'ct_eval.c3t', + 'ct_eval_sym.c3', + 'ct_eval_wrong.c3', + 'ct_for.c3t', + 'ct_foreach.c3t', + 'ct_func.c3t', + 'ct_funcptr.c3t', + 'ct_if.c3t', + 'ct_if_folding.c3t', + 'ct_memberof.c3t', + 'ct_ordered_error.c3t', + 'ct_string_functions.c3t', + 'ct_switch.c3t', + 'ct_switch_errors.c3', + 'ct_switch_more_checks.c3', + 'ct_switch_top_level.c3t', + 'ct_switch_type_check.c3t', + 'ct_switch_type_errors.c3', + 'ct_through_constant.c3t', + 'ct_value_from_access.c3t', + 'cttype_reassign.c3t', + 'macro_compile_time_pseudo_evaluation.c3t', + 'mod_ct.c3t', + 'mod_in_other_scope.c3', + 'not_cost.c3', + 'not_yet_initialized.c3', + 'stringify.c3t', + 'stringify2.c3t', + 'ternary_folding.c3t', + 'typed_ct_vars.c3t', + 'typefrom.c3t', + 'typefrom_errors.c3t', + 'typeof_example.c3t', + 'typeof_from_literal.c3', + 'untyped_conversions.c3t', + 'untyped_with_inferred.c3', + 'deep_stringify.c3t', ] compile_time_introspection = [ - 'alignof', - 'defined', - 'defined_2', - 'defined_builtin', - 'nameof', - 'offsetof', - 'parentof', - 'qnameof', - 'sizeof', + 'alignof.c3t', + 'defined.c3t', + 'defined2.c3', + 'defined_2.c3t', + 'defined_builtin.c3t', + 'defined_err.c3', + 'defined_index.c3t', + 'defined_subscript.c3', + 'nameof.c3t', + 'nameof_err.c3', + 'offsetof.c3t', + 'paramsof.c3t', + 'parentof.c3t', + 'qnameof.c3t', + 'recursive_tag.c3', + 'sizeof.c3t', + 'sizeof_errors.c3', + 'tag.c3t', + 'tag_1343.c3t', ] -concurrency = ['atomic_load_store_debug', 'atomic_load_store'] +concurrency = [ + 'atomic_load_store.c3t', + 'atomic_load_store_debug.c3t', +] constants = [ - 'byte_literals', - 'char_literals', - 'const_var_copy', - 'constants', - 'float_type', - 'init_order', + 'assign_to_const.c3', + 'byte_literal_fail_base64.c3', + 'byte_literal_fail_base64_2.c3', + 'byte_literal_fail_base64_4.c3', + 'byte_literal_fail_hex.c3', + 'byte_literals.c3t', + 'char_literals.c3t', + 'const_var_copy.c3t', + 'constant_struct.c3', + 'constants.c3t', + 'empty_byte_literal.c3', + 'float_type.c3t', + 'init_order.c3t', ] contracts = [ - 'simple_test' + 'constant_out.c3', + 'ct_eval_of_ensure.c3', + 'ensure_unsigned.c3', + 'in_array.c3', + 'in_out.c3', + 'macro_ensure_static.c3', + 'out_subscript.c3', + 'pure.c3', + 'pure_calls.c3', + 'require_contract_loc.c3', + 'simple_test.c3t', ] debug_symbols = [ - 'constants_mingw', - 'constants', + 'constants.c3t', + 'constants_mingw.c3t', + 'ct_foreach.c3t', + 'defer_macro.c3t', + 'foreach.c3t', ] defer = [ - 'defer_and_expr_block', - 'defer_catch_try', - 'defer_static_var', + 'defer_and_expr_block.c3t', + 'defer_catch_direct_error.c3t', + 'defer_catch_err.c3t', + 'defer_catch_mix.c3t', + 'defer_catch_try.c3t', + 'defer_nextcase.c3t', + 'defer_single_stmt.c3', + 'defer_static_var.c3t', + 'defer_try_catch.c3t', + 'defer_with_catch.c3t', + 'defer_with_rethrow.c3', + 'defer_with_return.c3', +] + +define = [ + 'alias_typename.c3', + 'aliased_consts.c3t', + 'common.c3', + 'common2.c3', + 'define_name_errors.c3', + 'forbidden_defines.c3', + 'test_at.c3', + 'test_at_alias.c3', + 'weak_alias_fails.c3', + 'weak_aliases.c3', ] distinct = [ - 'distinct_shift', + 'disntinct_add_fail.c3', + 'distinct_add.c3', + 'distinct_function.c3t', + 'distinct_function_call.c3', + 'distinct_inline_access.c3', + 'distinct_invalid.c3', + 'distinct_shift.c3t', + 'distinct_slicing.c3', + 'distinct_struct.c3', + 'distinct_struct_array.c3', + 'distinct_sub.c3t', + 'distinct_union.c3', + 'test_errors.c3', + 'test_ops_on_int.c3', + 'test_ops_on_struct.c3', ] dynamic = [ - 'inherit_linux', - 'inherit_macos', - 'null_and_protocol', - 'overlapping_function_linux', - 'overlapping_function_macos', + 'any_cast.c3', + 'duplicate_definition.c3', + 'dynamic_inherit_deep.c3t', + 'dynamic_mismatch.c3', + 'dynamic_tracing.c3t', + 'inherit_linux.c3t', + 'inherit_macos.c3t', + 'inline_protocol.c3', + 'null_and_protocol.c3t', + 'overlapping_function_linux.c3t', + 'overlapping_function_macos.c3t', + 'same_method_twice.c3', ] embed = [ - 'embed_basic', + 'embed_basic.c3t', ] enumerations = [ - 'enum_add_sub', - 'enum_associated_value', - 'enum_associated_values_other', - 'enum_cast', - 'enum_conversions', - 'enum_reflect_associated', - 'enum_values', - 'simple_inference', + 'compile_time.c3t', + 'enum_add_sub.c3t', + 'enum_associated_value.c3t', + 'enum_associated_values_other.c3t', + 'enum_cast.c3t', + 'enum_cast_error.c3', + 'enum_conversions.c3t', + 'enum_invalid_param.c3', + 'enum_reflect_associated.c3t', + 'enum_same_param.c3', + 'enum_signed_cast_swap.c3t', + 'enum_values.c3t', + 'enum_with_const.c3t', + 'inc_assign.c3t', + 'inc_assign_fail.c3', + 'introspection_data_error.c3t', + 'missing_type.c3', + 'simple_inference.c3t', + 'enum_with_associated_value_decl.c3', ] errors = [ - 'anyfault_void', - 'else_checks', - 'error_else', - 'error_introspect', - 'error_regression_2', - 'failable_catch', - 'general_error_regression', - 'macro_err', - 'macro_err2', - 'macro_err3', - 'multiple_catch', - 'optional_chained_init', - 'optional_inits', - 'optional_taddr_and_access', - 'optional_with_optional', - 'or_and_rethrow', - 'or_err_bool', - 'printing_errors', - 'rethrow_mingw', - 'rethrow', - 'simple_static_failable', - 'try_assign', - 'try_catch_if', - 'try_expr', - 'try_with_chained_unwrap', - 'try_with_unwrap', - 'try_with_unwrapper', + 'anyfault_void.c3t', + 'bitshift_failable.c3', + 'else_checks.c3t', + 'else_struct.c3t', + 'empty_fault.c3', + 'error_decl_ok.c3', + 'error_else.c3t', + 'error_introspect.c3t', + 'error_regression_2.c3t', + 'error_semantic_fails.c3', + 'error_throw.c3', + 'error_union.c3', + 'failable_catch.c3t', + 'fault_conv.c3t', + 'general_error_regression.c3t', + 'illegal_use_of_optional.c3', + 'invalid_cast_ct.c3', + 'lone_try.c3', + 'macro_err.c3t', + 'macro_err2.c3t', + 'macro_err3.c3t', + 'macro_recurse_twice.c3', + 'missing_bang.c3', + 'mixed_decl.c3', + 'more_optional_discard.c3', + 'more_optional_tests.c3', + 'multiple_catch.c3t', + 'no_common.c3', + 'optional_chained_init.c3t', + 'optional_contracts.c3', + 'optional_designated.c3', + 'optional_discarded_func.c3', + 'optional_discarded_macro.c3', + 'optional_inits.c3t', + 'optional_sizeof.c3', + 'optional_taddr_and_access.c3t', + 'optional_untyped_list.c3', + 'optional_with_optional.c3t', + 'or_and_rethrow.c3t', + 'or_err_bool.c3t', + 'precedence_err.c3', + 'printing_errors.c3t', + 'rethrow.c3t', + 'rethrow_macro.c3', + 'rethrow_mingw.c3t', + 'rethrow_no_err.c3', + 'simple_static_failable.c3t', + 'ternary_void_fault.c3t', + 'try_assign.c3t', + 'try_catch_if.c3t', + 'try_catch_unwrapping_while_if.c3', + 'try_expr.c3t', + 'try_unwrap_using_assert.c3', + 'try_with_assign_to_failable.c3', + 'try_with_chained_unwrap.c3t', + 'try_with_chained_unwrap_errors.c3', + 'try_with_unwrap.c3t', + 'try_with_unwrapper.c3t', + 'try_with_weird_stuff.c3', + 'type_optional_declaration_order.c3', +] + +examples = [ + 'gameoflife.c3', +] +expression_block = [ + 'expr_block_labelled_break.c3', + 'expr_block_no_assign.c3', + 'expression_block_break.c3', + 'expression_block_no_end_return.c3', ] expressions = [ - 'casts/cast_expr', # Odd one out, should probably handle properly one day but this is fine for now. - '2002-02-13-ConditionalInCall', - 'addr_compiles', - 'assignment_precedence', - 'bit_op_on_bool', - 'bool_conversions', - 'call_inline', - 'chained_conditional', - 'chained_ternary', - 'check_implict_conversion_signed_unsigned', - 'elvis', - 'enum_ct_sub', - 'fmuladd_err', - 'fmuladd', - 'folding_ptr', - 'incdec', - 'optional_ternary', - 'parsed_numbers', - 'pointer_access', - 'simple_float_sub_neg', - 'strings', - 'take_address', - 'ternary_bool', - 'type_support', + '2002-02-13-ConditionalInCall.c3t', + 'addr_compiles.c3t', + 'addr_of_fails.c3', + 'arithmetics.c3', + 'arithmetics_sema_fail.c3', + 'assign.c3', + 'assign_deref_opt.c3', + 'assign_optional.c3t', + 'assign_to_address.c3', + 'assignability.c3', + 'assignment_precedence.c3t', + 'bit_op_on_bool.c3t', + 'bool_conversions.c3t', + 'call_arg_types.c3', + 'call_inline.c3t', + 'chained_conditional.c3t', + 'chained_ternary.c3t', + 'check_implict_conversion_signed_unsigned.c3t', + 'deref_access_null.c3t', + 'elvis.c3t', + 'enum_ct_sub.c3t', + 'fail_index_usize.c3', + 'fmuladd.c3t', + 'fmuladd_err.c3t', + 'folding_ptr.c3t', + 'incdec.c3t', + 'incdec_overload.c3t', + 'negate_int.c3', + 'negated_macro.c3t', + 'no_valid_conversion_minus.c3', + 'not_in_wrong_position.c3', + 'optional_and_error.c3', + 'optional_ternary.c3t', + 'parsed_numbers.c3t', + 'plus_int.c3', + 'pointer_access.c3t', + 'pointer_arith.c3', + 'pointer_conv_error.c3', + 'pointer_to_bool.c3', + 'rvalues.c3', + 'simple_float_sub_neg.c3t', + 'strings.c3t', + 'take_address.c3t', + 'ternary_bool.c3t', + 'ternary_infer.c3t', + 'ternary_no_ident.c3', + 'ternary_void.c3t', + 'test_ct_param_bug.c3', + 'type_support.c3t', + 'underscore_errors.c3', + 'unsafe_comparisons.c3', + 'void_arg.c3', + 'casts/cast_const.c3', + 'casts/cast_enum_const_to_distinct.c3', + 'casts/cast_enum_to_various.c3', + 'casts/cast_expr.c3t', + 'casts/cast_failable.c3', + 'casts/cast_func_to_various.c3', + 'casts/cast_implicit_inline_distinct.c3', + 'casts/cast_to_nonscalar.c3', + 'casts/cast_unknown.c3', + 'casts/cast_vector_fail.c3', + 'casts/enum_plus_minus.c3t', + 'casts/explicit_cast.c3', + 'casts/failed_distinct_float_conversions.c3', + 'casts/narrowing.c3', + 'casts/narrowing_through_casts.c3', + 'casts/struct_cast_and_distinct.c3', + 'casts/void_casting.c3', ] floats = [ - 'convert_float', - 'inf_nan', - 'mod', + 'convert_float.c3t', + 'explicit_float_truncation_needed.c3', + 'float_exceeding_size.c3', + 'inf_nan.c3t', + 'mod.c3t', ] from_docs = [ - 'examples_defer', - 'examples_forswitch', - 'examples_functionpointer', - 'examples_if_catch', - 'examples_macro_function', + 'examples_defer.c3t', + 'examples_forswitch.c3t', + 'examples_functionpointer.c3t', + 'examples_if_catch.c3t', + 'examples_macro_function.c3t', + 'examples_struct.c3', ] functions = [ - 'assorted_tests', - 'c_vararg_expansion', - 'defered_default_arguments', - 'distinct_fn_ptr_and_lambda', - 'func_ptr_conversion_alias', - 'func_ptr_conversions_and_names', - 'naked_function', - 'returning_void', - 'simple_test', - 'splat_aarch64', - 'splat_mingw', - 'splat', - 'static_vars', - 'test_regression_mingw', - 'test_regression', - 'typeless_varargs', - 'varargs_followed_by_named', - 'varargs', + 'accidental_method_1448.c3', + 'after_vararg.c3', + 'assorted_tests.c3t', + 'body_argument_fail.c3', + 'c_vararg_expansion.c3t', + 'ct_named_params.c3t', + 'default_param_fail.c3', + 'defered_default_arguments.c3t', + 'distinct_fn_ptr_and_lambda.c3t', + 'double_return.c3', + 'failable_param.c3', + 'func_ptr_conversion_alias.c3t', + 'func_ptr_conversions_and_names.c3t', + 'func_ptr_null.check.c3t', + 'function_alias_llvm_check.c3t', + 'function_reserved_name.c3', + 'invalid_param.c3', + 'macro_arguments.c3', + 'macro_expr_type.c3', + 'missing_first_paren.c3', + 'missing_fn.c3', + 'missing_return.c3', + 'multisplat.c3t', + 'naked_function.c3t', + 'named_arg_order.c3', + 'param_doc_error.c3', + 'param_with_comma_at_end.c3', + 'pointer_escape.c3', + 'raw_splat.c3t', + 'recursive_fn.c3', + 'recursive_through_generic.c3', + 'returning_void.c3t', + 'simple_test.c3t', + 'splat.c3t', + 'splat_aarch64.c3t', + 'splat_empty.c3t', + 'splat_init.c3t', + 'splat_mingw.c3t', + 'splat_post_order.c3t', + 'splat_raw.c3', + 'splat_untyped.c3t', + 'static_vars.c3t', + 'test_regression.c3t', + 'test_regression_mingw.c3t', + 'too_many_params.c3', + 'type_argument_live_1461.c3t', + 'typeless_varargs.c3t', + 'unsplat_named.c3', + 'vaarg_raw.c3', + 'vararg_and_named_tests.c3', + 'vararg_argument_fails.c3', + 'varargs.c3t', + 'varargs_followed_by_named.c3t', + 'void_params.c3', ] generic = [ - 'enum_set_test', - 'generic_copy', - 'generic_idents', - 'generic_lambda_complex', - 'generic_num', - 'generic_over_fn', - 'generic_recursion', - 'generic_with_enum', + 'enum_in_other_module.c3t', + 'enum_set_test.c3t', + 'generic_builtin.c3t', + 'generic_copy.c3t', + 'generic_cyclic.c3', + 'generic_idents.c3t', + 'generic_interface.c3t', + 'generic_lambda_complex.c3t', + 'generic_local.c3', + 'generic_num.c3t', + 'generic_over_fn.c3t', + 'generic_recursion.c3t', + 'generic_resolution_1402.c3t', + 'generic_void.c3t', + 'generic_with_comment.c3t', + 'generic_with_enum.c3t', + 'generic_without_param.c3', + 'implicit_import_of_generic.c3', + 'incorrect_argument_type.c3', + 'nested_typedef.c3t', + 'used_without_param.c3', + 'used_without_param2.c3', + 'used_without_param3.c3', ] globals = [ - 'external_global', - 'global_align', - 'global_extname', - 'global_no_init', - 'init_with_err', + 'ext_global_init.c3', + 'extern_const.c3t', + 'external_global.c3t', + 'global_align.c3t', + 'global_extname.c3t', + 'global_init.c3', + 'global_no_init.c3t', + 'init_with_err.c3t', + 'misplaced_const.c3', + 'recursive_globals.c3', + 'recursive_locals.c3', + 'self_referencing_local.c3', + 'static_global.c3', ] import = [ - 'access_other_module', - 'import_works', + 'access_other_module.c3t', + 'autoimport.c3', + 'import_error.c3', + 'import_error_multi.c3', + 'import_error_string.c3', + 'import_implicit.c3', + 'import_nonrecurse.c3', + 'import_same.c3', + 'import_twice.c3', + 'import_works.c3t', ] initialize = [ - 'initializer_var', - 'initialize_finalize', + 'init_non_resolved_type.c3', + 'initialize_bad_prio.c3', + 'initialize_finalize.c3t', + 'initialize_jump.c3', + 'initialize_parse_error.c3', + 'initialize_prio.c3', + 'initializer_var.c3t', ] initializer_lists = [ - 'fasta', - 'general_tests', - 'ranges_to_dynamic', - 'statics', - 'subarrays', - 'zero_init', + 'disallowed_lists.c3', + 'fasta.c3t', + 'general_tests.c3t', + 'indexing_into_complist.c3', + 'infer_with_init.c3t', + 'init_any_interface.c3', + 'initializers_to_macros.c3', + 'ranges_to_dynamic.c3t', + 'statics.c3t', + 'subarrays.c3t', + 'zero_inferred_array.c3', + 'zero_init.c3t', ] lambda = [ - 'ct_lambda', - 'ct_lambda2', - 'lambda_in_macro', - 'nested_lambda_def', - 'simple_lambda', + 'ct_lambda.c3t', + 'ct_lambda2.c3t', + 'lambda_checks.c3', + 'lambda_in_macro.c3t', + 'lambda_ref.c3t', + 'nested_lambda_def.c3t', + 'simple_lambda.c3t', + 'var_lambda.c3', +] + +lexing = [ + 'expected_directive.c3', + 'invalid_hex_in_hexarray.c3', + 'invalid_hex_in_hexarray2.c3', + 'no_builtin.c3', ] literals = [ - 'bin_literal', - 'bin_literal2', - 'literal_general', + 'bad_bitwidth.c3', + 'bin_literal.c3t', + 'bin_literal2.c3t', + 'literal_general.c3t', + 'multi_unicode.c3', + 'radix_numbers_errors.c3', + 'too_small.c3', ] -macro_methods = ['macro_method_different_args'] +macro_methods = [ + 'access.c3', + 'macro_method_different_args.c3t', + 'macro_method_fails.c3', + 'macro_method_first_param.c3', + 'macro_methods_defined_twice.c3', +] macros = [ - 'hash_ident_nested', - 'macro_body_defer', - 'macro_chained_return_void_optional', - 'macro_common', - 'macro_defer_exit', - 'macro_defer_scope', - 'macro_defer_with_body', - 'macro_failable_return_rethrow', - 'macro_import_res_private', - 'macro_nested_labels', - 'macro_typed_varargs', - 'macro_untyped_varargs_2', - 'macro_vasplat', - 'macro_with_body', - 'type_params', - 'unifying_implicit_void', - 'userland_bitcast', + 'hash_ident.c3', + 'hash_ident_nested.c3t', + 'hash_initializer.c3t', + 'implicit_return_opt.c3', + 'macro_always_const.c3', + 'macro_body_as_value.c3', + 'macro_body_defer.c3t', + 'macro_body_errors.c3', + 'macro_body_ref_hash_constant_type.c3t', + 'macro_calls_prefix.c3', + 'macro_chained_return_void_optional.c3t', + 'macro_common.c3t', + 'macro_convert_literal.c3', + 'macro_defer_exit.c3t', + 'macro_defer_scope.c3t', + 'macro_defer_with_body.c3t', + 'macro_failable_return_rethrow.c3t', + 'macro_import_res_private.c3t', + 'macro_import_resolution.c3', + 'macro_nested_labels.c3t', + 'macro_ref_body_err1.c3', + 'macro_ref_body_err2.c3', + 'macro_resolution.c3', + 'macro_rtype.c3', + 'macro_tagof.c3t', + 'macro_typed_varargs.c3t', + 'macro_untyped_varargs.c3', + 'macro_untyped_varargs_2.c3t', + 'macro_vasplat.c3t', + 'macro_with_body.c3t', + 'macro_with_body_err.c3', + 'modify_ct_param.c3', + 'no_body.c3', + 'ref_macro_method.c3', + 'ref_vector.c3t', + 'trailing_body_const.c3t', + 'type_params.c3t', + 'typed_hash_access.c3', + 'unifying_implicit_void.c3t', + 'userland_bitcast.c3t', + 'vasplat_function_call.c3', ] methods = [ - 'enum_distinct_err_methods', - 'extension_method', - 'extension_method_in_other_modules', - 'methods_with_inferred_type', + 'access.c3', + 'access_private_method.c3', + 'dynamic_method_fails.c3', + 'enum_distinct_err_methods.c3t', + 'extending_with_visibility.c3', + 'extending_with_visibility_fail.c3', + 'extending_with_visibility_fail_private.c3', + 'extension_method.c3t', + 'extension_method_already_exist.c3', + 'extension_method_check.c3', + 'extension_method_generic.c3', + 'extension_method_in_other_modules.c3t', + 'method_extension_in_conditional_module.c3', + 'method_from_var.c3', + 'method_name_collision.c3', + 'method_ref_for_extension_method.c3', + 'methods_defined_twice.c3', + 'methods_with_inferred_type.c3t', + 'operator_assign_mutate.c3t', + 'operator_defined_twice.c3', + 'operator_inc.c3t', + 'operator_mismatch.c3', + 'self_methods_null.c3t', + 'unsupported_operator.c3', ] -module = ['module_section_export'] -overloading = ['set_overload'] +module = [ + 'missing_semi.c3', + 'module_bad_path_ident.c3', + 'module_bad_path_invalid.c3', + 'module_bad_path_keyword.c3', + 'module_error_string.c3', + 'module_generic_mixing.c3', + 'module_section_export.c3t', + 'module_start_bad_ident.c3', + 'module_start_invalid.c3', + 'module_start_keyword.c3', + 'private_module.c3', + 'unknown_modules.c3', +] + +overloading = [ + 'construct_op_zero_args.c3', + 'construct_operator.c3t', + 'set_not_set_overload.c3t', + 'set_overload.c3t', +] pointers = [ - 'array_pointer_decay', - 'const_pointer', - 'pointer_index', - 'subarray_variant_to_ptr', + 'array_pointer_decay.c3t', + 'const_pointer.c3t', + 'const_ref.c3t', + 'pointer_index.c3t', + 'subarray_variant_to_ptr.c3t', +] + +precedence = [ + 'required_parens.c3', +] + +regression = [ + 'crash_on_right_paren_macro.c3', ] -safe = ['deref'] +safe = [ + 'deref.c3t', + 'detect_invalid_deref_return.c3', +] slices = [ - 'slice_assign', - 'slice_assign2', - 'slice_comparison', - 'slice_init', - 'slice_offset_neg_end', - 'slice_offset_neg_start', - 'slice_offset', - 'slice_start', - 'slice_to_slice_assign', - 'slice_to_slice_vector_assign', + 'array_to_const_err.c3', + 'array_to_const_slice.c3t', + 'slice_assign.c3t', + 'slice_assign2.c3t', + 'slice_checks.c3t', + 'slice_comparison.c3t', + 'slice_conv_byte.c3t', + 'slice_init.c3t', + 'slice_inline.c3t', + 'slice_len_error.c3', + 'slice_negative_len.c3', + 'slice_offset.c3t', + 'slice_offset_neg_end.c3t', + 'slice_offset_neg_start.c3t', + 'slice_optional.c3t', + 'slice_optional_index.c3t', + 'slice_start.c3t', + 'slice_syntax.c3', + 'slice_to_slice_assign.c3t', + 'slice_to_slice_conv_err.c3t', + 'slice_to_slice_vector_assign.c3t', + 'sub_array_init.c3', + 'subscript_check_1519.c3t', + 'various_const_slicing.c3t', ] statements = [ - 'comparison_widening', - 'const_statements', - 'custom_foreach_with_ref', - 'defer_break_simple', - 'defer_break_switch', - 'defer_break', - 'defer_do_while', - 'defer_in_block', - 'defer_in_defer', - 'defer_in_defer2', - 'defer_next_switch', - 'defer_return', - 'defer_with_loop', - 'exhaustive_switch', - 'fallthough_do', - 'foreach_break', - 'foreach_common', - 'foreach_custom_macro', - 'foreach_custom', - 'foreach_more_implementations', - 'foreach_r_break', - 'foreach_r_common', - 'foreach_r_custom_macro', - 'foreach_r_custom', - 'if_tests', - 'infinite_do_while', - 'labelled_continue_for', - 'nextcase_const', - 'nextcase_default', - 'ranged_switch', - 'return_switch', - 'simple_do', - 'various_switching', - 'while_switch', + 'binary_fail.c3', + 'call_missing_paren.c3', + 'comparison_widening.c3t', + 'conditional_return.c3', + 'const_statements.c3t', + 'custom_foreach_with_ref.c3t', + 'default_args.c3', + 'default_macro_argc.c3t', + 'defer_break.c3t', + 'defer_break_simple.c3t', + 'defer_break_switch.c3t', + 'defer_continue_bug.c3t', + 'defer_do_while.c3t', + 'defer_hash.c3t', + 'defer_if_try_copy.c3t', + 'defer_in_block.c3t', + 'defer_in_defer.c3t', + 'defer_in_defer2.c3t', + 'defer_next_switch.c3t', + 'defer_return.c3t', + 'defer_test.c3', + 'defer_with_loop.c3t', + 'do_without_compound.c3', + 'exhaustive_switch.c3t', + 'fallthough_do.c3t', + 'for.c3', + 'for_empty.c3', + 'for_errors.c3', + 'for_with_extra_declarations.c3', + 'foreach_break.c3t', + 'foreach_common.c3t', + 'foreach_custom.c3t', + 'foreach_custom_errors.c3', + 'foreach_custom_macro.c3t', + 'foreach_distinct_iterable.c3t', + 'foreach_distinct_pointer_1506.c3', + 'foreach_errors.c3', + 'foreach_more_implementations.c3t', + 'foreach_parse_error.c3', + 'foreach_r_break.c3t', + 'foreach_r_common.c3t', + 'foreach_r_custom.c3t', + 'foreach_r_custom_errors.c3', + 'foreach_r_custom_macro.c3t', + 'foreach_r_errors.c3', + 'foreach_r_parse_error.c3', + 'foreach_r_with_error.c3', + 'foreach_with_error.c3', + 'foreach_wrong_index.c3', + 'if_decl.c3', + 'if_single.c3', + 'if_tests.c3t', + 'if_while_do_error.c3', + 'infinite_do_while.c3t', + 'label_errors.c3', + 'labelled_continue_for.c3t', + 'nextcase_const.c3t', + 'nextcase_default.c3t', + 'nextcase_missing_case.c3', + 'nextcase_no_switch.c3', + 'ranged_switch.c3t', + 'return_stmt.c3', + 'return_switch.c3t', + 'return_with_other_at_end.c3', + 'simple_do.c3t', + 'switch_error_range.c3', + 'switch_errors.c3', + 'various_switching.c3t', + 'while_statement_placement.c3', + 'while_statement_placement2.c3', + 'while_switch.c3t', ] stdlib = [ - 'map_linux', - 'map_macos', - 'memcomp', - 'priorityqueue', + 'ascii.c3', + 'map_linux.c3t', + 'map_macos.c3t', + 'memcomp.c3t', + 'minmax.c3', + 'print_env_defines.c3', + 'priorityqueue.c3t', ] strings = [ - 'literal_to_subarray', - 'multiline_strings', - 'string_escape', - 'string_len', - 'string_to_array', + 'literal_errors.c3', + 'literal_hex_ok.c3', + 'literal_to_subarray.c3t', + 'multiline_strings.c3t', + 'string_escape.c3t', + 'string_len.c3t', + 'string_to_array.c3t', ] struct = [ - 'nested_struct_init', - 'nested_struct_union_init', - 'simple_struct', - 'sret', - 'struct_as_value', - 'struct_as_value_aarch64', - 'struct_codegen', - 'struct_codegen_empty', - 'struct_codegen_fam', - 'struct_const_construct_simple', - 'struct_pack_and_align', + 'const_access_error.c3', + 'const_slice_struct.c3t', + 'const_zero_init_1360.c3t', + 'duplicate_member.c3', + 'flex_array_comparison.c3', + 'flex_array_struct_err.c3', + 'flexible_array_resolve.c3', + 'func_return_struct.c3', + 'init_cont_struct_array_locally.c3t', + 'initialize_inline_designated.c3t', + 'inline_array_access.c3t', + 'member_access.c3', + 'member_expr.c3', + 'multi_member_attributes.c3t', + 'nested_struct_init.c3t', + 'nested_struct_union_init.c3t', + 'recursive_structs.c3', + 'simple_struct.c3t', + 'sret.c3t', + 'struct_as_value.c3t', + 'struct_as_value_aarch64.c3t', + 'struct_bad_member.c3', + 'struct_codegen.c3t', + 'struct_codegen_empty.c3t', + 'struct_codegen_fam.c3t', + 'struct_const_construct_simple.c3t', + 'struct_nopadding_compact.c3t', + 'struct_pack_and_align.c3t', + 'struct_params.c3', + 'struct_reinit.c3t', + 'struct_union_inner_align.c3t', + 'zero_member.c3', + 'inner_struct_name.c3', ] -switch = ['switch_in_defer_macro'] +switch = [ + 'bad_ranges.c3', + 'failable_switch.c3', + 'jump_with_inc.c3t', + 'simple_jump.c3t', + 'switch_in_defer_macro.c3t', + 'enum_jump_switch_and_range.c3t', +] + +symbols = [ + 'allow_local_shadowing.c3', + 'shadow_struct.c3', + 'various.c3', +] + +types = [ + 'enum_illegal_type.c3', + 'enum_implicit_overflow.c3', + 'enum_inference.c3', + 'enum_ok.c3', + 'enum_param.c3', + 'enum_parse_errors.c3', + 'illegal_array_size_constant.c3', + 'non_rec_fn.c3', + 'recursive_array.c3', + 'recursive_fn.c3', + 'recursive_typedef.c3', + 'redefinition.c3', + 'typedefs.c3', + 'various.c3', +] + +unicode = [ + 'commenting-out.c3', +] union = [ - 'union_codegen_const', - 'union_codegen_empty', - 'union_codegen_overwrite_call', - 'union_in_struct', + 'designated_union_zeroing.c3t', + 'flexible_array_union.c3', + 'inferred_size_vector.c3', + 'test_unions.c3', + 'union_codegen_const.c3t', + 'union_codegen_empty.c3t', + 'union_codegen_overwrite_call.c3t', + 'union_in_struct.c3t', + 'union_member_voidcast.c3', + 'union_zero.c3', ] variables = [ - 'var_init_multi', - 'var_init', + 'consts.c3', + 'static_in_macro.c3t', + 'var_init.c3t', + 'var_init_multi.c3t', ] vector = [ - 'gather_scatter', - 'vector_bit', - 'vector_consts', - 'vector_incdec', - 'vector_init_regression', - 'vector_init', - 'vector_ops2', - 'vector_param', - 'vector_to_array_cast', + 'gather_scatter.c3t', + 'swizzle_vector_ref.c3t', + 'swizzling.c3', + 'vector_bit.c3t', + 'vector_consts.c3t', + 'vector_conversion_scalar.c3', + 'vector_incdec.c3t', + 'vector_init.c3t', + 'vector_init_regression.c3t', + 'vector_lowering_regression1.c3t', + 'vector_ops2.c3t', + 'vector_param.c3t', + 'vector_pointer_errors.c3', + 'vector_to_array_cast.c3t', + 'vector_to_array_fail.c3', ] visibility = [ - 'ambiguous_var', - 'no_shared_imports', - 'not_visible', - 'shared_module', - 'simple_visibility', + 'ambiguous_recursive.c3', + 'ambiguous_var.c3t', + 'export_property.c3t', + 'no_shared_imports.c3t', + 'not_visible.c3t', + 'private_import.c3', + 'private_import2.c3', + 'private_to_extern.c3t', + 'shared_module.c3t', + 'simple_visibility.c3t', ] test_suites = { @@ -554,6 +1147,7 @@ test_suites = { 'builtins': builtins, 'cast': cast, 'clang': clang, + 'comments': comments, 'compile_time': compile_time, 'compile_time_introspection': compile_time_introspection, 'concurrency': concurrency, @@ -561,11 +1155,14 @@ test_suites = { 'contracts': contracts, 'debug_symbols': debug_symbols, 'defer': defer, + 'define': define, 'distinct': distinct, 'dynamic': dynamic, 'embed': embed, 'enumerations': enumerations, 'errors': errors, + 'examples': examples, + 'expression_block': expression_block, 'expressions': expressions, 'floats': floats, 'from_docs': from_docs, @@ -576,6 +1173,7 @@ test_suites = { 'initialize': initialize, 'initializer_lists': initializer_lists, 'lambda': lambda, + 'lexing': lexing, 'literals': literals, 'macro_methods': macro_methods, 'macros': macros, @@ -583,6 +1181,8 @@ test_suites = { 'module': module, 'overloading': overloading, 'pointers': pointers, + 'precedence': precedence, + 'regression': regression, 'safe': safe, 'slices': slices, 'statements': statements, @@ -590,19 +1190,27 @@ test_suites = { 'strings': strings, 'struct': struct, 'switch': switch, + 'symbols': symbols, + 'types': types, + 'unicode': unicode, 'union': union, 'variables': variables, 'vector': vector, 'visibility': visibility, } -# And generate our tests! +# Generate tests in meson so that we can make trivial changes manually foreach suite, tests : test_suites foreach test : tests + test_name = test.replace('.c3', '').replace('.c3t', '') + test_type = 'compile' + if test.endswith('.c3t') + test_type = 'unit' + endif test( - f'Test Suite - @suite@ - @test@', + f'Test Suite - @suite@ - @test_type@ - @test_name@', py3, - args: [test_args, f'../test/test_suite/@suite@/@test@.c3t'], + args: [test_args, f'../test/test_suite/@suite@/@test@'], ) endforeach endforeach diff --git a/test/src/generate_meson_test_cases.py b/test/src/generate_meson_test_cases.py old mode 100644 new mode 100755 index b83363a5d..2f06213a0 --- a/test/src/generate_meson_test_cases.py +++ b/test/src/generate_meson_test_cases.py @@ -1,12 +1,118 @@ +#!/usr/bin/env python3 + +# Regenerate the meson.build file with the test cases in the test_suite directory +# Doesn't _need_ to be run, just saves time when adding new test cases +# This consitst of a dict with the test suite name and the stripped path to the test case +# expressions = [ +# '2002-02-13-ConditionalInCall', +# . . . +# 'casts/cast_expr', +# ] +# +# test_suites = { +# . . . +# expressions: expressions, +# . . .} + + import os -def create_meson_test_commands(root_dir): - for folder, subfolders, files in os.walk(root_dir): +def define_meson_tests(root_dir): + suites = {} + for dir, subdir, files in os.walk(root_dir): + # Determine the suite and sub-suite (if any) + relative_path = os.path.relpath(dir, root_dir) + path_parts = relative_path.split(os.sep) + suite = path_parts[0] # Top-level directory is the suite + + if suite == '.': # we are at the root + continue + + if len(path_parts) > 1: + sub_suite = os.path.join(*path_parts[1:]) # Join the rest for the sub-suite path + test_prefix = f"{sub_suite}/" + else: + sub_suite = None + test_prefix = "" + + test_cases = [] for file in files: - if file.endswith('.c3t'): - test_name = f"Test Suite - {os.path.basename(folder)} - {file.replace('.c3t', '')}" - test_path = os.path.join('../test/test_suite/', os.path.relpath(folder, root_dir), file) - print(f"test('{test_name}', py3, args: [test_args, '{test_path}'])") + if file.endswith(('.c3', '.c3t')): + test_cases.append(f"{test_prefix}{file}") + + # Add test cases to the suite + if len(test_cases) > 0: + if suite not in suites: + suites[suite] = [] + suites[suite].extend(test_cases) + + # Initialize the output string + output = [] + output.append('# This file can be regenerated with generate_meson_test_cases.py') + output.append('') + output.append('py3 = find_program(\'python3\', required: true)') + output.append('test_args = [\'../test/src/check.py\', \'../test/src/tester.py\', c3c_exe]') + output.append('') + # Build test case lists + for suite, tests in suites.items(): + output.append(f'{suite} = [') + for test in tests: + output.append(f" '{test}',") + output.append(']\n') + + # Build test suites dictionary + output.append('test_suites = {') + for suite in suites: + output.append(f" '{suite}': {suite},") + output.append('}') + + output.append(''' +# Generate tests in meson so that we can make trivial changes manually +foreach suite, tests : test_suites + foreach test : tests + test_name = test.replace('.c3', '').replace('.c3t', '') + test_type = 'compile' + if test.endswith('.c3t') + test_type = 'unit' + endif + test( + f'Test Suite - @suite@ - @test_type@ - @test_name@', + py3, + args: [test_args, f'../test/test_suite/@suite@/@test@'], + ) + endforeach +endforeach +''' + ) + return '\n'.join(output) + + +# # Example usage with a dummy directory structure (and test cases) +# root_directory = 'test_root' + +# # Create a sample directory structure +# os.makedirs(os.path.join(root_directory, 'suite1', 'sub1'), exist_ok=True) +# os.makedirs(os.path.join(root_directory, 'suite1', 'sub2'), exist_ok=True) +# os.makedirs(os.path.join(root_directory, 'suite2'), exist_ok=True) +# os.makedirs(os.path.join(root_directory, 'suite3', 'a', 'b'), exist_ok=True) + +# open(os.path.join(root_directory, 'suite1', 'sub1', 'test1.c3t'), 'w').close() +# open(os.path.join(root_directory, 'suite1', 'sub1', 'test2.c3t'), 'w').close() +# open(os.path.join(root_directory, 'suite1', 'sub2', 'test3.c3t'), 'w').close() +# open(os.path.join(root_directory, 'suite1', 'test4.c3t'), 'w').close() +# open(os.path.join(root_directory, 'suite2', 'test5.c3t'), 'w').close() +# open(os.path.join(root_directory, 'suite3', 'a', 'b', 'test6.c3t'), 'w').close() + +# # Run the function +# define_meson_tests(root_directory) + +# # Clean up the sample directory structure (optional) +# import shutil +# shutil.rmtree(root_directory) # Usage -create_meson_test_commands('../test_suite/') +meson_tests = define_meson_tests('../test_suite/') + +# Write the output to meson.build +with open('../meson.build', 'w') as f: + f.write(meson_tests)