chore: move all remaining llvm-lit tests into zig's test runner

This commit is contained in:
Brett Broadhurst 2026-04-03 12:22:22 -06:00
parent f82b361005
commit 19cceb1b35
Failed to generate hash of commit
24 changed files with 48 additions and 262 deletions

View file

@ -1,5 +0,0 @@
cmake_minimum_required(VERSION 3.20)
project(InkCompiler LANGUAGES NONE)
add_subdirectory(testing/regression)

View file

@ -777,12 +777,6 @@ fn irBreak(
return error.InvalidBreakTarget; return error.InvalidBreakTarget;
} }
fn irBreakInline(sema: *Sema, inst: Ir.Inst.Index) InnerError!ValueInfo {
const data = sema.ir.instructions[@intFromEnum(inst)].data.bin;
const rvalue_inst = sema.resolveInst(data.rhs);
return rvalue_inst;
}
fn irContentPush(sema: *Sema, builder: *Builder, inst: Ir.Inst.Index) InnerError!void { fn irContentPush(sema: *Sema, builder: *Builder, inst: Ir.Inst.Index) InnerError!void {
const data = sema.ir.instructions[@intFromEnum(inst)].data.un; const data = sema.ir.instructions[@intFromEnum(inst)].data.un;
const lhs = sema.resolveInst(data.lhs); const lhs = sema.resolveInst(data.lhs);
@ -981,7 +975,7 @@ fn irDivert(
const arg_end = sema.ir.extra[extra.end + i]; const arg_end = sema.ir.extra[extra.end + i];
defer arg_start = arg_end; defer arg_start = arg_end;
const arg_body = body[arg_start..arg_end]; const arg_body = body[arg_start..arg_end];
const arg_value = try analyzeBodyInner(sema, builder, block, @ptrCast(arg_body), false); const arg_value = try analyzeInlineBody(sema, builder, block, @ptrCast(arg_body));
if (arg_value != .none) try builder.ensureLoad(arg_value); if (arg_value != .none) try builder.ensureLoad(arg_value);
} }
try builder.addConstOp(.divert, @intCast(args_len)); try builder.addConstOp(.divert, @intCast(args_len));

View file

@ -14,6 +14,14 @@ test "fixture - constant folding" {
try testRuntimeFixture("constant-folding"); try testRuntimeFixture("constant-folding");
} }
test "fixture - global variable shadowing" {
try testRuntimeFixture("global-shadowing");
}
test "fixture - global variable shadowing 2" {
try testRuntimeFixture("global-shadowing-2");
}
test "fixture - simple conditional" { test "fixture - simple conditional" {
try testRuntimeFixture("simple-conditional"); try testRuntimeFixture("simple-conditional");
} }

View file

View file

@ -0,0 +1 @@
temp

View file

View file

@ -0,0 +1 @@
temp

View file

