Andrea Barberio 7 лет назад
Родитель
Сommit
db6f273f55
3 измененных файлов с 50 добавлено и 5 удалено
  1. 24 0
      .travis.yml
  2. 24 0
      .travis/tests.sh
  3. 2 5
      config/config.go

+ 24 - 0
.travis.yml

@@ -0,0 +1,24 @@
+language: go
+
+sudo: required
+
+go:
+  - "1.9"
+  - "1.10"
+  - "1.11"
+  - tip
+
+before_install:
+  - go get -t -v ./...
+
+before_script:
+  - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
+      sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6';
+    fi
+
+script:
+  - ./.travis/tests.sh
+
+after_success:
+  - bash <(curl -s https://codecov.io/bash)
+

+ 24 - 0
.travis/tests.sh

@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+# because things are never simple.
+# See https://github.com/codecov/example-go#caveat-multiple-files
+
+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
+    # integration tests
+    go test -c -tags=integration -race -coverprofile=profile.out -covermode=atomic $d
+    testbin="./$(basename $d).test"
+    # only run it if it was built - i.e. if there are integ tests
+    test -x "${testbin}" && sudo "./${testbin}"
+    if [ -f profile.out ]; then
+        cat profile.out >> coverage.txt
+        rm profile.out
+    fi
+done

+ 2 - 5
config/config.go

@@ -99,13 +99,10 @@ func parseV6Config(v *viper.Viper) (*ServerConfig, error) {
 	if pluginList == nil {
 		return nil, ConfigErrorFromString("dhcpv6: invalid plugins section, not a list")
 	}
-	if len(pluginList) == 0 {
-		return &sc, nil
-	}
-	for name, v := range pluginList {
+	for idx, v := range pluginList {
 		conf := cast.ToStringMap(v)
 		if conf == nil {
-			return nil, ConfigErrorFromString("dhcpv6: plugin `%s` is not a string map", name)
+			return nil, ConfigErrorFromString("dhcpv6: plugin #%d is not a string map", idx)
 		}
 		// make sure that only one item is specified, since it's a
 		// map name -> args