| ... | ... | @@ -2040,7 +2040,7 @@ const UnpackResult = struct { |
| 2040 | 2040 | defer errors.deinit(gpa); |
| 2041 | 2041 | var aw: Io.Writer.Allocating = .init(gpa); |
| 2042 | 2042 | defer aw.deinit(); |
| 2043 | | try errors.renderToWriter(.{}, &aw.writer, .no_color); |
| 2043 | try errors.renderToWriter(.{}, &aw.writer); |
| 2044 | 2044 | try std.testing.expectEqualStrings( |
| 2045 | 2045 | \\error: unable to unpack |
| 2046 | 2046 | \\ note: unable to create symlink from 'dir2/file2' to 'filename': SymlinkError |
| ... | ... | @@ -2210,13 +2210,13 @@ test "set executable bit based on file content" { |
| 2210 | 2210 | defer out.close(io); |
| 2211 | 2211 | const S = std.posix.S; |
| 2212 | 2212 | // expect executable bit not set |
| 2213 | | try std.testing.expect((try out.statFile(io, "file1", .{})).mode & S.IXUSR == 0); |
| 2214 | | try std.testing.expect((try out.statFile(io, "script_without_shebang", .{})).mode & S.IXUSR == 0); |
| 2213 | try std.testing.expect((try out.statFile(io, "file1", .{})).permissions.toMode() & S.IXUSR == 0); |
| 2214 | try std.testing.expect((try out.statFile(io, "script_without_shebang", .{})).permissions.toMode() & S.IXUSR == 0); |
| 2215 | 2215 | // expect executable bit set |
| 2216 | | try std.testing.expect((try out.statFile(io, "hello", .{})).mode & S.IXUSR != 0); |
| 2217 | | try std.testing.expect((try out.statFile(io, "script", .{})).mode & S.IXUSR != 0); |
| 2218 | | try std.testing.expect((try out.statFile(io, "script_with_shebang_without_exec_bit", .{})).mode & S.IXUSR != 0); |
| 2219 | | try std.testing.expect((try out.statFile(io, "hello_ln", .{})).mode & S.IXUSR != 0); |
| 2216 | try std.testing.expect((try out.statFile(io, "hello", .{})).permissions.toMode() & S.IXUSR != 0); |
| 2217 | try std.testing.expect((try out.statFile(io, "script", .{})).permissions.toMode() & S.IXUSR != 0); |
| 2218 | try std.testing.expect((try out.statFile(io, "script_with_shebang_without_exec_bit", .{})).permissions.toMode() & S.IXUSR != 0); |
| 2219 | try std.testing.expect((try out.statFile(io, "hello_ln", .{})).permissions.toMode() & S.IXUSR != 0); |
| 2220 | 2220 | |
| 2221 | 2221 | // |
| 2222 | 2222 | // $ ls -al zig-cache/tmp/OCz9ovUcstDjTC_U/zig-global-cache/p/1220fecb4c06a9da8673c87fe8810e15785f1699212f01728eadce094d21effeeef3 |
| ... | ... | @@ -2233,7 +2233,7 @@ fn saveEmbedFile(io: Io, comptime tarball_name: []const u8, dir: Io.Dir) !void { |
| 2233 | 2233 | const tarball_content = @embedFile("Fetch/testdata/" ++ tarball_name); |
| 2234 | 2234 | var tmp_file = try dir.createFile(io, tarball_name, .{}); |
| 2235 | 2235 | defer tmp_file.close(io); |
| 2236 | | try tmp_file.writeAll(tarball_content); |
| 2236 | try tmp_file.writeStreamingAll(io, tarball_content); |
| 2237 | 2237 | } |
| 2238 | 2238 | |
| 2239 | 2239 | // Builds Fetch with required dependencies, clears dependencies on deinit(). |
| ... | ... | @@ -2316,21 +2316,22 @@ const TestFetchBuilder = struct { |
| 2316 | 2316 | // expected_files must be sorted. |
| 2317 | 2317 | fn expectPackageFiles(self: *TestFetchBuilder, expected_files: []const []const u8) !void { |
| 2318 | 2318 | const io = self.job_queue.io; |
| 2319 | const gpa = std.testing.allocator; |
| 2319 | 2320 | |
| 2320 | 2321 | var package_dir = try self.packageDir(); |
| 2321 | 2322 | defer package_dir.close(io); |
| 2322 | 2323 | |
| 2323 | 2324 | var actual_files: std.ArrayList([]u8) = .empty; |
| 2324 | | defer actual_files.deinit(std.testing.allocator); |
| 2325 | | defer for (actual_files.items) |file| std.testing.allocator.free(file); |
| 2326 | | var walker = try package_dir.walk(std.testing.allocator); |
| 2325 | defer actual_files.deinit(gpa); |
| 2326 | defer for (actual_files.items) |file| gpa.free(file); |
| 2327 | var walker = try package_dir.walk(gpa); |
| 2327 | 2328 | defer walker.deinit(); |
| 2328 | | while (try walker.next()) |entry| { |
| 2329 | while (try walker.next(io)) |entry| { |
| 2329 | 2330 | if (entry.kind != .file) continue; |
| 2330 | | const path = try std.testing.allocator.dupe(u8, entry.path); |
| 2331 | | errdefer std.testing.allocator.free(path); |
| 2331 | const path = try gpa.dupe(u8, entry.path); |
| 2332 | errdefer gpa.free(path); |
| 2332 | 2333 | std.mem.replaceScalar(u8, path, std.fs.path.sep, '/'); |
| 2333 | | try actual_files.append(std.testing.allocator, path); |
| 2334 | try actual_files.append(gpa, path); |
| 2334 | 2335 | } |
| 2335 | 2336 | std.mem.sortUnstable([]u8, actual_files.items, {}, struct { |
| 2336 | 2337 | fn lessThan(_: void, a: []u8, b: []u8) bool { |
| ... | ... | @@ -2347,17 +2348,19 @@ const TestFetchBuilder = struct { |
| 2347 | 2348 | |
| 2348 | 2349 | // Test helper, asserts that fetch has failed with `msg` error message. |
| 2349 | 2350 | fn expectFetchErrors(self: *TestFetchBuilder, notes_len: usize, msg: []const u8) !void { |
| 2351 | const gpa = std.testing.allocator; |
| 2352 | |
| 2350 | 2353 | var errors = try self.fetch.error_bundle.toOwnedBundle(""); |
| 2351 | | defer errors.deinit(std.testing.allocator); |
| 2354 | defer errors.deinit(gpa); |
| 2352 | 2355 | |
| 2353 | 2356 | const em = errors.getErrorMessage(errors.getMessages()[0]); |
| 2354 | 2357 | try std.testing.expectEqual(1, em.count); |
| 2355 | 2358 | if (notes_len > 0) { |
| 2356 | 2359 | try std.testing.expectEqual(notes_len, em.notes_len); |
| 2357 | 2360 | } |
| 2358 | | var aw: Io.Writer.Allocating = .init(std.testing.allocator); |
| 2361 | var aw: Io.Writer.Allocating = .init(gpa); |
| 2359 | 2362 | defer aw.deinit(); |
| 2360 | | try errors.renderToWriter(.{}, &aw.writer, .no_color); |
| 2363 | try errors.renderToWriter(.{}, &aw.writer); |
| 2361 | 2364 | try std.testing.expectEqualStrings(msg, aw.written()); |
| 2362 | 2365 | } |
| 2363 | 2366 | }; |