@ -2,6 +2,43 @@ const std = @import("std");
const compile = @import("compile.zig"); const compile = @import("compile.zig");
const Module = compile.Module; const Module = compile.Module;
test "compiler: VAR expected expression" {
try testEqual(
\\VAR foo =
,
\\<STDIN>:1:10: error: expected expression
\\1 | VAR foo =
\\ | ^
\\
,
);
}
test "compiler: CONST expected expression" {
try testEqual(
\\CONST foo =
,
\\<STDIN>:1:12: error: expected expression
\\1 | CONST foo =
\\ | ^
\\
,
);
}
test "compiler: knot expected identifier" {
try testEqual(
\\===
\\Hello, world!
,
\\<STDIN>:1:4: error: expected identifier
\\1 | ===
\\ | ^
\\
,
);
}
test "compiler: unknown global variable" { test "compiler: unknown global variable" {
try testEqual( try testEqual(
\\{a} \\{a}

View file

@ -1,9 +0,0 @@
set(LIT_CFG_DIR ${CMAKE_CURRENT_SOURCE_DIR})
configure_file(lit.site.cfg.py.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py @ONLY)
find_program(LLVM_LIT_EXECUTABLE NAMES llvm-lit lit)
add_custom_target(check
COMMAND ${LLVM_LIT_EXECUTABLE} -v "${CMAKE_CURRENT_BINARY_DIR}"
)

View file

@ -1,14 +0,0 @@
#!/usr/bin/env python3
import os
import lit.formats
config.name = "Ink Compiler Regression Tests"
config.suffixes = [".ink"]
config.tools = ["FileCheck"]
config.test_format = lit.formats.ShTest(execute_external=True)
config.test_source_root = os.path.dirname(__file__)
config.test_exec_root = os.path.join(config.project_build_root, "testing", "regression")
exe_path = os.path.join(config.project_zig_root, "bin", "inkc")
config.substitutions.append(("%ink-compiler", exe_path))

View file

@ -1,8 +0,0 @@
import os
config.project_source_root = r"@CMAKE_SOURCE_DIR@"
config.project_build_root = r"@CMAKE_BINARY_DIR@"
config.project_zig_root = os.path.join(r"@CMAKE_SOURCE_DIR@", "zig-out")
lit_config.load_config(
config, os.path.join(config.project_source_root, "testing", "regression", "lit.cfg.py"))

View file

@ -1,2 +0,0 @@
VAR foo = "Hello, world!"
VAR foo = "Hello, world!"

View file

@ -1,27 +0,0 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:23, line:27>
// CHECK-NEXT: |--TempDecl <line:23, col:3:13>
// CHECK-NEXT: | |--Identifier `x` <col:8, col:9>
// CHECK-NEXT: | `--NumberLiteral `2` <col:12, col:13>
// CHECK-NEXT: `--ContentStmt <line:25, col:1:48>
// CHECK-NEXT: `--Content <col:1, col:48>
// CHECK-NEXT: `--IfStmt <line:25, line:27>
// CHECK-NEXT: |--LogicalAndExpr <col:2, col:20>
// CHECK-NEXT: | |--LogicalGreaterThanOrEqualExpr <col:2, col:8>
// CHECK-NEXT: | | |--Identifier `x` <col:2, col:3>
// CHECK-NEXT: | | `--NumberLiteral `1` <col:7, col:8>
// CHECK-NEXT: | `--LogicalLesserThanOrEqualExpr <col:13, col:20>
// CHECK-NEXT: | |--Identifier `x` <col:13, col:14>
// CHECK-NEXT: | `--NumberLiteral `10` <col:18, col:20>
// CHECK-NEXT: `--BlockStmt <line:26, line:26>
// CHECK-NEXT: `--ContentStmt <line:26, col:5:25>
// CHECK-NEXT: `--Content <col:5, col:25>
// CHECK-NEXT: `--StringLiteral `Between one and ten!` <col:5, col:25>
~ temp x = 2
{x >= 1 and x <= 10:
Between one and ten!
}

View file

@ -1,27 +0,0 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:23, line:27>
// CHECK-NEXT: |--TempDecl <line:23, col:3:13>
// CHECK-NEXT: | |--Identifier `x` <col:8, col:9>
// CHECK-NEXT: | `--NumberLiteral `2` <col:12, col:13>
// CHECK-NEXT: `--ContentStmt <line:25, col:1:56>
// CHECK-NEXT: `--Content <col:1, col:56>
// CHECK-NEXT: `--IfStmt <line:25, line:27>
// CHECK-NEXT: |--LogicalOrExpr <col:2, col:22>
// CHECK-NEXT: | |--LogicalGreaterThanOrEqualExpr <col:2, col:8>
// CHECK-NEXT: | | |--Identifier `x` <col:2, col:3>
// CHECK-NEXT: | | `--NumberLiteral `1` <col:7, col:8>
// CHECK-NEXT: | `--LogicalEqualityExpr <col:12, col:22>
// CHECK-NEXT: | |--Identifier `x` <col:12, col:13>
// CHECK-NEXT: | `--FalseLiteral <col:17, col:22>
// CHECK-NEXT: `--BlockStmt <line:26, line:26>
// CHECK-NEXT: `--ContentStmt <line:26, col:5:31>
// CHECK-NEXT: `--Content <col:5, col:31>
// CHECK-NEXT: `--StringLiteral `Greater than one or false!` <col:5, col:31>
~ temp x = 2
{x >= 1 or x == false:
Greater than one or false!
}

View file

@ -1,43 +0,0 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:36, line:43>
// CHECK-NEXT: |--TempDecl <line:36, col:3:13>
// CHECK-NEXT: | |--Identifier `x` <col:8, col:9>
// CHECK-NEXT: | `--NumberLiteral `3` <col:12, col:13>
// CHECK-NEXT: `--ContentStmt <line:38, col:1:51>
// CHECK-NEXT: `--Content <col:1, col:51>
// CHECK-NEXT: `--SwitchStmt <line:38, line:43>
// CHECK-NEXT: |--Identifier `x` <col:3, col:4>
// CHECK-NEXT: |--SwitchCase <col:3, col:7>
// CHECK-NEXT: | |--NumberLiteral `0` <col:3, col:4>
// CHECK-NEXT: | `--BlockStmt <line:39, line:39>
// CHECK-NEXT: | `--ContentStmt <line:39, col:7:11>
// CHECK-NEXT: | `--Content <col:7, col:11>
// CHECK-NEXT: | `--StringLiteral `zero` <col:7, col:11>
// CHECK-NEXT: |--SwitchCase <col:3, col:7>
// CHECK-NEXT: | |--NumberLiteral `1` <col:3, col:4>
// CHECK-NEXT: | `--BlockStmt <line:40, line:40>
// CHECK-NEXT: | `--ContentStmt <line:40, col:7:10>
// CHECK-NEXT: | `--Content <col:7, col:10>
// CHECK-NEXT: | `--StringLiteral `one` <col:7, col:10>
// CHECK-NEXT: |--SwitchCase <col:3, col:7>
// CHECK-NEXT: | |--NumberLiteral `2` <col:3, col:4>
// CHECK-NEXT: | `--BlockStmt <line:41, line:41>
// CHECK-NEXT: | `--ContentStmt <line:41, col:7:10>
// CHECK-NEXT: | `--Content <col:7, col:10>
// CHECK-NEXT: | `--StringLiteral `two` <col:7, col:10>
// CHECK-NEXT: `--ElseBranch <col:3, col:9>
// CHECK-NEXT: `--BlockStmt <line:42, line:42>
// CHECK-NEXT: `--ContentStmt <line:42, col:9:13>
// CHECK-NEXT: `--Content <col:9, col:13>
// CHECK-NEXT: `--StringLiteral `lots` <col:9, col:13>
~ temp x = 3
{ x:
- 0: zero
- 1: one
- 2: two
- else: lots
}

View file

@ -1 +0,0 @@
CONST foo =

View file

@ -1,23 +0,0 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--BlockStmt <line:21, line:23>
// CHECK-NEXT: |--VarDecl <line:21, col:1:24>
// CHECK-NEXT: | |--Identifier `x` <col:5, col:6>
// CHECK-NEXT: | `--StringExpr `"Hello world 1"` <col:9, col:24>
// CHECK-NEXT: | `--StringLiteral `Hello world 1` <col:10, col:23>
// CHECK-NEXT: |--ContentStmt <line:22, col:1:4>
// CHECK-NEXT: | `--Content <col:1, col:4>
// CHECK-NEXT: | `--InlineLogicExpr <col:1, col:4>
// CHECK-NEXT: | `--Identifier `x` <col:2, col:3>
// CHECK-NEXT: `--ContentStmt <line:23, col:1:19>
// CHECK-NEXT: `--Content <col:1, col:19>
// CHECK-NEXT: |--StringLiteral `Hello ` <col:1, col:7>
// CHECK-NEXT: |--InlineLogicExpr <col:7, col:16>
// CHECK-NEXT: | `--StringExpr `"world"` <col:8, col:15>
// CHECK-NEXT: | `--StringLiteral `world` <col:9, col:14>
// CHECK-NEXT: `--StringLiteral ` 2.` <col:16, col:19>
VAR x = "Hello world 1"
{x}
Hello {"world"} 2.

View file

@ -1,28 +0,0 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: |--BlockStmt <line:25, line:25>
// CHECK-NEXT: | `--ContentStmt <line:25, col:1:13>
// CHECK-NEXT: | `--Content <col:1, col:13>
// CHECK-NEXT: | `--InlineLogicExpr <col:1, col:13>
// CHECK-NEXT: | `--CallExpr <col:2, col:12>
// CHECK-NEXT: | |--Identifier `func` <col:2, col:6>
// CHECK-NEXT: | `--ArgumentList <col:6, col:12>
// CHECK-NEXT: | |--NumberLiteral `1` <col:7, col:8>
// CHECK-NEXT: | `--NumberLiteral `2` <col:10, col:11>
// CHECK-NEXT: `--FunctionDecl <line:27, line:28>
// CHECK-NEXT: |--FunctionProto <col:1, col:23>
// CHECK-NEXT: | |--Identifier `func` <col:13, col:17>
// CHECK-NEXT: | `--ParamList <col:17, col:23>
// CHECK-NEXT: | |--ParamDecl `a` <col:18, col:19>
// CHECK-NEXT: | `--ParamDecl `b` <col:21, col:22>
// CHECK-NEXT: `--BlockStmt <line:28, line:28>
// CHECK-NEXT: `--ReturnStmt <line:28, col:3:15>
// CHECK-NEXT: `--AddExpr <col:10, col:15>
// CHECK-NEXT: |--Identifier `a` <col:10, col:11>
// CHECK-NEXT: `--Identifier `b` <col:14, col:15>
{func(1, 2)}
== function func(a, b)
~ return a + b

View file

@ -1,2 +0,0 @@
===
Hello, world!

View file

@ -1,34 +0,0 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: |--BlockStmt <line:30, line:30>
// CHECK-NEXT: | `--DivertStmt <line:30, col:1:16>
// CHECK-NEXT: | `--Divert <col:1, col:16>
// CHECK-NEXT: | `--CallExpr <col:4, col:16>
// CHECK-NEXT: | |--SelectorExpr <col:4, col:7>
// CHECK-NEXT: | | |--Identifier `a` <col:4, col:5>
// CHECK-NEXT: | | `--Identifier `b` <col:6, col:7>
// CHECK-NEXT: | `--ArgumentList <col:7, col:16>
// CHECK-NEXT: | `--StringExpr `"Brett"` <col:8, col:15>
// CHECK-NEXT: | `--StringLiteral `Brett` <col:9, col:14>
// CHECK-NEXT: `--KnotDecl <line:32, line:34>
// CHECK-NEXT: |--KnotProto <col:1, col:5>
// CHECK-NEXT: | `--Identifier `a` <col:4, col:5>
// CHECK-NEXT: `--StitchDecl <line:33, line:34>
// CHECK-NEXT: |--StitchProto <col:1, col:10>
// CHECK-NEXT: | |--Identifier `b` <col:3, col:4>
// CHECK-NEXT: | `--ParamList <col:4, col:10>
// CHECK-NEXT: | `--ParamDecl `name` <col:5, col:9>
// CHECK-NEXT: `--BlockStmt <line:34, line:34>
// CHECK-NEXT: `--ContentStmt <line:34, col:1:15>
// CHECK-NEXT: `--Content <col:1, col:15>
// CHECK-NEXT: |--StringLiteral `Hello, ` <col:1, col:8>
// CHECK-NEXT: |--InlineLogicExpr <col:8, col:14>
// CHECK-NEXT: | `--Identifier `name` <col:9, col:13>
// CHECK-NEXT: `--StringLiteral `!` <col:14, col:15>
-> a.b("Brett")
== a
= b(name)
Hello, {name}!

View file

@ -1,31 +0,0 @@
// RUN: %ink-compiler --stdin --compile-only --dump-ast < %s | FileCheck %s
// CHECK: File "<STDIN>"
// CHECK-NEXT: `--KnotDecl <line:26, line:31>
// CHECK-NEXT: |--KnotProto <col:1, col:13>
// CHECK-NEXT: | `--Identifier `knot` <col:5, col:9>
// CHECK-NEXT: |--BlockStmt <line:27, line:27>
// CHECK-NEXT: | `--ContentStmt <line:27, col:1:19>
// CHECK-NEXT: | `--Content <col:1, col:19>
// CHECK-NEXT: | `--StringLiteral `Hello from `knot`!` <col:1, col:19>
// CHECK-NEXT: |--StitchDecl <line:28, line:29>
// CHECK-NEXT: | |--StitchProto <col:1, col:4>
// CHECK-NEXT: | | `--Identifier `a` <col:3, col:4>
// CHECK-NEXT: | `--BlockStmt <line:29, line:29>
// CHECK-NEXT: | `--ContentStmt <line:29, col:1:21>
// CHECK-NEXT: | `--Content <col:1, col:21>
// CHECK-NEXT: | `--StringLiteral `Hello from `knot.a`!` <col:1, col:21>
// CHECK-NEXT: `--StitchDecl <line:30, line:31>
// CHECK-NEXT: |--StitchProto <col:1, col:4>
// CHECK-NEXT: | `--Identifier `b` <col:3, col:4>
// CHECK-NEXT: `--BlockStmt <line:31, line:31>
// CHECK-NEXT: `--ContentStmt <line:31, col:1:21>
// CHECK-NEXT: `--Content <col:1, col:21>
// CHECK-NEXT: `--StringLiteral `Hello from `knot.b`!` <col:1, col:21>
=== knot ===
Hello from `knot`!
= a
Hello from `knot.a`!
= b
Hello from `knot.b`!

View file

@ -1 +0,0 @@
VAR foo =