Explorar el Código

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

R=golang-dev, dsymonds
CC=golang-dev
http://codereview.appspot.com/5645094
Rob Pike hace 14 años
padre
commit
990ea20d59
Se han modificado 1 ficheros con 5 adiciones y 2 borrados
  1. 5 2
      proto/testdata/golden_test.go

+ 5 - 2
proto/testdata/golden_test.go

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