authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-07 12:30:16-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-07 12:30:16-05:00
log3fce8008cc1303cb3a8ed6c2c48cbebc81dadaa8
tree4695f875212d2e9d9a4e2ab5444055c0383af4d7
parent7f4cce3345baab10ff51e898c3810ee58e6bd88b
signaturelock-open Commit is signed but in an unrecognized format.

skip self-hosted for now as we work towards async I/O

1. behavior tests with --test-evented-io 2. std lib tests with --test-evented-io 3. fuzz test evented I/O a bit, make it robust 4. make sure it works on all platforms (kqueue, Windows IOCP, epoll/other) 5. restart efforts on self-hosted

5 files changed, 20 insertions(+), 18 deletions(-)

build.zig+3-4
......@@ -72,14 +72,13 @@ pub fn build(b: *Builder) !void {
7272 const skip_release_safe = b.option(bool, "skip-release-safe", "Main test suite skips release-safe builds") orelse skip_release;
7373 const skip_non_native = b.option(bool, "skip-non-native", "Main test suite skips non-native builds") orelse false;
7474 const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
75 const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false;
76 if (!skip_self_hosted and builtin.os == .linux) {
77 // TODO evented I/O other OS's
75 const skip_self_hosted = (b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false) or true; // TODO evented I/O good enough that this passes everywhere
76 if (!skip_self_hosted) {
7877 test_step.dependOn(&exe.step);
7978 }
8079
8180 const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
82 if (!only_install_lib_files) {
81 if (!only_install_lib_files and !skip_self_hosted) {
8382 b.default_step.dependOn(&exe.step);
8483 exe.install();
8584 }
lib/std/fs/watch.zig+3
......@@ -11,6 +11,9 @@ const fd_t = os.fd_t;
1111const File = std.fs.File;
1212const Allocator = mem.Allocator;
1313
14const global_event_loop = Loop.instance orelse
15 @compileError("std.fs.Watch currently only works with event-based I/O");
16
1417const WatchEventId = enum {
1518 CloseWrite,
1619 Delete,
src-self-hosted/compilation.zig+12-12
......@@ -29,7 +29,7 @@ const Package = @import("package.zig").Package;
2929const link = @import("link.zig").link;
3030const LibCInstallation = @import("libc_installation.zig").LibCInstallation;
3131const CInt = @import("c_int.zig").CInt;
32const fs = event.fs;
32const fs = std.fs;
3333const util = @import("util.zig");
3434
3535const max_src_size = 2 * 1024 * 1024 * 1024; // 2 GiB
......@@ -442,7 +442,7 @@ pub const Compilation = struct {
442442 comp.name = try Buffer.init(comp.arena(), name);
443443 comp.llvm_triple = try util.getTriple(comp.arena(), target);
444444 comp.llvm_target = try util.llvmTargetFromTriple(comp.llvm_triple);
445 comp.zig_std_dir = try std.fs.path.join(comp.arena(), &[_][]const u8{ zig_lib_dir, "std" });
445 comp.zig_std_dir = try fs.path.join(comp.arena(), &[_][]const u8{ zig_lib_dir, "std" });
446446
447447 const opt_level = switch (build_mode) {
448448 .Debug => llvm.CodeGenLevelNone,
......@@ -488,8 +488,8 @@ pub const Compilation = struct {
488488 defer comp.events.deinit();
489489
490490 if (root_src_path) |root_src| {
491 const dirname = std.fs.path.dirname(root_src) orelse ".";
492 const basename = std.fs.path.basename(root_src);
491 const dirname = fs.path.dirname(root_src) orelse ".";
492 const basename = fs.path.basename(root_src);
493493
494494 comp.root_package = try Package.create(comp.arena(), dirname, basename);
495495 comp.std_package = try Package.create(comp.arena(), comp.zig_std_dir, "std.zig");
......@@ -521,7 +521,7 @@ pub const Compilation = struct {
521521 if (comp.tmp_dir.getOrNull()) |tmp_dir_result|
522522 if (tmp_dir_result.*) |tmp_dir| {
523523 // TODO evented I/O?
524 std.fs.deleteTree(tmp_dir) catch {};
524 fs.deleteTree(tmp_dir) catch {};
525525 } else |_| {};
526526 }
527527
......@@ -797,7 +797,7 @@ pub const Compilation = struct {
797797
798798 async fn rebuildFile(self: *Compilation, root_scope: *Scope.Root) BuildError!void {
799799 const tree_scope = blk: {
800 const source_code = fs.readFile(
800 const source_code = fs.cwd().readFileAlloc(
801801 self.gpa(),
802802 root_scope.realpath,
803803 max_src_size,
......@@ -935,8 +935,8 @@ pub const Compilation = struct {
935935 fn initialCompile(self: *Compilation) !void {
936936 if (self.root_src_path) |root_src_path| {
937937 const root_scope = blk: {
938 // TODO async/await std.fs.realpath
939 const root_src_real_path = std.fs.realpathAlloc(self.gpa(), root_src_path) catch |err| {
938 // TODO async/await fs.realpath
939 const root_src_real_path = fs.realpathAlloc(self.gpa(), root_src_path) catch |err| {
940940 try self.addCompileErrorCli(root_src_path, "unable to open: {}", .{@errorName(err)});
941941 return;
942942 };
......@@ -1157,7 +1157,7 @@ pub const Compilation = struct {
11571157 const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", .{ file_prefix[0..], suffix });
11581158 defer self.gpa().free(file_name);
11591159
1160 const full_path = try std.fs.path.join(self.gpa(), &[_][]const u8{ tmp_dir, file_name[0..] });
1160 const full_path = try fs.path.join(self.gpa(), &[_][]const u8{ tmp_dir, file_name[0..] });
11611161 errdefer self.gpa().free(full_path);
11621162
11631163 return Buffer.fromOwnedSlice(self.gpa(), full_path);
......@@ -1178,8 +1178,8 @@ pub const Compilation = struct {
11781178 const zig_dir_path = try getZigDir(self.gpa());
11791179 defer self.gpa().free(zig_dir_path);
11801180
1181 const tmp_dir = try std.fs.path.join(self.arena(), &[_][]const u8{ zig_dir_path, comp_dir_name[0..] });
1182 try std.fs.makePath(self.gpa(), tmp_dir);
1181 const tmp_dir = try fs.path.join(self.arena(), &[_][]const u8{ zig_dir_path, comp_dir_name[0..] });
1182 try fs.makePath(self.gpa(), tmp_dir);
11831183 return tmp_dir;
11841184 }
11851185
......@@ -1351,7 +1351,7 @@ async fn addFnToLinkSet(comp: *Compilation, fn_val: *Value.Fn) Compilation.Build
13511351}
13521352
13531353fn getZigDir(allocator: *mem.Allocator) ![]u8 {
1354 return std.fs.getAppDataDir(allocator, "zig");
1354 return fs.getAppDataDir(allocator, "zig");
13551355}
13561356
13571357fn analyzeFnType(
src-self-hosted/introspect.zig+1-1
......@@ -14,7 +14,7 @@ pub fn testZigInstallPrefix(allocator: *mem.Allocator, test_path: []const u8) ![
1414 const test_index_file = try fs.path.join(allocator, &[_][]const u8{ test_zig_dir, "std", "std.zig" });
1515 defer allocator.free(test_index_file);
1616
17 var file = try fs.File.openRead(test_index_file);
17 var file = try fs.cwd().openRead(test_index_file);
1818 file.close();
1919
2020 return test_zig_dir;
src-self-hosted/main.zig+1-1
......@@ -724,7 +724,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
724724 if (try held.value.put(file_path, {})) |_| return;
725725 }
726726
727 const source_code = event.fs.readFile(
727 const source_code = fs.cwd().readFileAlloc(
728728 fmt.allocator,
729729 file_path,
730730 max_src_size,