From 68a6d43233f72495417268e4c7a68dd9f010ae27 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 13 Aug 2018 21:20:31 -0400 Subject: [PATCH] test/cli: fixup for supporting OSX --- test/cli.go | 2 ++ test/cli/0001.sh | 20 ++++++++++---------- test/cli/0002.sh | 4 ++-- test/cli/0003.sh | 6 +++--- test/cli/0004.sh | 4 ++-- test/cli/0005.sh | 4 ++-- test/cli/0006.sh | 4 ++-- test/cli/0007.sh | 6 +++--- test/cli/0008.sh | 2 +- test/cli/0009.sh | 4 ++-- test/doc.go | 3 +++ test/realpath.go | 22 ++++++++++++++++++++++ 12 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 test/doc.go create mode 100644 test/realpath.go diff --git a/test/cli.go b/test/cli.go index 3444579..1c47c65 100644 --- a/test/cli.go +++ b/test/cli.go @@ -1,3 +1,5 @@ +// +build ignore + package main import ( diff --git a/test/cli/0001.sh b/test/cli/0001.sh index a1b6cfa..5c9287e 100644 --- a/test/cli/0001.sh +++ b/test/cli/0001.sh @@ -3,8 +3,8 @@ set -e name=$(basename $0) root="$(dirname $(dirname $(dirname $0)))" -gomtree=$(readlink -f ${root}/gomtree) -t=$(mktemp -t -d go-mtree.XXXXXX) +gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree) +t=$(mktemp -d -t go-mtree.XXXXXX) echo "[${name}] Running in ${t}" # This test is for basic running check of manifest, and check against tar and file system @@ -12,33 +12,33 @@ echo "[${name}] Running in ${t}" pushd ${root} -git archive --format=tar HEAD^{tree} . > ${t}/${name}.tar +git archive --format=tar -o "${t}/${name}.tar" HEAD^{tree} prev_umask=$(umask) umask 0 # this is so the tar command can set the mode's properly mkdir -p ${t}/extract -tar -C ${t}/extract/ -xf ${t}/${name}.tar +tar -C ${t}/extract/ -xf "${t}/${name}.tar" umask ${prev_umask} # create manifest from tar -${gomtree} -K sha256digest -c -T ${t}/${name}.tar > ${t}/${name}.mtree +${gomtree} -K sha256digest -c -T "${t}/${name}.tar" > "${t}/${name}.mtree" # check tar-manifest against the tar -${gomtree} -f ${t}/${name}.mtree -T ${t}/${name}.tar +${gomtree} -f ${t}/${name}.mtree -T "${t}/${name}.tar" # check tar-manifest against the filesystem # git archive makes the uid/gid as 0, so don't check them for this test -${gomtree} -k size,sha256digest,mode,type -f ${t}/${name}.mtree -p ${t}/extract/ +${gomtree} -k size,sha256digest,mode,type -f "${t}/${name}.mtree" -p ${t}/extract/ # create a manifest from filesystem -${gomtree} -K sha256digest -c -p ${t}/extract/ > ${t}/${name}.mtree +${gomtree} -K sha256digest -c -p "${t}/extract/" > "${t}/${name}.mtree" # check filesystem-manifest against the filesystem -${gomtree} -f ${t}/${name}.mtree -p ${t}/extract/ +${gomtree} -f "${t}/${name}.mtree" -p "${t}/extract/" # check filesystem-manifest against the tar # git archive makes the uid/gid as 0, so don't check them for this test -${gomtree} -k size,sha256digest,mode,type -f ${t}/${name}.mtree -T ${t}/${name}.tar +${gomtree} -k size,sha256digest,mode,type -f "${t}/${name}.mtree" -T "${t}/${name}.tar" popd rm -rf ${t} diff --git a/test/cli/0002.sh b/test/cli/0002.sh index 56d139e..1f85803 100644 --- a/test/cli/0002.sh +++ b/test/cli/0002.sh @@ -3,8 +3,8 @@ set -e name=$(basename $0) root="$(dirname $(dirname $(dirname $0)))" -gomtree=$(readlink -f ${root}/gomtree) -t=$(mktemp -t -d go-mtree.XXXXXX) +gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree) +t=$(mktemp -d -t go-mtree.XXXXXX) echo "[${name}] Running in ${t}" # This test is for basic running check of manifest, and check against tar and file system diff --git a/test/cli/0003.sh b/test/cli/0003.sh index 3c992e2..0a074ed 100644 --- a/test/cli/0003.sh +++ b/test/cli/0003.sh @@ -3,10 +3,10 @@ set -e name=$(basename $0) root="$(dirname $(dirname $(dirname $0)))" -gomtree=$(readlink -f ${root}/gomtree) -t=$(mktemp -t -d go-mtree.XXXXXX) +gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree) +t=$(mktemp -d -t go-mtree.XXXXXX) -setfattr -n user.has.xattrs -v "true" "${t}" || exit 0 +setfattr -n user.has.xattrs -v "true" "${t}" || exit 0 echo "[${name}] Running in ${t}" diff --git a/test/cli/0004.sh b/test/cli/0004.sh index a86bd65..395777d 100644 --- a/test/cli/0004.sh +++ b/test/cli/0004.sh @@ -4,8 +4,8 @@ set -e name=$(basename $0) root="$(dirname $(dirname $(dirname $0)))" -gomtree=$(readlink -f ${root}/gomtree) -t=$(mktemp -t -d go-mtree.XXXXXX) +gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree) +t=$(mktemp -d -t go-mtree.XXXXXX) echo "[${name}] Running in ${t}" diff --git a/test/cli/0005.sh b/test/cli/0005.sh index c0680c4..97ecc11 100644 --- a/test/cli/0005.sh +++ b/test/cli/0005.sh @@ -3,8 +3,8 @@ set -e name=$(basename $0) root="$(dirname $(dirname $(dirname $0)))" -gomtree=$(readlink -f ${root}/gomtree) -t=$(mktemp -t -d go-mtree.XXXXXX) +gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree) +t=$(mktemp -d -t go-mtree.XXXXXX) echo "[${name}] Running in ${t}" diff --git a/test/cli/0006.sh b/test/cli/0006.sh index cd33f88..c1dd877 100644 --- a/test/cli/0006.sh +++ b/test/cli/0006.sh @@ -3,8 +3,8 @@ set -e name=$(basename $0) root="$(dirname $(dirname $(dirname $0)))" -gomtree=$(readlink -f ${root}/gomtree) -t=$(mktemp -t -d go-mtree.XXXXXX) +gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree) +t=$(mktemp -d -t go-mtree.XXXXXX) echo "[${name}] Running in ${t}" # This test is for basic running check of manifest, and check against tar and file system diff --git a/test/cli/0007.sh b/test/cli/0007.sh index ada1086..2e944ad 100644 --- a/test/cli/0007.sh +++ b/test/cli/0007.sh @@ -3,9 +3,9 @@ set -e name=$(basename $0) root="$(dirname $(dirname $(dirname $0)))" -gomtree=$(readlink -f ${root}/gomtree) -left=$(mktemp -t -d go-mtree.XXXXXX) -right=$(mktemp -t -d go-mtree.XXXXXX) +gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree) +left=$(mktemp -d -t go-mtree.XXXXXX) +right=$(mktemp -d -t go-mtree.XXXXXX) echo "[${name}] Running in ${left} and ${right}" diff --git a/test/cli/0008.sh b/test/cli/0008.sh index b32d43e..07c9ca4 100644 --- a/test/cli/0008.sh +++ b/test/cli/0008.sh @@ -3,7 +3,7 @@ set -e name=$(basename $0) root="$(dirname $(dirname $(dirname $0)))" -gomtree=$(readlink -f ${root}/gomtree) +gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree) t=$(mktemp -d /tmp/go-mtree.XXXXXX) echo "[${name}] Running in ${t}" diff --git a/test/cli/0009.sh b/test/cli/0009.sh index 01d0c57..d1adc63 100644 --- a/test/cli/0009.sh +++ b/test/cli/0009.sh @@ -3,8 +3,8 @@ set -e name=$(basename $0) root="$(dirname $(dirname $(dirname $0)))" -gomtree=$(readlink -f ${root}/gomtree) -t=$(mktemp -t -d go-mtree.XXXXXX) +gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree) +t=$(mktemp -d -t go-mtree.XXXXXX) echo "[${name}] Running in ${t}" diff --git a/test/doc.go b/test/doc.go new file mode 100644 index 0000000..7902d8e --- /dev/null +++ b/test/doc.go @@ -0,0 +1,3 @@ +package test + +// place holder for test helpers diff --git a/test/realpath.go b/test/realpath.go new file mode 100644 index 0000000..980eef2 --- /dev/null +++ b/test/realpath.go @@ -0,0 +1,22 @@ +// +build ignore + +package main + +import ( + "flag" + "fmt" + "os" + "path/filepath" +) + +func main() { + flag.Parse() + for _, arg := range flag.Args() { + path, err := filepath.Abs(arg) + if err != nil { + fmt.Fprint(os.Stderr, err) + os.Exit(1) + } + fmt.Printf("%s", path) + } +}