zig/test/cases
Linus Groh eb37552536 Remove numerous things deprecated during the 0.14 release cycle
Basically everything that has a direct replacement or no uses left.

Notable omissions:

- std.ArrayHashMap: Too much fallout, needs a separate cleanup.
- std.debug.runtime_safety: Too much fallout.
- std.heap.GeneralPurposeAllocator: Lots of references to it remain, not
  a simple find and replace as "debug allocator" is not equivalent to
  "general purpose allocator".
- std.io.Reader: Is being reworked at the moment.
- std.unicode.utf8Decode(): No replacement, needs a new API first.
- Manifest backwards compat options: Removal would break test data used
  by TestFetchBuilder.
- panic handler needs to be a namespace: Many tests still rely on it
  being a function, needs a separate cleanup.
2025-07-11 08:17:43 +02:00
..
compile_errors Remove numerous things deprecated during the 0.14 release cycle 2025-07-11 08:17:43 +02:00
llvm x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
run_translated_c translate-c: fix referencing extern locals from nested blocks 2025-03-31 20:22:03 +03:00
safety fix test case expected float value 2025-07-07 22:43:53 -07:00
translate_c translate-c: fix callconv attribute in macro 2025-05-07 16:15:51 +03:00
address_of_extern_var_as_const.zig test cases: taking address of extern var as constant 2023-06-27 19:08:27 -04:00
ambiguous_reference.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
array_in_anon_struct.zig x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
bad_inferred_variable_type.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
comparison_of_non-tagged_union_and_enum_literal.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
compile_error.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
comptime_aggregate_print.zig compiler: improve "... contains reference to comptime var" errors 2025-01-11 08:54:47 +00:00
decl_value_arena.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
error_in_nested_declaration.zig x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
exit.zig disable plan9 test 2024-09-26 21:02:14 -07:00
f32_passed_to_variadic_fn.zig x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
float_mode_optimized_reduce.zig x86_64: implement optimized float @reduce(.Add) 2025-05-28 15:10:22 -04:00
fn_typeinfo_passed_to_comptime_fn.zig x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
function_pointers.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
function_redeclaration.zig compiler: allow files with AstGen errors to undergo semantic analysis 2024-12-05 19:58:38 +00:00
global_variable_redeclaration.zig cases: update for new error wording, add coverage for field/decl name conflict 2024-08-29 23:43:52 +01:00
inherit_want_safety.zig test: Set emit_bin=false for some safety tests. 2024-11-24 22:11:17 +01:00
inner_func_accessing_outer_var.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
large_add_function.zig x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
maximum_sized_integer_literal.zig x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
no_compile_panic_for_unchecked_arith.zig test: Set emit_bin=false for some safety tests. 2024-11-24 22:11:17 +01:00
non_leaf_functions.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
passing_u0_to_function.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
pic_freestanding.zig test: Add test cases for PIC/PIE on various supported platforms. 2024-11-24 22:11:17 +01:00
pic_linux.zig test: Add test cases for PIC/PIE on various supported platforms. 2024-11-24 22:11:17 +01:00
pie_freestanding.zig test: Add test cases for PIC/PIE on various supported platforms. 2024-11-24 22:11:17 +01:00
pie_linux.zig test: Add test cases for PIC/PIE on various supported platforms. 2024-11-24 22:11:17 +01:00
print_u32s.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
README.md tests: translate-c and run-translated-c to the test harness 2023-10-17 11:55:17 +03:00
recursive_fibonacci.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
returning_undefined_sentinel_terminated_const_u8_slice.zig x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
returns_in_try.zig stage2: change how defers are stored in Zir 2022-09-12 01:52:44 -04:00
runtime_bitwise_and.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
runtime_bitwise_or.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
save_function_return_values_in_callee_preserved_register.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
setting_an_address_space_on_a_local_variable.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
spirv_mergable_pointers.zig test: Set emit_bin=false for spirv_mergable_pointers.zig. 2024-11-24 22:11:17 +01:00
tail_call_noreturn.zig test cases: fix typo in filename 2023-06-27 19:57:23 -04:00
taking_pointer_of_global_tagged_union.zig x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
try_in_comptime_in_struct_in_test.zig tests: translate-c and run-translated-c to the test harness 2023-10-17 11:55:17 +03:00
type_names.zig don't put intern pool indexes in test cases 2025-06-07 12:29:51 -07:00
union_unresolved_layout.zig x86_64: implement error set and enum safety 2025-02-15 03:45:21 -05:00
unused_vars.zig compiler: allow files with AstGen errors to undergo semantic analysis 2024-12-05 19:58:38 +00:00

Test Case Quick Reference

Use comments at the end of the file to indicate metadata about the test case. Here are examples of different kinds of tests:

Compile Error Test

If you want it to be run with zig test and match expected error messages:

// error
// is_test=true
//
// :4:13: error: 'try' outside function scope

Execution

This will do zig run on the code and expect exit code 0.

// run

Translate-c

If you want to test translating C code to Zig use translate-c:

// translate-c
// c_frontend=aro,clang
// target=x86_64-linux
//
// pub const foo = 1;
// pub const immediately_after_foo = 2;
//
// pub const somewhere_else_in_the_file = 3:

Run Translated C

If you want to test translating C code to Zig and then executing it use run-translated-c:

// run-translated-c
// c_frontend=aro,clang
// target=x86_64-linux
//
// Hello world!

Incremental Compilation

Make multiple files that have ".", and then an integer, before the ".zig" extension, like this:

hello.0.zig
hello.1.zig
hello.2.zig

Each file can be a different kind of test, such as expecting compile errors, or expecting to be run and exit(0). The test harness will use these to simulate incremental compilation.

At the time of writing there is no way to specify multiple files being changed as part of an update.

Subdirectories

Subdirectories do not have any semantic meaning but they can be used for organization since the test harness will recurse into them. The full directory path will be prepended as a prefix on the test case name.

Limiting which Backends and Targets are Tested

// run
// backend=stage2,llvm
// target=x86_64-linux,x86_64-macos

Possible backends are:

  • stage1: equivalent to -fstage1.
  • stage2: equivalent to passing -fno-stage1 -fno-LLVM.
  • llvm: equivalent to -fLLVM -fno-stage1.