Просмотр исходного кода

goprotobuf: don't overwrite test.pb.go in golden test

R=golang-dev, dsymonds
CC=golang-dev
http://codereview.appspot.com/5645094
Rob Pike 14 лет назад
Родитель
Сommit
990ea20d59
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      proto/testdata/golden_test.go

+ 5 - 2
proto/testdata/golden_test.go

@@ -39,6 +39,7 @@ import (
 	"io/ioutil"
 	"os"
 	"os/exec"
+	"path/filepath"
 	"testing"
 )
 
@@ -71,9 +72,11 @@ func TestGolden(t *testing.T) {
 	// Compute the original checksum.
 	goldenSum := sum(t, "test.pb.go")
 	// Run the proto compiler.
-	run(t, "protoc", "--go_out=.", "test.proto")
+	run(t, "protoc", "--go_out="+os.TempDir(), "test.proto")
+	newFile := filepath.Join(os.TempDir(), "test.pb.go")
+	defer os.Remove(newFile)
 	// Compute the new checksum.
-	newSum := sum(t, "test.pb.go")
+	newSum := sum(t, newFile)
 	// Verify
 	if newSum != goldenSum {
 		run(t, "hg", "diff", "test.pb.go")