Skip to content

Commit

Permalink
Test_wrapCmd
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAbides committed Dec 9, 2023
1 parent acc07cb commit 88aa45d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cmd/bindown/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -478,3 +479,32 @@ url_checksums:
require.NoFileExists(t, filepath.Join(runner.tmpDir, "bin", "foo"))
})
}

func Test_wrapCmd(t *testing.T) {
t.Run("bindown path", func(t *testing.T) {
runner := newCmdRunner(t)
servePath := testdataPath("downloadables/runnable.tar.gz")
ts := testutil.ServeFile(t, servePath, "/runnable/runnable.tar.gz", "")
depURL := ts.URL + "/runnable/runnable.tar.gz"
runner.writeConfigYaml(fmt.Sprintf(`
dependencies:
runnable:
archive_path: bin/runnable.sh
url: %s
url_checksums:
%s: fb2fe41a34b77ee180def0cb9a222d8776a6e581106009b64f35983da291ab6e
`, depURL, depURL))
outputDir := filepath.Join(runner.tmpDir, "output")
runnable := filepath.Join(outputDir, "runnable")
result := runner.run("wrap", "runnable", "--bindown", testutil.BindownBin(), "--output", runnable)
result.assertState(resultState{stdout: runnable})
testutil.AssertFile(t, runnable, true, false)
testutil.CheckGoldenDir(t, outputDir, filepath.FromSlash("testdata/golden/wrap/bindown-path"))

// make sure it runs
cmd := exec.Command("sh", "-c", filepath.ToSlash(runnable))
out, err := cmd.Output()
require.NoError(t, err)
require.Equal(t, "Hello world", strings.TrimSpace(string(out)))
})
}
15 changes: 15 additions & 0 deletions cmd/bindown/testdata/golden/wrap/bindown-path/runnable
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
# Code generated by bindown. DO NOT EDIT.

set -e

bindown_bin="$(
CDPATH="" cd -- "$(dirname -- "$0")"
"../../../../../../../../../Users/wroden/repos/WillAbides/bindown/tmp/_test/bindown" install "runnable" \
--to-cache \
--configfile "../.bindown.yaml" \
--cache "../cache"
)"

exec "$bindown_bin" "$@"

0 comments on commit 88aa45d

Please sign in to comment.