On 6/14/21 7:22 PM, Link Dupont wrote:
I'm attempting to package github.com/rjeczalik/notify[1] as an RPM. This
package includes a utility function[2] that determines whether a path is a
symlink, and resolves it to an absolute path. This function clearly has merit,
as the package is an abstraction wrapper around inotify. There are tests around
this function that set up symlinks and test whether or not the function
correctly resolves the symlink redirections. These test functions fail when I
build the package[3]. It turns out the abstractions created by %goprep that set
up the _build/src directory hierarchy (including the final symlink in the tree)
are tripping up the tests that are attempting to resolve symlinks. I replaced
the symlink at _build/src/github.com/rjeczalik/notify with a properly unpacked
source directory and ran go-rpm-integration check by hand, and the tests pass.
If _build/src/github.com/rjeczalik/notify is a symlink, however, the tests are
failing.
Is there a proper way to manipulate the %goprep macro or tell it to not create
symlinks? Or, what's the appropriate Fedora RPM go macro way of handling cases
like this?
You can redefine the goprep macro in your spec by replacing the linking with
copying:
%define gomkdir(z:i:b:s:kv) %{expand:
%goenv %{-z} %{?-i} %{?-v}
%define mybuilddir %{?-b*}%{!-b:%{gobuilddir}}
%define mygoipath %{?-i*}%{!-i:%{currentgoipath}}
%define mysourcedir %{?-s*}%{!-s:%{currentgosourcedir}}
%{!?-k:rm -fr "%{mysourcedir}/vendor"}
if [[ ! -e "%{mybuilddir}/bin" ]] ; then
install -m 0755 -vd "%{mybuilddir}/bin"
export GOPATH="%{mybuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"
fi
if [[ ! -e "%{mybuilddir}/src/%{mygoipath}" ]] ; then
install -m 0755 -vd "%{mybuilddir}/src/%{mygoipath}"
find "%{mysourcedir}" -not \\( -path "%{mysourcedir}" \\) -and -not \\( -path
"%{mysourcedir}/_build" -prune \\) -exec cp -a "{}" "%{mybuilddir}/src/%{mygoipath}/" \\;
fi
cd "%{mybuilddir}/src/%{mygoipath}"
}
Add a comment explaining why you need to do that though.
You will also find that the test "TestRecreated" is flaky, it is sometimes
successful, sometimes it timeouts:
Testing in:
/builddir/build/BUILD/notify-135d4685afb9d0fb32e23a065b95cd797cb8a4ee/_build/src
PATH:
/builddir/build/BUILD/notify-135d4685afb9d0fb32e23a065b95cd797cb8a4ee/_build/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
GOPATH:
/builddir/build/BUILD/notify-135d4685afb9d0fb32e23a065b95cd797cb8a4ee/_build:/usr/share/gocode
GO111MODULE: off
command: go test -buildmode pie -compiler gc -ldflags " -X github.com/rjeczalik/notify/version.commit=135d4685afb9d0fb32e23a065b95cd797cb8a4ee -X github.com/rjeczalik/notify/version=0.9.2 -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld '"
testing: github.com/rjeczalik/notify
github.com/rjeczalik/notify
--- FAIL: TestRecreated (5.00s)
notify_test.go:192: ######## First ########
notify_test.go:179: /tmp/notify_test-447166328/folder notify.Create
notify_test.go:179: /tmp/notify_test-447166328/folder/file notify.Write
notify_test.go:179: /tmp/notify_test-447166328/folder/file notify.Create
notify_test.go:199: ######## Second ########
notify_test.go:179: /tmp/notify_test-447166328/folder/file notify.Remove
notify_test.go:179: /tmp/notify_test-447166328/folder notify.Remove
notify_test.go:179: /tmp/notify_test-447166328/folder notify.Remove
notify_test.go:179: /tmp/notify_test-447166328/folder notify.Create
notify_test.go:179: /tmp/notify_test-447166328/folder/file notify.Write
notify_test.go:179: /tmp/notify_test-447166328/folder/file notify.Create
notify_test.go:207: ######## Third ########
notify_test.go:179: /tmp/notify_test-447166328/folder notify.Create
notify_test.go:179: /tmp/notify_test-447166328/folder/file notify.Remove
notify_test.go:179: /tmp/notify_test-447166328/folder notify.Remove
notify_test.go:179: /tmp/notify_test-447166328/folder notify.Remove
notify_test.go:184: timed out before receiving event
FAIL
exit status 1
FAIL github.com/rjeczalik/notify 21.392s
Report it upstream and use this workaround in the meantime:
%if %{with check}
%check
for test in "TestRecreated" \
; do
awk -i inplace '/^func.*'"$test"'\(/ { print; print "\tt.Skip(\"disabled failing
test\")"; next}1' $(grep -rl $test)
done
%gocheck
%endif
Best regards,
Robert-André
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure