<div dir="ltr">I'd like gccgo to pass reliably, but I think it falls under a CI test rather than a pre-commit test. (Because otherwise it roughly doubles the time it takes to know whether your patch will land.)<div><br>
</div><div>I don't have specific feedback on the behavior differences, but the changes seem sane to me. An errors library is certainly something that I'd like to see shared between code bases.</div><div><br>John</div>
<div>=:-></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 14, 2014 at 1:24 PM, Tim Penhey <span dir="ltr"><<a href="mailto:tim.penhey@canonical.com" target="_blank">tim.penhey@canonical.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I took it upon myself to get Rog's errgo library used inside juju-core.<br>
<br>
Dimiter recently did a hunk of work in the juju-core/errors package to<br>
have functions to add context to some core error types while keeping<br>
their type.<br>
<br>
What I did was to move this errors package out of juju-core and into its<br>
own package, and update it to use the errgo as a base. For those that<br>
are interested the diff for the errors_test (to show that everything<br>
works as before) is as shown at the bottom of this email.<br>
<br>
I also added in simple methods based on my earlier error handling<br>
package, but changed them to be based on errgo. This adds in the<br>
functions: New, Errorf, Check, Trace, Annotate, Annotatef, Wrap, ErrorStack.<br>
<br>
One key difference in behaviour between these methods and the base errgo<br>
ones is that the cause is always passed through. Unless you call Wrap,<br>
in which case the cause changes, but that is the purpose of the call.<br>
<br>
I have a branch of juju-core up as work in progress that does the following:<br>
* removes the dependency on <a href="http://github.com/errgo/errgo" target="_blank">github.com/errgo/errgo</a><br>
* changes uses of errgo/errgo to juju/errors<br>
* adds both juju/errgo and juju/errors to the dependency file<br>
* removes the juju-core/errors package<br>
* changes all the juju-core/errors import statement to use<br>
<a href="http://github.com/juju/errors" target="_blank">github.com/juju/errors</a> (and puts the import statement in the<br>
right block)<br>
<a href="https://code.launchpad.net/~thumper/juju-core/juju-errors/+merge/219311" target="_blank">https://code.launchpad.net/~thumper/juju-core/juju-errors/+merge/219311</a><br>
3602 lines (+252/-658) 156 files modified<br>
<br>
I have tested juju/errors with both gc and gccgo and the tests pass with<br>
both. Interestingly juju/errgo has a few test failures with gccgo, but<br>
Dave is looking at them and assures me they are simple fixes.<br>
As an aside, I do think that any new dependencies we add should pass all<br>
tests with both gc and gccgo.<br>
<br>
Cheers,<br>
<br>
Tim<br>
<br>
$ diff -u ~/src/juju-core/trunk/errors/errors_test.go errors_test.go<br>
--- /home/tim/src/juju-core/trunk/errors/errors_test.go 2014-05-14<br>
19:18:53.376121000 +1200<br>
+++ errors_test.go 2014-05-13 17:14:50.329051637 +1200<br>
@@ -1,5 +1,5 @@<br>
-// Copyright 2013 Canonical Ltd.<br>
-// Licensed under the AGPLv3, see LICENCE file for details.<br>
+// Copyright 2013, 2014 Canonical Ltd.<br>
+// Licensed under the GPLv3, see LICENCE file for details.<br>
<br>
package errors_test<br>
<br>
@@ -8,12 +8,10 @@<br>
"fmt"<br>
"reflect"<br>
"runtime"<br>
- "testing"<br>
<br>
+ "<a href="http://github.com/juju/errors" target="_blank">github.com/juju/errors</a>"<br>
jc "<a href="http://github.com/juju/testing/checkers" target="_blank">github.com/juju/testing/checkers</a>"<br>
gc "<a href="http://launchpad.net/gocheck" target="_blank">launchpad.net/gocheck</a>"<br>
-<br>
- "<a href="http://launchpad.net/juju-core/errors" target="_blank">launchpad.net/juju-core/errors</a>"<br>
)<br>
<br>
// errorInfo holds information about a single error type: a satisfier<br>
@@ -40,10 +38,6 @@<br>
<br>
var _ = gc.Suite(&errorsSuite{})<br>
<br>
-func Test(t *testing.T) {<br>
- gc.TestingT(t)<br>
-}<br>
-<br>
func (t *errorInfo) satisfierName() string {<br>
value := reflect.ValueOf(t.satisfier)<br>
f := runtime.FuncForPC(value.Pointer())<br>
@@ -175,6 +169,12 @@<br>
runErrorTests(c, errorTests, true)<br>
}<br>
<br>
+func (*errorsSuite) TestContextfNotNewer(c *gc.C) {<br>
+ err := fmt.Errorf("simple error")<br>
+ errors.Contextf(&err, "annotate")<br>
+ c.Assert(err, gc.ErrorMatches, "annotate: simple error")<br>
+}<br>
+<br>
func (*errorsSuite) TestAllErrors(c *gc.C) {<br>
errorTests := []errorTest{}<br>
for _, errInfo := range allErrors {<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Juju-dev mailing list<br>
<a href="mailto:Juju-dev@lists.ubuntu.com">Juju-dev@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/juju-dev" target="_blank">https://lists.ubuntu.com/mailman/listinfo/juju-dev</a><br>
</font></span></blockquote></div><br></div>