Jelajahi Sumber

test and cover multiple packages

Tao Wen 8 tahun lalu
induk
melakukan
f60a6a17c2
3 mengubah file dengan 15 tambahan dan 1 penghapusan
  1. 2 0
      .gitignore
  2. 1 1
      .travis.yml
  3. 12 0
      test.sh

+ 2 - 0
.gitignore

@@ -1 +1,3 @@
 .idea
+/coverage.txt
+/profile.out

+ 1 - 1
.travis.yml

@@ -8,7 +8,7 @@ before_install:
   - go get -t -v ./...
 
 script:
-  - go test -race -coverprofile=coverage.txt -covermode=atomic
+  - ./test.sh
 
 after_success:
   - bash <(curl -s https://codecov.io/bash)

+ 12 - 0
test.sh

@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+set -e
+echo "" > coverage.txt
+
+for d in $(go list ./... | grep -v vendor); do
+    go test -race -coverprofile=profile.out -covermode=atomic $d
+    if [ -f profile.out ]; then
+        cat profile.out >> coverage.txt
+        rm profile.out
+    fi
+done