Skip to content

Commit d5ab737

Browse files
authored
fix(internal/docuploader): find right tar executable for macOS (#4121)
The test failed in darwin system because option `--xform` is not supported by `tar` command. The right command is `gtar`. Fix the test by requiring different executable with respect to systems.
1 parent f09f60c commit d5ab737

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

internal/docuploader/archive_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"log/slog"
2020
"os"
2121
"path/filepath"
22+
"runtime"
2223
"slices"
2324
"strings"
2425
"testing"
@@ -29,7 +30,15 @@ import (
2930
)
3031

3132
func TestCreateArchive(t *testing.T) {
32-
testhelper.RequireCommand(t, "tar")
33+
var tarExe string
34+
opSys := runtime.GOOS
35+
switch opSys {
36+
case "darwin":
37+
tarExe = "gtar"
38+
default:
39+
tarExe = "tar"
40+
}
41+
testhelper.RequireCommand(t, tarExe)
3342
dir := t.TempDir()
3443
paths := []string{
3544
"other.txt",
@@ -52,7 +61,7 @@ func TestCreateArchive(t *testing.T) {
5261
sourceDir := filepath.Join(dir, "docs")
5362
targetFile := filepath.Join(dir, "target.tar.gz")
5463

55-
if err := CreateArchive(t.Context(), "tar", sourceDir, targetFile); err != nil {
64+
if err := CreateArchive(t.Context(), tarExe, sourceDir, targetFile); err != nil {
5665
t.Fatal(err)
5766
}
5867

0 commit comments

Comments
 (0)