[pkg-go] Circular dependency in a test file

Michael Stapelberg stapelberg at debian.org
Tue Feb 13 12:12:05 UTC 2018


On Tue, Feb 13, 2018 at 12:37 PM, Arnaud <arnaud.rebillout at collabora.com>
wrote:

> Dear pkg-go maintainers,
>
> I bumped into a trouble while packaging <https://github.com/
> containerd/typeurl> <https://github.com/containerd/typeurl>.
>
> The library is fairly simple, however the file marshal_test.go [1]
> contains this line:
>
>   eventsapi "github.com/containerd/containerd/api/services/events/v1"
>
> This is a circulare dependency, since containerd/typeurl is a depency of
> of containerd/containerd, but requires containerd/containerd for this test.
>
> This breaks dh-make-golang with this error:
>
> 2018/02/13 18:29:20 Downloading "github.com/containerd/typeurl/..."
> go get: 82.03 MiBpackage github.com/containerd/typeurl
>     imports github.com/containerd/containerd/typeurl: cannot find package
> "github.com/containerd/containerd/typeurl" in any of:
>     /usr/lib/go-1.7/src/github.com/containerd/containerd/typeurl (from
> $GOROOT)
>     /tmp/dh-make-golang738896973/src/github.com/containerd/
> containerd/typeurl (from $GOPATH)
> 2018/02/13 18:29:44 Could not create a tarball of the upstream source:
> exit status 1
>

This error is actually not because of a circular dependency, but rather
because the import path specified in marshal_test.go is incorrect: it reads
github.com/containerd/containerd/typeurl, but should read
github.com/containerd/typeurl.

You can reproduce this issue outside of our packaging infrastructure by
running go get -t -u github.com/containerd/typeurl

Please file an upstream issue about this.


>
> The fact that it breaks dh-make-dolang is not the blocker here, as I can
> workaround and create the packaging files manually. However, what should I
> do with this `marshal_test.go` file ? Should I exclude it from the package
> ? Or should I patch it ?
>

I agree with tincho’s reply.


>
> And more generally: I've noticed that a lot of go packages have test files
> named `*_test.go` Is it good policy to remove them from the package when
> they get in the way like this ? Or are they needed in some way that I don't
> expect ?
>
> Thanks,
>
>   Arnaud
>
> [1]: https://github.com/containerd/typeurl/blob/master/marshal_test.go
>
>
> _______________________________________________
> Pkg-go-maintainers mailing list
> Pkg-go-maintainers at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-go-maintainers
>



-- 
Best regards,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-go-maintainers/attachments/20180213/bab01da7/attachment.html>


More information about the Pkg-go-maintainers mailing list