add-test
Create a new Verona compiler test case. Use when the user wants to add a test, create a test, or scaffold a test for the compiler.
- License 许可
- MIT
- 所属仓库
- microsoft/verona
- 最近更新
- 2026-11-13
- Stars
- ★ 3.7k
- Forks
- 173
01 前言 Front Matter
- name
- add-test
- description
- Create a new Verona compiler test case. Use when the user wants to add a test, create a test, or scaffold a test for the compiler.
- argument-hint
- <test-name> [error|ffi]
03 SKILL.md 正文
Add a Verona Compiler Test
Create a new test case in testsuite/v/ for the Verona compiler.
Arguments
$0— the test name (required, snake_case)$1— if set toerror, creates a compile-error test (exit code 1, no run/ directory). If set toffi, creates a test that uses FFI builtins.
Steps
1. Create the source file
Create testsuite/v/$0/$0.v with appropriate Verona source code. For an
expected compile error, use
testsuite/v/compile_only/$0/$0.v instead.
Conventions:
- Tests must be self-contained — no external dependencies (no
use "https://...") - Use only
_builtintypes - Do NOT write
use "_builtin"— it is always implicitly available - No semicolons after closing braces of control flow (
for,if,while) - Semicolons are needed after statements and field definitions
- Don't use explicit type annotations on literals when inference can determine the type from context (write
0notusize 0) - Class definitions use bare names:
myclass[T] { ... } - Fields need semicolons:
val: T; newusesnew { field = val }(no class name afternew)- Use
Type(args)constructor sugar:callback(f)instead ofcallback::create(f) - Use
(obj.field)(args)for apply on field access,x.methodfor zero-arg methods
For success tests (default):
- Use the bitmask exit code pattern:
var result = 0;thenif cond { result = result + N; }with powers of 2 - Exit code 0 means all checks passed
- The
mainfunction must returni32
For compile-error tests ($1 = error):
- Write code that should fail to compile
- The test validates that the compiler correctly rejects invalid code
- Keep the test under
testsuite/v/compile_only/so no run node is registered
For FFI tests ($1 = ffi):
- Tests that use FFI builtins (
:::name(...)syntax) or_builtin/ffi/wrappers (e.g.,ffi::add_external()) - If the test relies on init functions running, it MUST include at least one reachable FFI call from the same lib — init functions are only reified when their lib's FFI symbols are called from reachable code
- Declare FFI symbols in a
useblock with aLibstring - Call FFI wrappers as
ffi::func_name(args)for functions in_builtin/ffi/
2. Generate golden files
Run from the build directory:
cd build
ninja install && ninja update-dump
This auto-generates the golden file directory structure:
testsuite/v/$0/$0/compile/(ortestsuite/v/compile_only/$0/$0/compile/for errors) — containsexit_code.txt,stdout.txt,stderr.txt, pass dump files (00_parse.triestethrough13_typecheck.trieste),*_final.trieste, and.vbcfile (success tests only)testsuite/v/$0/$0/run/— containsexit_code.txt,stdout.txt,stderr.txt(only for success tests that produce a.vbc)
3. Verify golden file completeness
Check that the golden compile/ directory has the expected files:
- All 14 pass dumps:
00_parse.triestethrough13_typecheck.trieste *_final.triesteexit_code.txt(value0for success,1for error, no trailing newline)stdout.txtandstderr.txt*.vbcfile (success tests only)
If pass dumps are missing (e.g., only 0–5 present), it usually means a WF violation in a later pass. Investigate with dist/vc/vc build ../testsuite/v/$0 --dump_passes=dump_$0 to see which pass fails.
For error tests: no run/ directory, no .vbc file, exit_code.txt = 1.
4. Verify the test passes
cd build && ctest --output-on-failure -R "^vbc/v/$0/$0" -j$(nproc)
This should show the test passing. If it fails, check the source code and re-run ninja update-dump.
For an expected compile error, use
"^vbc/v/compile_only/$0/$0" instead.
5. Report
State the test name, whether it's a success/error/ffi test, what it tests, and the expected exit code.
04 同仓库更多 Skills
verona-type-inference
Verona compiler type inference model — bidirectional refinement, per-function inference, lambda/context propagation, algebraic and structural typing, generics, and debugging. Use when changing or debugging `vc/passes/infer.cc` or investigating type inference failures.
verona-conventions
Verona compiler coding conventions, C++ style, trieste patterns, and project structure. Applies when writing or reviewing Verona compiler code.
verona-coding
Patterns, pitfalls, and idioms for writing Verona source code (.v files). Use when writing library code, _builtin types, or user programs.
vbci-memory
Verona interpreter (vbci) memory management model — regions, reference counting, write barriers, dragging, cowns, and finalization. Use when working on or debugging vbci runtime memory management code.
testsuite
Verona compiler test suite infrastructure — running tests, updating golden files, verifying pass completeness, checking error codes. Use when debugging test failures, regenerating golden files, or understanding the test framework.
review
Run a principle-based code review on the current branch. Use when the user asks for a review, or at mandatory review checkpoints (after planning, after implementation before PR).