File: test.sh

package info (click to toggle)
golang-github-cloudflare-cfssl 1.2.0%2Bgit20160825.89.7fb22c8-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,916 kB
  • ctags: 2,827
  • sloc: sh: 146; sql: 62; python: 11; makefile: 8
file content (71 lines) | stat: -rwxr-xr-x 1,716 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -o errexit

CDIR=$(cd `dirname "$0"` && pwd)
cd "$CDIR"

ORG_PATH="github.com/cloudflare"
REPO_PATH="${ORG_PATH}/cfssl"

export GOPATH="${CDIR}/gopath"

export PATH="${PATH}:${GOPATH}/bin"

eval $(go env)

if [ ! -h gopath/src/${REPO_PATH} ]; then
    mkdir -p gopath/src/${ORG_PATH}
    ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
fi

ls "${GOPATH}/src/${REPO_PATH}"

PACKAGES=""
if [ "$#" != 0 ]; then
    for pkg in "$@"; do
        PACKAGES="$PACKAGES $REPO_PATH/$pkg"
    done
else
    PACKAGES=$(go list ./... | grep -v /vendor/ | grep ^_)
    # Escape current cirectory
    CDIR_ESC=$(printf "%q" "$CDIR/")
    # Remove current directory from the package path
    PACKAGES=${PACKAGES//$CDIR_ESC/}
    # Remove underscores
    PACKAGES=${PACKAGES//_/}
    # split PACKAGES into an array and prepend REPO_PATH to each local package
    split=(${PACKAGES// / })
    PACKAGES=${split[@]/#/${REPO_PATH}/}
fi

go vet $PACKAGES
if ! which fgt > /dev/null ; then
    go get github.com/GeertJohan/fgt
fi

if ! which golint > /dev/null ; then
    go get github.com/golang/lint/golint
fi

for package in $PACKAGES
do
    fgt golint "${package}"
done

# check go fmt
for package in $PACKAGES
do
    test -z "$(gofmt -s -l $GOPATH/src/$package/ | tee /dev/stderr)"
done

# Build and install cfssl executable in PATH
go install -tags "$BUILD_TAGS" ${REPO_PATH}/cmd/cfssl

COVPROFILES=""
for package in $(go list -f '{{if len .TestGoFiles}}{{.ImportPath}}{{end}}' $PACKAGES)
do
    profile="$GOPATH/src/$package/.coverprofile"
    go test -race -tags "$BUILD_TAGS" --coverprofile=$profile $package
    [ -s $profile ] && COVPROFILES="$COVPROFILES $profile"
done
cat $COVPROFILES > coverprofile.txt