Skip to content

Commit

Permalink
Skip tarz test on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
bertold committed Jul 1, 2024
1 parent 7cb3f4c commit 4efeead
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"

"github.com/dsnet/compress/bzip2"
Expand Down Expand Up @@ -93,22 +94,27 @@ proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`
}

tests := []struct {
name string
compressor compressor
extension string
name string
compressor compressor
extension string
skipWindows bool
}{
{"tar", &tarCompressor{}, "tar"},
{"tarZ", &tarZCompressor{}, "tar.z"},
{"tarBzip", &tarBzipCompressor{}, "tar.bz2"},
{"tarXZ", &tarXZCompressor{}, "tar.xz"},
{"tarGzip", &tarGzipCompressor{}, "tar.gz"},
{"tar", &tarCompressor{}, "tar", false},
{"tarZ", &tarZCompressor{}, "tar.z", true},
{"tarBzip", &tarBzipCompressor{}, "tar.bz2", false},
{"tarXZ", &tarXZCompressor{}, "tar.xz", false},
{"tarGzip", &tarGzipCompressor{}, "tar.gz", false},
}

for i := range tests {
test := tests[i]
t.Run(test.name, func(t *testing.T) {
t.Parallel()

if runtime.GOOS == "windows" && test.skipWindows {
t.Log("skipping test on windows")
}

archiveBase := filepath.Join(destFilesDir, "archive")
err := test.compressor.Compress(t, sourceFilesDir, archiveBase)
require.NoError(t, err)
Expand Down Expand Up @@ -194,7 +200,7 @@ func (c *tarZCompressor) Compress(t *testing.T, sourceDir string, destBase strin
tarFile.Close()

cmd := exec.Command("compress", tarFilename).Run()
assert.Nil(t, cmd)
assert.NoError(t, cmd)

return nil
}
Expand Down

0 comments on commit 4efeead

Please sign in to comment.