authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-03-02 00:50:39+01:00
committergravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-03-11 12:22:12+01:00
log10add7c677d368501691178ea0c073a9766cd498
treebeb81d132badb7e95f796379a0eb73fd860e20bc
parent04e8bbd932c9ce9ac99230a656c8951c467d5b24

std.tar: remove redundant test name prefixes


2 files changed, 22 insertions(+), 22 deletions(-)

lib/std/tar.zig+18-4
...@@ -656,7 +656,7 @@ fn stripComponents(path: []const u8, count: u32) []const u8 {...@@ -656,7 +656,7 @@ fn stripComponents(path: []const u8, count: u32) []const u8 {
656 return path[i..];656 return path[i..];
657}657}
658658
659test "tar stripComponents" {659test "stripComponents" {
660 const expectEqualStrings = std.testing.expectEqualStrings;660 const expectEqualStrings = std.testing.expectEqualStrings;
661 try expectEqualStrings("a/b/c", stripComponents("a/b/c", 0));661 try expectEqualStrings("a/b/c", stripComponents("a/b/c", 0));
662 try expectEqualStrings("b/c", stripComponents("a/b/c", 1));662 try expectEqualStrings("b/c", stripComponents("a/b/c", 1));
...@@ -665,7 +665,7 @@ test "tar stripComponents" {...@@ -665,7 +665,7 @@ test "tar stripComponents" {
665 try expectEqualStrings("", stripComponents("a/b/c", 4));665 try expectEqualStrings("", stripComponents("a/b/c", 4));
666}666}
667667
668test "tar PaxIterator" {668test "PaxIterator" {
669 const Attr = struct {669 const Attr = struct {
670 kind: PaxAttributeKind,670 kind: PaxAttributeKind,
671 value: []const u8 = undefined,671 value: []const u8 = undefined,
...@@ -793,7 +793,7 @@ test {...@@ -793,7 +793,7 @@ test {
793 _ = @import("tar/test.zig");793 _ = @import("tar/test.zig");
794}794}
795795
796test "tar header parse size" {796test "header parse size" {
797 const cases = [_]struct {797 const cases = [_]struct {
798 in: []const u8,798 in: []const u8,
799 want: u64 = 0,799 want: u64 = 0,
...@@ -828,7 +828,7 @@ test "tar header parse size" {...@@ -828,7 +828,7 @@ test "tar header parse size" {
828 }828 }
829}829}
830830
831test "tar header parse mode" {831test "header parse mode" {
832 const cases = [_]struct {832 const cases = [_]struct {
833 in: []const u8,833 in: []const u8,
834 want: u64 = 0,834 want: u64 = 0,
...@@ -871,3 +871,17 @@ test "create file and symlink" {...@@ -871,3 +871,17 @@ test "create file and symlink" {
871 _ = try createDirAndSymlink(root.dir, "../../../g/h/i/file4", "j/k/l/symlink3");871 _ = try createDirAndSymlink(root.dir, "../../../g/h/i/file4", "j/k/l/symlink3");
872 _ = try createDirAndFile(root.dir, "g/h/i/file4");872 _ = try createDirAndFile(root.dir, "g/h/i/file4");
873}873}
874
875test "insufficient buffer for iterator" {
876 var file_name_buffer: [10]u8 = undefined;
877 var link_name_buffer: [10]u8 = undefined;
878
879 var fsb = std.io.fixedBufferStream("");
880 try std.testing.expectError(
881 error.TarInsufficientBuffer,
882 iterator(fsb.reader(), .{
883 .file_name_buffer = &file_name_buffer,
884 .link_name_buffer = &link_name_buffer,
885 }),
886 );
887}
lib/std/tar/test.zig+4-18
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const tar = @import("../tar.zig");2const tar = @import("../tar.zig");
3const testing = std.testing;3const testing = std.testing;
44
5test "tar run Go test cases" {5test "run test cases" {
6 const Case = struct {6 const Case = struct {
7 const File = struct {7 const File = struct {
8 name: []const u8,8 name: []const u8,
...@@ -401,7 +401,7 @@ const Md5Writer = struct {...@@ -401,7 +401,7 @@ const Md5Writer = struct {
401 }401 }
402};402};
403403
404test "tar should not overwrite existing file" {404test "should not overwrite existing file" {
405 // Starting from this folder structure:405 // Starting from this folder structure:
406 // $ tree root406 // $ tree root
407 // root407 // root
...@@ -457,7 +457,7 @@ test "tar should not overwrite existing file" {...@@ -457,7 +457,7 @@ test "tar should not overwrite existing file" {
457 try tar.pipeToFileSystem(root2.dir, fsb.reader(), .{ .mode_mode = .ignore, .strip_components = 0 });457 try tar.pipeToFileSystem(root2.dir, fsb.reader(), .{ .mode_mode = .ignore, .strip_components = 0 });
458}458}
459459
460test "tar case sensitivity" {460test "case sensitivity" {
461 // Mimicking issue #18089, this tar contains, same file name in two case461 // Mimicking issue #18089, this tar contains, same file name in two case
462 // sensitive name version. Should fail on case insensitive file systems.462 // sensitive name version. Should fail on case insensitive file systems.
463 //463 //
...@@ -484,7 +484,7 @@ test "tar case sensitivity" {...@@ -484,7 +484,7 @@ test "tar case sensitivity" {
484 try testing.expect((try root.dir.statFile("alacritty/Darkermatrix.yml")).kind == .file);484 try testing.expect((try root.dir.statFile("alacritty/Darkermatrix.yml")).kind == .file);
485}485}
486486
487test "tar pipeToFileSystem" {487test "pipeToFileSystem" {
488 // $ tar tvf488 // $ tar tvf
489 // pipe_to_file_system_test/489 // pipe_to_file_system_test/
490 // pipe_to_file_system_test/b/490 // pipe_to_file_system_test/b/
...@@ -515,17 +515,3 @@ test "tar pipeToFileSystem" {...@@ -515,17 +515,3 @@ test "tar pipeToFileSystem" {
515 var buf: [32]u8 = undefined;515 var buf: [32]u8 = undefined;
516 try testing.expectEqualSlices(u8, "../a/file", try root.dir.readLink("b/symlink", &buf));516 try testing.expectEqualSlices(u8, "../a/file", try root.dir.readLink("b/symlink", &buf));
517}517}
518
519test "insufficient buffer for iterator" {
520 var file_name_buffer: [10]u8 = undefined;
521 var link_name_buffer: [10]u8 = undefined;
522
523 var fsb = std.io.fixedBufferStream("");
524 try testing.expectError(
525 error.TarInsufficientBuffer,
526 tar.iterator(fsb.reader(), .{
527 .file_name_buffer = &file_name_buffer,
528 .link_name_buffer = &link_name_buffer,
529 }),
530 );
531}