bbbc95afd0
...and fix a minor x86_64 backend bug exposed by this fix. Resolves: #21974 |
||
---|---|---|
.. | ||
compile_errors | ||
llvm | ||
run_translated_c | ||
safety | ||
translate_c | ||
address_of_extern_var_as_const.zig | ||
ambiguous_reference.zig | ||
array_in_anon_struct.zig | ||
bad_inferred_variable_type.zig | ||
comparison_of_non-tagged_union_and_enum_literal.zig | ||
compile_error.zig | ||
comptime_aggregate_print.zig | ||
decl_value_arena.zig | ||
errdefer_discard.zig | ||
error_in_nested_declaration.zig | ||
exit.zig | ||
f32_passed_to_variadic_fn.zig | ||
float_mode_optimized_reduce.zig | ||
fn_typeinfo_passed_to_comptime_fn.zig | ||
function_pointers.zig | ||
function_redeclaration.zig | ||
global_variable_redeclaration.zig | ||
inherit_want_safety.zig | ||
inner_func_accessing_outer_var.zig | ||
large_add_function.zig | ||
maximum_sized_integer_literal.zig | ||
no_compile_panic_for_unchecked_arith.zig | ||
non_leaf_functions.zig | ||
passing_u0_to_function.zig | ||
print_u32s.zig | ||
README.md | ||
recursive_fibonacci.zig | ||
returning_undefined_sentinel_terminated_const_u8_slice.zig | ||
returns_in_try.zig | ||
runtime_bitwise_and.zig | ||
runtime_bitwise_or.zig | ||
save_function_return_values_in_callee_preserved_register.zig | ||
setting_an_address_space_on_a_local_variable.zig | ||
spirv_mergable_pointers.zig | ||
tail_call_noreturn.zig | ||
taking_pointer_of_global_tagged_union.zig | ||
try_in_comptime_in_struct_in_test.zig | ||
union_unresolved_layout.zig | ||
unused_vars.zig |
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
.