Commit e8921f0e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d617938d
......@@ -406,14 +406,18 @@ func writeFile(path string, data []byte) error {
return ioutil.WriteFile(path, data, 0666)
}
// removeFile removes file at path after checking it is safe to write to that file
// removeFile make sure there is no file at path after checking it is safe to write to that file
func removeFile(path string) error {
err := checkCanWrite(path)
if err != nil {
return err
}
return os.Remove(path)
err = os.Remove(path)
if e, ok := err.(*os.PathError); ok && os.IsNotExist(e.Err) {
err = nil
}
return err
}
type Buffer struct {
......
package main
import (
"bytes"
"fmt"
"go/build"
"io/ioutil"
"os"
......@@ -100,16 +100,17 @@ func xprepareTree(src, dst string, mode TreePrepareMode) {
// diffR compares two directories recursively
func diffR(patha, pathb string) (diff string, err error) {
out := &bytes.Buffer{}
cmd := exec.Command("diff", "-urN", patha, pathb)
cmd.Stdout = out
err = cmd.Run()
if e, ok := err.(*exec.ExitError); ok && e.Sys().(syscall.WaitStatus).ExitStatus() == 1 {
out, err := cmd.Output()
if e, ok := err.(*exec.ExitError); ok {
if e.Sys().(syscall.WaitStatus).ExitStatus() == 1 {
err = nil // diff signals with 1 just a difference - problem exit code is 2
} else {
err = fmt.Errorf("diff %s %s:\n%s", patha, pathb, e.Stderr)
}
}
return out.String(), err
return string(out), err
}
func TestGoTraceGen(t *testing.T) {
......@@ -143,7 +144,7 @@ func TestGoTraceGen(t *testing.T) {
t.Errorf("%v: %v", tpkg, err)
}
diff, err := diffR(good+"/"+tpkg, work+"/"+tpkg)
diff, err := diffR(good+"/src/"+tpkg, work+"/src/"+tpkg)
if err != nil {
t.Fatalf("%v: %v", tpkg, err)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment