~mvo/snappy/snappy-snapfs-refactor-ftw

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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/sh

set -eu

if which goctest >/dev/null; then
    goctest="goctest"
else
    goctest="go test"
fi

QUICK=""
if [ "${1:-}" = "--quick" ]; then
    QUICK=yes
fi

endmsg() {
    if [ $? -eq 0 ]; then
        p="success.txt"
        m="All good, what could possibly go wrong."
    else
        p="failure.txt"
        m="Crushing failure and despair."
    fi
    echo
    if [ -t 1 -a -z "$QUICK" ]; then
        cat "data/$p"
    else
        echo "$m"
    fi
}
trap endmsg EXIT

echo Checking docs
./mdlint.py docs/*.md

echo Checking formatting
fmt=$(gofmt -l .)

if [ -n "$fmt" ]; then
    echo "Formatting wrong in following files"
    echo "$fmt"
    exit 1
fi

if [ -z "$QUICK" ]; then
    echo Installing godeps
    go get launchpad.net/godeps
    export PATH=$PATH:$GOPATH/bin

    echo Install golint
    go get github.com/golang/lint/golint
    export PATH=$PATH:$GOPATH/bin

    echo Obtaining dependencies
    godeps -u dependencies.tsv

    echo Building
    go build -v launchpad.net/snappy/...


    # tests
    echo Running tests from $(pwd)
    $goctest -v -cover ./...
fi

# go vet
echo Running vet
go vet ./...
go vet ./_integration-tests/tests/...
go vet ./_integration-tests/testutils/...

# golint
echo Running lint
lint=$(golint ./... && golint ./_integration-tests/testutils/... && golint ./_integration-tests/tests/...)
if [ -n "$lint" ]; then
    echo "Lint complains:"
    echo "$lint"
    exit 1
fi

(
    # pot file
    TMPF="$(mktemp)"
    trap "rm -f $TMPF" 0
    ./update-pot "$TMPF"
    if ! diff -u --ignore-matching-lines=.*POT-Creation-Date.* po/snappy.pot $TMPF; then
        echo "You need to run ./update-pot"
        exit 1
    fi
    # This is a subshell so we don't overwrite the all-important outer trap.
)

if [ -z "$QUICK" ]; then
    # integration tests
    echo Building the integration tests
    go build _integration-tests/main.go

    # the rabbit hole
    echo Running the tests for the integration testutils
    $goctest -v -cover ./_integration-tests/testutils/...

    # integration suite in kvm
    if which adt-run >/dev/null 2>&1; then
        echo "Running integration tests on rolling edge"
        go run _integration-tests/main.go --snappy-from-branch
        # print the results.
        if which subunit2pyunit >/dev/null 2>&1; then
            subunit-1to2 /tmp/snappy-test/output/artifacts/results.subunit | subunit2pyunit
        fi
    fi
fi