spec: fix %check on ELN

%gotest ./... was failing on ELN because it couldn't find the vendored
dependencies.

Let me explain why this worked before:
In Fedora, we don't use vendored deps, therefore we had no issue.

In RHEL8, we use vendored deps and -mod=vendor with GO111MODULE unset.
In this case, vendored deps were indeed used.

However, ELN added GO111MODULE=off. When modules are disabled, -mod=vendor
is ignored[1]. It turns out that go with disabled modules uses vendor directory
only in case when $(pwd) is inside GOPATH. Don't ask me why.

Therefore, this fix uses cd to ensure that pwd inside GOPATH (even though
technically we're still in the same directory).

Note that in %build we already had this magic cd command, therefore it wasn't
an issue there.

[1]: Actually `GO111MODULE=off go build -mod=vendor` returns an error. However,
`GO111MODULE=off GOFLAGS=-mod=vendor go build` just ignores the go flag from
env.

Fixes #rhbz1884383
This commit is contained in:
Ondřej Budai 2020-10-13 12:57:28 +02:00
parent 84711d518e
commit f52ff68798

View file

@ -209,6 +209,8 @@ install -m 0755 -vp test/data/vendor/dnsname %{buildroot}%{_d
%if 0%{?rhel}
export GOFLAGS=-mod=vendor
export GOPATH=$PWD/_build:%{gopath}
# cd inside GOPATH, otherwise go with GO111MODULE=off ignores vendor directory
cd $PWD/_build/src/%{goipath}
%gotest ./...
%else
%gocheck