# Add rudimentary compile error test file support · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/7f64f7c9259ba5f67adb386ba55473d4b2b74607)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 7f64f7c9259ba5f67adb386ba55473d4b2b74607

Requested commit: 7f64f7c9259ba5f67adb386ba55473d4b2b74607

Commit: 7f64f7c9259ba5f67adb386ba55473d4b2b74607

Tree: 77eb3a4eb8bacc3d0b1b6ffa5fdd6e8902e9b8c7

Author: Cody Tapscott

Committer: Cody Tapscott

## Message

````
Add rudimentary compile error test file support

This brings two quality-of-life improvements for folks working on
compile error test cases:
 - test cases can be added/changed without re-building Zig
 - wrapping the source in a multi-line string literal is not necessary

I decided to keep things as simple as possible for this initial
implementation. The test "manifest" is a contiguous comment block at the
end of the test file:
1. The first line is the test case name
2. The second line is a blank comment
2. The following lines are expected errors

Here's an example:
```zig
const U = union(enum(u2)) {
    A: u8,
    B: u8,
    C: u8,
    D: u8,
    E: u8,
};
export fn entry() void {
    _ = U{ .E = 1 };
}

// union with too small explicit unsigned tag type
//
// tmp.zig:1:22: error: specified integer tag type cannot represent every field
// tmp.zig:1:22: note: type u2 cannot fit values in range 0...4
```

The mode of the test (obj/exe/test), as well as the target
(stage1/stage2) is determined based on the directory containing the
test.

We'll probably eventually want to support embedding this information
in the test files themselves, similar to the arocc test runner, but
that enhancement can be tackled later.

````

## Parents

- [1c33ea2c35e9260babedb116ad527256e0a4ef5e](https://git.cafe/gitcafe/zig/commit/1c33ea2c35e9260babedb116ad527256e0a4ef5e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/7f64f7c9259ba5f67adb386ba55473d4b2b74607?format=markdown)
