-
Notifications
You must be signed in to change notification settings - Fork 159
/
.travis.yml
90 lines (74 loc) · 2.72 KB
/
.travis.yml
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
language: go
os:
- linux
- osx
env:
- CLANG=3.9
matrix:
include:
- env: CLANG=3.8
os: linux
- env: CLANG=3.7
os: linux
- env: CLANG=3.6
os: linux
- env: CLANG=3.4
os: linux
before_install:
- |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-add-repository "deb http://apt.llvm.org/precise/ llvm-toolchain-precise-$CLANG main"
sudo apt-get update
sudo apt-cache search clang
sudo apt-get install -f -y --force-yes clang-$CLANG lldb-$CLANG
fi
- |
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
rvm get head
fi
# gocovmerge is used to merge all the separate unit/integration test coverage
# profiles.
- go get -u github.com/wadey/gocovmerge
script:
- . ./.travis.gofmt.sh
# Run the unit/integration tests first
- |
set -e
echo "" > coverage.txt
# The code below was copied from:
# https://github.com/golang/go/issues/6909#issuecomment-232878416
#
# As in @rodrigocorsi2 comment above (using full path to grep due to
# 'grep -n' alias).
export PKGS=$(go list ./... | grep -v c2go/build | /usr/bin/grep -v /vendor/)
# Make comma-separated.
export PKGS_DELIM=$(echo "$PKGS" | paste -sd "," -)
# Run tests and append all output to out.txt. It's important we have "-v"
# so that all the test names are printed.
rm -f /tmp/out.txt
go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}go test -v -tags=integration -race -coverprofile {{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile -coverpkg $PKGS_DELIM {{.ImportPath}}{{end}} >> /tmp/out.txt' $PKGS | xargs -I {} bash -c {}
if [ $? -ne 0 ]; then
# Print out the failures (removing a lot of the noise).
cat /tmp/out.txt | grep -v -- "--- PASS" | grep -v -- "=== RUN"
exit 1
fi
# Merge coverage profiles.
gocovmerge `ls *.coverprofile` > coverage.txt
rm *.coverprofile
# Print stats
echo "Unit tests: " $(grep "=== RUN" /tmp/out.txt | wc -l)
# These steps are from the README to verify it can be installed and run as
# documented.
- cd /tmp
- export C2GO=$GOPATH/src/github.com/elliotchance/c2go
- c2go transpile $C2GO/tests/prime.c
- echo "47" | go run prime.go
- if [ $(c2go -v | wc -l) -ne 1 ]; then exit 1; fi
- if [ $(cat prime.go | wc -l) -eq 0 ]; then exit 1; fi
- if [ $(c2go ast $C2GO/tests/prime.c | wc -l) -eq 0 ]; then exit 1; fi
# Revert the cwd for any cleanup commands.
- cd -
after_success:
- include_cov=coverage.txt bash <(curl -s https://codecov.io/bash)