Sfoglia il codice sorgente

test.bash: use repo-local cache

Use a local ".cache" directory in the repository root for the cache
instead of a directory in /tmp. On many operating systems, files are arbitrarily
purged as part of the OS' cleanup procedures, leading to obscure failures.

Since the build cache is in the repo root, we adjust the invocation of gofmt
to only act upon the set of Go files tracked by git.

Change-Id: I10cd0ea0de3370ea25fcd3870451fb41c4204a4b
Reviewed-on: https://go-review.googlesource.com/133875
Reviewed-by: Damien Neil <dneil@google.com>
Joe Tsai 7 anni fa
parent
commit
f8505dac3f
3 ha cambiato i file con 4 aggiunte e 3 eliminazioni
  1. 1 0
      .gitignore
  2. 1 1
      .travis.yml
  3. 2 2
      test.bash

+ 1 - 0
.gitignore

@@ -1,2 +1,3 @@
+.cache
 vendor
 vendor
 cmd/protoc-gen-go/protoc-gen-go
 cmd/protoc-gen-go/protoc-gen-go

+ 1 - 1
.travis.yml

@@ -2,4 +2,4 @@ script:
   - ./test.bash
   - ./test.bash
 cache:
 cache:
   directories:
   directories:
-  - /tmp/golang-protobuf-test
+  - .cache

+ 2 - 2
test.bash

@@ -10,7 +10,7 @@ function print() { echo -e "\x1b[1m> $@\x1b[0m"; }
 # The test directory contains the Go and protobuf toolchains used for testing.
 # The test directory contains the Go and protobuf toolchains used for testing.
 # The bin directory contains symlinks to each tool by version.
 # The bin directory contains symlinks to each tool by version.
 # It is safe to delete this directory and run the test script from scratch.
 # It is safe to delete this directory and run the test script from scratch.
-TEST_DIR=/tmp/golang-protobuf-test
+TEST_DIR=$REPO_ROOT/.cache
 mkdir -p $TEST_DIR/bin
 mkdir -p $TEST_DIR/bin
 function register_binary() {
 function register_binary() {
 	rm -f $TEST_DIR/bin/$1 # best-effort delete
 	rm -f $TEST_DIR/bin/$1 # best-effort delete
@@ -110,7 +110,7 @@ function check() {
 
 
 # Check for stale or unformatted source files.
 # Check for stale or unformatted source files.
 check go run ./internal/cmd/generate-types
 check go run ./internal/cmd/generate-types
-check gofmt -d .
+check gofmt -d $(cd $REPO_ROOT && git ls-files '*.go')
 
 
 # Check for changed or untracked files.
 # Check for changed or untracked files.
 check git diff --no-prefix HEAD
 check git diff --no-prefix HEAD