Add builder.findProgram test and fix references

master
Benjamin Feng 2019-07-31 21:26:39 -05:00
parent d6d0bb0542
commit e40513e97f
1 changed files with 13 additions and 4 deletions

View File

@ -805,7 +805,7 @@ pub const Builder = struct {
return name; return name;
} }
const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) }); const full_path = try fs.path.join(self.allocator, [_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) });
if (fs.path.real(self.allocator, full_path)) |real_path| { if (fs.realpathAlloc(self.allocator, full_path)) |real_path| {
return real_path; return real_path;
} else |_| { } else |_| {
continue; continue;
@ -817,10 +817,10 @@ pub const Builder = struct {
if (fs.path.isAbsolute(name)) { if (fs.path.isAbsolute(name)) {
return name; return name;
} }
var it = mem.tokenize(PATH, []u8{fs.path.delimiter}); var it = mem.tokenize(PATH, [_]u8{fs.path.delimiter});
while (it.next()) |path| { while (it.next()) |path| {
const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
if (fs.path.real(self.allocator, full_path)) |real_path| { if (fs.realpathAlloc(self.allocator, full_path)) |real_path| {
return real_path; return real_path;
} else |_| { } else |_| {
continue; continue;
@ -834,7 +834,7 @@ pub const Builder = struct {
} }
for (paths) |path| { for (paths) |path| {
const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) }); const full_path = try fs.path.join(self.allocator, [_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
if (fs.path.real(self.allocator, full_path)) |real_path| { if (fs.realpathAlloc(self.allocator, full_path)) |real_path| {
return real_path; return real_path;
} else |_| { } else |_| {
continue; continue;
@ -904,6 +904,15 @@ pub const Builder = struct {
} }
}; };
test "builder.findProgram compiles" {
//allocator: *Allocator,
//zig_exe: []const u8,
//build_root: []const u8,
//cache_root: []const u8,
const builder = try Builder.create(std.heap.direct_allocator, "zig", "zig-cache", "zig-cache");
_ = builder.findProgram([_][]const u8{}, [_][]const u8{}) catch null;
}
pub const Version = struct { pub const Version = struct {
major: u32, major: u32,
minor: u32, minor: u32,