aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Lugg <mlugg@mlugg.co.uk>2024-08-18 12:56:04 +0100
committerGitHub <noreply@github.com>2024-08-18 12:56:04 +0100
commit4929cf23cedef2ca8a8cfb2f9379d136681a6f37 (patch)
tree04156c9a729b5029a3682ff25fef088156addfdd /test
parent2b05e85107dd1c637ab40f8b145b232d18e8d6c6 (diff)
parentf0374fe3f04925a6e686077c2ffcb51b8eafc926 (diff)
downloadzig-4929cf23cedef2ca8a8cfb2f9379d136681a6f37.tar.gz
zig-4929cf23cedef2ca8a8cfb2f9379d136681a6f37.zip
Merge pull request #21063 from mlugg/incremental
Incremental compilation progress
Diffstat (limited to 'test')
-rw-r--r--test/incremental/add_decl59
-rw-r--r--test/incremental/add_decl_namespaced59
-rw-r--r--test/incremental/delete_comptime_decls38
-rw-r--r--test/incremental/unreferenced_error38
4 files changed, 194 insertions, 0 deletions
diff --git a/test/incremental/add_decl b/test/incremental/add_decl
new file mode 100644
index 0000000000..376a725efc
--- /dev/null
+++ b/test/incremental/add_decl
@@ -0,0 +1,59 @@
+#target=x86_64-linux
+#update=initial version
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(foo);
+}
+const foo = "good morning\n";
+#expect_stdout="good morning\n"
+
+#update=add new declaration
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(foo);
+}
+const foo = "good morning\n";
+const bar = "good evening\n";
+#expect_stdout="good morning\n"
+
+#update=reference new declaration
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(bar);
+}
+const foo = "good morning\n";
+const bar = "good evening\n";
+#expect_stdout="good evening\n"
+
+#update=reference missing declaration
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(qux);
+}
+const foo = "good morning\n";
+const bar = "good evening\n";
+#expect_error=ignored
+
+#update=add missing declaration
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(qux);
+}
+const foo = "good morning\n";
+const bar = "good evening\n";
+const qux = "good night\n";
+#expect_stdout="good night\n"
+
+#update=remove unused declarations
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(qux);
+}
+const qux = "good night\n";
+#expect_stdout="good night\n"
diff --git a/test/incremental/add_decl_namespaced b/test/incremental/add_decl_namespaced
new file mode 100644
index 0000000000..43123e0d0c
--- /dev/null
+++ b/test/incremental/add_decl_namespaced
@@ -0,0 +1,59 @@
+#target=x86_64-linux
+#update=initial version
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(@This().foo);
+}
+const foo = "good morning\n";
+#expect_stdout="good morning\n"
+
+#update=add new declaration
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(@This().foo);
+}
+const foo = "good morning\n";
+const bar = "good evening\n";
+#expect_stdout="good morning\n"
+
+#update=reference new declaration
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(@This().bar);
+}
+const foo = "good morning\n";
+const bar = "good evening\n";
+#expect_stdout="good evening\n"
+
+#update=reference missing declaration
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(@This().qux);
+}
+const foo = "good morning\n";
+const bar = "good evening\n";
+#expect_error=ignored
+
+#update=add missing declaration
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(@This().qux);
+}
+const foo = "good morning\n";
+const bar = "good evening\n";
+const qux = "good night\n";
+#expect_stdout="good night\n"
+
+#update=remove unused declarations
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(@This().qux);
+}
+const qux = "good night\n";
+#expect_stdout="good night\n"
diff --git a/test/incremental/delete_comptime_decls b/test/incremental/delete_comptime_decls
new file mode 100644
index 0000000000..424dc37ea8
--- /dev/null
+++ b/test/incremental/delete_comptime_decls
@@ -0,0 +1,38 @@
+#target=x86_64-linux
+#update=initial version
+#file=main.zig
+pub fn main() void {}
+comptime {
+ var array = [_:0]u8{ 1, 2, 3, 4 };
+ const src_slice: [:0]u8 = &array;
+ const slice = src_slice[2..6];
+ _ = slice;
+}
+comptime {
+ var array = [_:0]u8{ 1, 2, 3, 4 };
+ const slice = array[2..6];
+ _ = slice;
+}
+comptime {
+ var array = [_]u8{ 1, 2, 3, 4 };
+ const slice = array[2..5];
+ _ = slice;
+}
+comptime {
+ var array = [_:0]u8{ 1, 2, 3, 4 };
+ const slice = array[3..2];
+ _ = slice;
+}
+#expect_error=ignored
+
+#update=delete and modify comptime decls
+#file=main.zig
+pub fn main() void {}
+comptime {
+ const x: [*c]u8 = null;
+ var runtime_len: usize = undefined;
+ runtime_len = 0;
+ const y = x[0..runtime_len];
+ _ = y;
+}
+#expect_error=ignored
diff --git a/test/incremental/unreferenced_error b/test/incremental/unreferenced_error
new file mode 100644
index 0000000000..e3d67d6ad8
--- /dev/null
+++ b/test/incremental/unreferenced_error
@@ -0,0 +1,38 @@
+#target=x86_64-linux
+#update=initial version
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(a);
+}
+const a = "Hello, World!\n";
+#expect_stdout="Hello, World!\n"
+
+#update=introduce compile error
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(a);
+}
+const a = @compileError("bad a");
+#expect_error=ignored
+
+#update=remove error reference
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(b);
+}
+const a = @compileError("bad a");
+const b = "Hi there!\n";
+#expect_stdout="Hi there!\n"
+
+#update=introduce and remove reference to error
+#file=main.zig
+const std = @import("std");
+pub fn main() !void {
+ try std.io.getStdOut().writeAll(a);
+}
+const a = "Back to a\n";
+const b = @compileError("bad b");
+#expect_stdout="Back to a\n"