.travis.yml: fix travis CI
Changes made:
* Call autogen.sh before building protobuf.
It's unclear how this worked before, but the README instructions for
protobuf does state to run autogen.sh prior to building and installing.
* Fix downloadArchive to take in a prefix path rather than the number of
prefix directories to skip. The reason for this change is due to a bug
in the Go build system where unexpected directories were being packed.
See https://golang.org/issue/29906
* Explicitly set Travis dist to be "xenial", which comes with Go1.11.
We require Go1.11 for two reasons:
* The use of t.Helper in integration_test.go
* Proper understanding of the -mod=vendor flag
(even if all that flag does is disable modules).
* Add a hack to integration_test.go to periodically output the timestamp
to work around a restriction in Travis where it auto-kills the test
after 10 minutes of no stdout activity.
Change-Id: I114fe2855faeed091c34d79df3d97068be7eccd8
Reviewed-on: https://go-review.googlesource.com/c/164919
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/integration_test.go b/integration_test.go
index 2115ff1..eb1b7a4 100644
--- a/integration_test.go
+++ b/integration_test.go
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build integration
+// +build ignore
-package protobuf
+package main
import (
"archive/tar"
@@ -22,6 +22,7 @@
"runtime"
"strings"
"testing"
+ "time"
)
var (
@@ -119,6 +120,25 @@
testDir := filepath.Join(repoRoot, ".cache")
check(os.MkdirAll(testDir, 0775))
+ // Travis-CI has a hard-coded timeout where it kills the test after
+ // 10 minutes of a lack of activity on stdout.
+ // We work around this restriction by periodically printing the timestamp.
+ ticker := time.NewTicker(5 * time.Minute)
+ done := make(chan struct{})
+ go func() {
+ now := time.Now()
+ for {
+ select {
+ case t := <-ticker.C:
+ fmt.Printf("\tt=%0.fmin\n", t.Sub(now).Minutes())
+ case <-done:
+ return
+ }
+ }
+ }()
+ defer close(done)
+ defer ticker.Stop()
+
// Delete the current directory if non-empty,
// which only occurs if a dependency failed to initialize properly.
var workingDir string
@@ -165,9 +185,10 @@
if _, err := os.Stat(workingDir); err != nil {
fmt.Printf("download %v\n", filepath.Base(workingDir))
url := fmt.Sprintf("https://github.com/google/protobuf/releases/download/v%v/protobuf-all-%v.tar.gz", protobufVersion, protobufVersion)
- downloadArchive(check, workingDir, url, 1)
+ downloadArchive(check, workingDir, url, "protobuf-"+protobufVersion)
fmt.Printf("build %v\n", filepath.Base(workingDir))
+ mustRunCommand(t, workingDir, "./autogen.sh")
mustRunCommand(t, workingDir, "./configure")
mustRunCommand(t, workingDir, "make")
mustRunCommand(t, filepath.Join(workingDir, "conformance"), "make")
@@ -184,7 +205,7 @@
if _, err := os.Stat(workingDir); err != nil {
fmt.Printf("download %v\n", filepath.Base(workingDir))
url := fmt.Sprintf("https://dl.google.com/go/go%v.%v-%v.tar.gz", v, runtime.GOOS, runtime.GOARCH)
- downloadArchive(check, workingDir, url, 1)
+ downloadArchive(check, workingDir, url, "go")
}
registerBinary("go"+v, filepath.Join(workingDir, "bin", "go"))
}
@@ -210,7 +231,7 @@
check(os.Setenv("GOPATH", goPath))
}
-func downloadArchive(check func(error), dstPath, srcURL string, skipPrefixes int) {
+func downloadArchive(check func(error), dstPath, srcURL, skipPrefix string) {
check(os.RemoveAll(dstPath))
resp, err := http.Get(srcURL)
@@ -228,7 +249,17 @@
}
check(err)
- path := strings.Join(strings.Split(h.Name, "/")[skipPrefixes:], "/")
+ // Skip directories or files outside the prefix directory.
+ if len(skipPrefix) > 0 {
+ if !strings.HasPrefix(h.Name, skipPrefix) {
+ continue
+ }
+ if len(h.Name) > len(skipPrefix) && h.Name[len(skipPrefix)] != '/' {
+ continue
+ }
+ }
+
+ path := strings.TrimPrefix(strings.TrimPrefix(h.Name, skipPrefix), "/")
path = filepath.Join(dstPath, filepath.FromSlash(path))
mode := os.FileMode(h.Mode & 0777)
switch h.Typeflag {