archive: Explicitly specify stdio for tar(1)
Different tar(1) implementations default to different input and output locations when none is specified. This can include tape devices like /dev/st0 (on Linux) or /dev/sa0 (on FreeBSD), but may be overridden by compilation options or environment variables. Using the f option with the special value of - instructs tar(1) to read from stdin and write to stdout instead of the default. Signed-off-by: Samuel Karp <me@samuelkarp.com>
This commit is contained in:
parent
95f1d79718
commit
5560b622d6
@ -844,7 +844,7 @@ func testApply(t *testing.T, a fstest.Applier) error {
|
|||||||
return fmt.Errorf("failed to apply filesystem changes: %w", err)
|
return fmt.Errorf("failed to apply filesystem changes: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tarArgs := []string{"c", "-C", td}
|
tarArgs := []string{"cf", "-", "-C", td}
|
||||||
names, err := readDirNames(td)
|
names, err := readDirNames(td)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read directory names: %w", err)
|
return fmt.Errorf("failed to read directory names: %w", err)
|
||||||
@ -879,9 +879,12 @@ func testBaseDiff(t *testing.T, a fstest.Applier) error {
|
|||||||
|
|
||||||
arch := Diff(context.Background(), "", td)
|
arch := Diff(context.Background(), "", td)
|
||||||
|
|
||||||
cmd := exec.Command(tarCmd, "x", "-C", dest)
|
cmd := exec.Command(tarCmd, "xf", "-", "-C", dest)
|
||||||
cmd.Stdin = arch
|
cmd.Stdin = arch
|
||||||
|
stderr := &bytes.Buffer{}
|
||||||
|
cmd.Stderr = stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
|
fmt.Println(stderr.String())
|
||||||
return fmt.Errorf("tar command failed: %w", err)
|
return fmt.Errorf("tar command failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user