test/cli: fixup for supporting OSX
This commit is contained in:
parent
1bcf4de08f
commit
68a6d43233
12 changed files with 54 additions and 27 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -3,8 +3,8 @@ set -e
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
root="$(dirname $(dirname $(dirname $0)))"
|
root="$(dirname $(dirname $(dirname $0)))"
|
||||||
gomtree=$(readlink -f ${root}/gomtree)
|
gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree)
|
||||||
t=$(mktemp -t -d go-mtree.XXXXXX)
|
t=$(mktemp -d -t go-mtree.XXXXXX)
|
||||||
|
|
||||||
echo "[${name}] Running in ${t}"
|
echo "[${name}] Running in ${t}"
|
||||||
# This test is for basic running check of manifest, and check against tar and file system
|
# 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}
|
pushd ${root}
|
||||||
|
|
||||||
git archive --format=tar HEAD^{tree} . > ${t}/${name}.tar
|
git archive --format=tar -o "${t}/${name}.tar" HEAD^{tree}
|
||||||
|
|
||||||
prev_umask=$(umask)
|
prev_umask=$(umask)
|
||||||
umask 0 # this is so the tar command can set the mode's properly
|
umask 0 # this is so the tar command can set the mode's properly
|
||||||
mkdir -p ${t}/extract
|
mkdir -p ${t}/extract
|
||||||
tar -C ${t}/extract/ -xf ${t}/${name}.tar
|
tar -C ${t}/extract/ -xf "${t}/${name}.tar"
|
||||||
umask ${prev_umask}
|
umask ${prev_umask}
|
||||||
|
|
||||||
# create manifest from tar
|
# 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
|
# 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
|
# check tar-manifest against the filesystem
|
||||||
# git archive makes the uid/gid as 0, so don't check them for this test
|
# 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
|
# 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
|
# 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
|
# check filesystem-manifest against the tar
|
||||||
# git archive makes the uid/gid as 0, so don't check them for this test
|
# 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
|
popd
|
||||||
rm -rf ${t}
|
rm -rf ${t}
|
||||||
|
|
|
@ -3,8 +3,8 @@ set -e
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
root="$(dirname $(dirname $(dirname $0)))"
|
root="$(dirname $(dirname $(dirname $0)))"
|
||||||
gomtree=$(readlink -f ${root}/gomtree)
|
gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree)
|
||||||
t=$(mktemp -t -d go-mtree.XXXXXX)
|
t=$(mktemp -d -t go-mtree.XXXXXX)
|
||||||
|
|
||||||
echo "[${name}] Running in ${t}"
|
echo "[${name}] Running in ${t}"
|
||||||
# This test is for basic running check of manifest, and check against tar and file system
|
# This test is for basic running check of manifest, and check against tar and file system
|
||||||
|
|
|
@ -3,8 +3,8 @@ set -e
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
root="$(dirname $(dirname $(dirname $0)))"
|
root="$(dirname $(dirname $(dirname $0)))"
|
||||||
gomtree=$(readlink -f ${root}/gomtree)
|
gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree)
|
||||||
t=$(mktemp -t -d go-mtree.XXXXXX)
|
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
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ set -e
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
root="$(dirname $(dirname $(dirname $0)))"
|
root="$(dirname $(dirname $(dirname $0)))"
|
||||||
gomtree=$(readlink -f ${root}/gomtree)
|
gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree)
|
||||||
t=$(mktemp -t -d go-mtree.XXXXXX)
|
t=$(mktemp -d -t go-mtree.XXXXXX)
|
||||||
|
|
||||||
echo "[${name}] Running in ${t}"
|
echo "[${name}] Running in ${t}"
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ set -e
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
root="$(dirname $(dirname $(dirname $0)))"
|
root="$(dirname $(dirname $(dirname $0)))"
|
||||||
gomtree=$(readlink -f ${root}/gomtree)
|
gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree)
|
||||||
t=$(mktemp -t -d go-mtree.XXXXXX)
|
t=$(mktemp -d -t go-mtree.XXXXXX)
|
||||||
|
|
||||||
echo "[${name}] Running in ${t}"
|
echo "[${name}] Running in ${t}"
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ set -e
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
root="$(dirname $(dirname $(dirname $0)))"
|
root="$(dirname $(dirname $(dirname $0)))"
|
||||||
gomtree=$(readlink -f ${root}/gomtree)
|
gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree)
|
||||||
t=$(mktemp -t -d go-mtree.XXXXXX)
|
t=$(mktemp -d -t go-mtree.XXXXXX)
|
||||||
|
|
||||||
echo "[${name}] Running in ${t}"
|
echo "[${name}] Running in ${t}"
|
||||||
# This test is for basic running check of manifest, and check against tar and file system
|
# This test is for basic running check of manifest, and check against tar and file system
|
||||||
|
|
|
@ -3,9 +3,9 @@ set -e
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
root="$(dirname $(dirname $(dirname $0)))"
|
root="$(dirname $(dirname $(dirname $0)))"
|
||||||
gomtree=$(readlink -f ${root}/gomtree)
|
gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree)
|
||||||
left=$(mktemp -t -d go-mtree.XXXXXX)
|
left=$(mktemp -d -t go-mtree.XXXXXX)
|
||||||
right=$(mktemp -t -d go-mtree.XXXXXX)
|
right=$(mktemp -d -t go-mtree.XXXXXX)
|
||||||
|
|
||||||
echo "[${name}] Running in ${left} and ${right}"
|
echo "[${name}] Running in ${left} and ${right}"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ set -e
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
root="$(dirname $(dirname $(dirname $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)
|
t=$(mktemp -d /tmp/go-mtree.XXXXXX)
|
||||||
|
|
||||||
echo "[${name}] Running in ${t}"
|
echo "[${name}] Running in ${t}"
|
||||||
|
|
|
@ -3,8 +3,8 @@ set -e
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
root="$(dirname $(dirname $(dirname $0)))"
|
root="$(dirname $(dirname $(dirname $0)))"
|
||||||
gomtree=$(readlink -f ${root}/gomtree)
|
gomtree=$(go run ${root}/test/realpath.go ${root}/gomtree)
|
||||||
t=$(mktemp -t -d go-mtree.XXXXXX)
|
t=$(mktemp -d -t go-mtree.XXXXXX)
|
||||||
|
|
||||||
echo "[${name}] Running in ${t}"
|
echo "[${name}] Running in ${t}"
|
||||||
|
|
||||||
|
|
3
test/doc.go
Normal file
3
test/doc.go
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
package test
|
||||||
|
|
||||||
|
// place holder for test helpers
|
22
test/realpath.go
Normal file
22
test/realpath.go
Normal file
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue