Commit 78887b76 authored by Kirill Smelkov's avatar Kirill Smelkov

Adjust to recent go123 myname & xruntime changes:

- myname moved -> my
  go123@98249b24

- Traceback now returns []runtime.Frame
  go123@7deb28a5
parent b4dd16c6
...@@ -77,7 +77,7 @@ import ( ...@@ -77,7 +77,7 @@ import (
"lab.nexedi.com/kirr/go123/exc" "lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/mem" "lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/myname" "lab.nexedi.com/kirr/go123/my"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xflag" "lab.nexedi.com/kirr/go123/xflag"
"lab.nexedi.com/kirr/go123/xstrings" "lab.nexedi.com/kirr/go123/xstrings"
...@@ -383,7 +383,7 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) { ...@@ -383,7 +383,7 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) {
// prefix namespace and this way won't leave stale removed things) // prefix namespace and this way won't leave stale removed things)
xgit("rm", "--cached", "-r", "--ignore-unmatch", "--", prefix) xgit("rm", "--cached", "-r", "--ignore-unmatch", "--", prefix)
here := myname.Func() here := my.FuncName()
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) (errout error) { err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) (errout error) {
// any error -> stop // any error -> stop
if err != nil { if err != nil {
...@@ -765,7 +765,7 @@ func cmd_restore_(gb *git.Repository, HEAD_ string, restorespecv []RestoreSpec) ...@@ -765,7 +765,7 @@ func cmd_restore_(gb *git.Repository, HEAD_ string, restorespecv []RestoreSpec)
defer wg.Done() defer wg.Done()
defer close(packxq) defer close(packxq)
// raised err -> errch // raised err -> errch
here := myname.Func() here := my.FuncName()
defer exc.Catch(func(e *exc.Error) { defer exc.Catch(func(e *exc.Error) {
errch <- exc.Addcallingcontext(here, e) errch <- exc.Addcallingcontext(here, e)
}) })
...@@ -847,7 +847,7 @@ func cmd_restore_(gb *git.Repository, HEAD_ string, restorespecv []RestoreSpec) ...@@ -847,7 +847,7 @@ func cmd_restore_(gb *git.Repository, HEAD_ string, restorespecv []RestoreSpec)
go func() { go func() {
defer wg.Done() defer wg.Done()
// raised err -> errch // raised err -> errch
here := myname.Func() here := my.FuncName()
defer exc.Catch(func(e *exc.Error) { defer exc.Catch(func(e *exc.Error) {
errch <- exc.Addcallingcontext(here, e) errch <- exc.Addcallingcontext(here, e)
}) })
...@@ -981,7 +981,7 @@ func main() { ...@@ -981,7 +981,7 @@ func main() {
} }
// catch Error and report info from it // catch Error and report info from it
here := myname.Func() here := my.FuncName()
defer exc.Catch(func(e *exc.Error) { defer exc.Catch(func(e *exc.Error) {
e = exc.Addcallingcontext(here, e) e = exc.Addcallingcontext(here, e)
fmt.Fprintln(os.Stderr, e) fmt.Fprintln(os.Stderr, e)
......
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
"testing" "testing"
"lab.nexedi.com/kirr/go123/exc" "lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/myname" "lab.nexedi.com/kirr/go123/my"
"lab.nexedi.com/kirr/go123/xruntime" "lab.nexedi.com/kirr/go123/xruntime"
"lab.nexedi.com/kirr/go123/xstrings" "lab.nexedi.com/kirr/go123/xstrings"
...@@ -56,17 +56,15 @@ func XSha1(s string) Sha1 { ...@@ -56,17 +56,15 @@ func XSha1(s string) Sha1 {
// verify end-to-end pull-restore // verify end-to-end pull-restore
func TestPullRestore(t *testing.T) { func TestPullRestore(t *testing.T) {
// if something raises -> don't let testing panic - report it as proper error with context. // if something raises -> don't let testing panic - report it as proper error with context.
here := myname.Func() here := my.FuncName()
defer exc.Catch(func(e *exc.Error) { defer exc.Catch(func(e *exc.Error) {
e = exc.Addcallingcontext(here, e) e = exc.Addcallingcontext(here, e)
// add file:line for failing code inside testing function - so we have exact context to debug // add file:line for failing code inside testing function - so we have exact context to debug
failedat := "" failedat := ""
for _, f := range xruntime.Traceback(1) { for _, f := range xruntime.Traceback(1) {
if f.Name() == here { if f.Function == here {
// TODO(go1.7) -> f.File, f.Line (f becomes runtime.Frame) failedat = fmt.Sprintf("%s:%d", filepath.Base(f.File), f.Line)
file, line := f.FileLine(f.Pc - 1)
failedat = fmt.Sprintf("%s:%d", filepath.Base(file), line)
break break
} }
} }
......
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