Merge pull request #22602 from mlugg/incr-embedfile

incremental: handle `@embedFile`
This commit is contained in:
Matthew Lugg
2025-01-26 01:41:56 +00:00
committed by GitHub
19 changed files with 468 additions and 209 deletions

View File

@@ -39,7 +39,7 @@ pub fn main() !void {
}
const foo = "good morning\n";
const bar = "good evening\n";
#expect_error=ignored
#expect_error=main.zig:3:37: error: use of undeclared identifier 'qux'
#update=add missing declaration
#file=main.zig

View File

@@ -39,7 +39,8 @@ pub fn main() !void {
}
const foo = "good morning\n";
const bar = "good evening\n";
#expect_error=ignored
#expect_error=main.zig:3:44: error: root source file struct 'main' has no member named 'qux'
#expect_error=main.zig:1:1: note: struct declared here
#update=add missing declaration
#file=main.zig

View File

@@ -0,0 +1,46 @@
#target=x86_64-linux-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
const string = @embedFile("string.txt");
pub fn main() !void {
try std.io.getStdOut().writeAll(string);
}
#file=string.txt
Hello, World!
#expect_stdout="Hello, World!\n"
#update=change file contents
#file=string.txt
Hello again, World!
#expect_stdout="Hello again, World!\n"
#update=delete file
#rm_file=string.txt
#expect_error=main.zig:2:27: error: unable to open 'string.txt': FileNotFound
#update=remove reference to file
#file=main.zig
const std = @import("std");
const string = @embedFile("string.txt");
pub fn main() !void {
try std.io.getStdOut().writeAll("a hardcoded string\n");
}
#expect_stdout="a hardcoded string\n"
#update=re-introduce reference to file
#file=main.zig
const std = @import("std");
const string = @embedFile("string.txt");
pub fn main() !void {
try std.io.getStdOut().writeAll(string);
}
#expect_error=main.zig:2:27: error: unable to open 'string.txt': FileNotFound
#update=recreate file
#file=string.txt
We're back, World!
#expect_stdout="We're back, World!\n"

View File

@@ -39,7 +39,7 @@ comptime {
std.debug.assert(@TypeOf(@intFromEnum(Foo.e)) == Tag);
}
const std = @import("std");
#expect_error=ignored
#expect_error=main.zig:7:5: error: enumeration value '4' too large for type 'u2'
#update=increase tag size
#file=main.zig
const Tag = u3;

View File

@@ -4,19 +4,22 @@
#target=wasm32-wasi-selfhosted
#update=initial version with compile error
#file=main.zig
pub fn main() void {}
comptime {
@compileError("this is an error");
}
comptime {
@compileLog("this is a log");
}
#expect_error=ignored
#expect_error=main.zig:3:5: error: this is an error
#update=remove the compile error
#file=main.zig
pub fn main() void {}
comptime {
//@compileError("this is an error");
}
comptime {
@compileLog("this is a log");
}
#expect_error=ignored
#expect_error=main.zig:6:5: error: found compile log statement

View File

@@ -26,7 +26,10 @@ comptime {
const slice = array[3..2];
_ = slice;
}
#expect_error=ignored
#expect_error=main.zig:5:32: error: end index 6 out of bounds for slice of length 4 +1 (sentinel)
#expect_error=main.zig:10:28: error: end index 6 out of bounds for array of length 4 +1 (sentinel)
#expect_error=main.zig:15:28: error: end index 5 out of bounds for array of length 4
#expect_error=main.zig:20:25: error: start index 3 is larger than end index 2
#update=delete and modify comptime decls
#file=main.zig
@@ -38,4 +41,4 @@ comptime {
const y = x[0..runtime_len];
_ = y;
}
#expect_error=ignored
#expect_error=main.zig:6:16: error: slice of null pointer

View File

@@ -11,7 +11,7 @@ pub fn main() !void {
pub fn hello() !void {
try std.io.getStdOut().writeAll("Hello, World!\n");
}
#expect_error=ignored
#expect_error=foo.zig:2:9: error: use of undeclared identifier 'std'
#update=fix the error
#file=foo.zig
const std = @import("std");
@@ -25,7 +25,7 @@ const std = @import("std");
pub fn hello() !void {
try std.io.getStdOut().writeAll(hello_str);
}
#expect_error=ignored
#expect_error=foo.zig:3:37: error: use of undeclared identifier 'hello_str'
#update=fix the new error
#file=foo.zig
const std = @import("std");

View File

@@ -24,7 +24,26 @@ export fn f6() void { @compileError("f6"); }
export fn f7() void { @compileError("f7"); }
export fn f8() void { @compileError("f8"); }
export fn f9() void { @compileError("f9"); }
#expect_error=ignored
#expect_error=main.zig:2:12: error: c0
#expect_error=main.zig:3:12: error: c1
#expect_error=main.zig:4:12: error: c2
#expect_error=main.zig:5:12: error: c3
#expect_error=main.zig:6:12: error: c4
#expect_error=main.zig:7:12: error: c5
#expect_error=main.zig:8:12: error: c6
#expect_error=main.zig:9:12: error: c7
#expect_error=main.zig:10:12: error: c8
#expect_error=main.zig:11:12: error: c9
#expect_error=main.zig:12:23: error: f0
#expect_error=main.zig:13:23: error: f1
#expect_error=main.zig:14:23: error: f2
#expect_error=main.zig:15:23: error: f3
#expect_error=main.zig:16:23: error: f4
#expect_error=main.zig:17:23: error: f5
#expect_error=main.zig:18:23: error: f6
#expect_error=main.zig:19:23: error: f7
#expect_error=main.zig:20:23: error: f8
#expect_error=main.zig:21:23: error: f9
#update=fix all the errors
#file=main.zig
pub fn main() !void {}

View File

@@ -23,4 +23,5 @@ pub fn main() !void {
try std.io.getStdOut().writer().print("{}\n", .{@intFromEnum(MyEnum.foo)});
}
const std = @import("std");
#expect_error=ignored
#expect_error=main.zig:6:73: error: enum 'main.MyEnum' has no member named 'foo'
#expect_error=main.zig:1:16: note: enum declared here

View File

@@ -15,7 +15,8 @@ pub fn main() void {
const u: U = .{ .a = 123 };
_ = u;
}
#expect_error=ignored
#expect_error=main.zig:6:5: error: no field named 'd' in enum 'main.E'
#expect_error=main.zig:1:11: note: enum declared here
#update=remove invalid backing enum
#file=main.zig
const U = union {

View File

@@ -11,7 +11,7 @@ pub fn main() !void {}
#update=introduce parse error
#file=main.zig
pub fn main() !void {
#expect_error=ignored
#expect_error=main.zig:2:1: error: expected statement, found 'EOF'
#update=fix parse error
#file=main.zig

View File

@@ -18,7 +18,7 @@ pub fn main() !void {
try std.io.getStdOut().writeAll(a);
}
const a = @compileError("bad a");
#expect_error=ignored
#expect_error=main.zig:5:11: error: bad a
#update=remove error reference
#file=main.zig