mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
SetupTarTestFixture: don't depend on "sh"
This commit is contained in:
parent
4f8cc1180d
commit
c228a212b0
@ -88,19 +88,18 @@ func RandomReader(seed, size int) *bytes.Reader {
|
|||||||
|
|
||||||
// SetupTarTestFixture extracts the tarFile to outputDir.
|
// SetupTarTestFixture extracts the tarFile to outputDir.
|
||||||
func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) {
|
func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) {
|
||||||
err := System("sh", "-c", `(cd "$1" && tar xzf - ) < "$2"`,
|
f, err := os.Open(tarFile)
|
||||||
"sh", outputDir, tarFile)
|
defer f.Close()
|
||||||
OK(t, err)
|
OK(t, err)
|
||||||
}
|
|
||||||
|
|
||||||
// System runs the command and returns the exit code. Output is passed on to
|
cmd := exec.Command("tar", "xzf", "-")
|
||||||
// stdout/stderr.
|
cmd.Dir = outputDir
|
||||||
func System(command string, args ...string) error {
|
|
||||||
cmd := exec.Command(command, args...)
|
cmd.Stdin = f
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
return cmd.Run()
|
OK(t, cmd.Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithTestEnvironment creates a test environment, extracts the repository
|
// WithTestEnvironment creates a test environment, extracts the repository
|
||||||
|
Loading…
Reference in New Issue
Block a user