Hello all,
I'm still fairly new to packaging and I was packaging a golang library when one of it's tests relies on networking so I'd like to skip it. The Fedora packaging guidelines https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang/#_running_t... suggests the `-r <regexp>` flag would help me do this, however I've not been able to get it to work.
I've tried `%gocheck -r get_gcs_test.go`, `%gocheck -r get_gcs_test.*`, `%gocheck -r ./get_gcs_test.go`, as well as adding double quotes around the filename, but none of these seem to have any effect on excluding the test. Am I using this flag incorrectly or is there a bug with this flag?
I looked at a number of other golang packages and I wasn't able to find any other uses of the `-r` flag. Only noting uses of the `-d <directory>` flag, which does seem to work in my case but excludes other tests which I do not want to exclude.
-- Bryce Torcello https://procupti.me
If you are looking for inspiration, then this [1] archive contains all Fedora .spec files. Grepping for `%gocheck`, it seems that golang-github-gogo-protobuf.spec is using the `-r` option this way:
~~~
%gocheck -t protoc-gen-gogo -d test/moredefaults -d test/dashfilename -d test/embedconflict -d test/issue270 -r .*/unsafeunmarshaler -r .*/unsafeboth -r .*/unsafemarshaler -d test/packed
~~~
Not sure if that helps.
Vít
[1] https://pkgs.fedoraproject.org/repo/rpm-specs-latest.tar.xz
Dne 17. 03. 21 v 10:12 Bryce Torcello napsal(a):
Hello all,
I'm still fairly new to packaging and I was packaging a golang library when one of it's tests relies on networking so I'd like to skip it. The Fedora packaging guidelines https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang/#_running_t... suggests the `-r <regexp>` flag would help me do this, however I've not been able to get it to work.
I've tried `%gocheck -r get_gcs_test.go`, `%gocheck -r get_gcs_test.*`, `%gocheck -r ./get_gcs_test.go`, as well as adding double quotes around the filename, but none of these seem to have any effect on excluding the test. Am I using this flag incorrectly or is there a bug with this flag?
I looked at a number of other golang packages and I wasn't able to find any other uses of the `-r` flag. Only noting uses of the `-d <directory>` flag, which does seem to work in my case but excludes other tests which I do not want to exclude.
-- Bryce Torcello https://procupti.me _______________________________________________ packaging mailing list -- packaging@lists.fedoraproject.org To unsubscribe send an email to packaging-leave@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/packaging@lists.fedoraproject.... Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
Le mercredi 17 mars 2021 à 09:12 +0000, Bryce Torcello a écrit : Hi,
I'm still fairly new to packaging and I was packaging a golang library when one of it's tests relies on networking so I'd like to skip it. The Fedora packaging guidelines https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang/#_running_t... suggests the `-r <regexp>` flag would help me do this, however I've not been able to get it to work.
I've tried `%gocheck -r get_gcs_test.go`, `%gocheck -r get_gcs_test.*`, `%gocheck -r ./get_gcs_test.go`, as well as adding double quotes around the filename, but none of these seem to have any effect on excluding the test. Am I using this flag incorrectly or is there a bug with this flag?
The regexp flag is advanced use and quite quirky to use. First, regexp means regexp as implemented by Golang (ie, not exactly usual shell regexp syntax). And second, the other simplified flags hide quite a lot of internal Golang complexity, from memory and without testing I’m almost certain that what you think of “./” does not exist for Golang, you need to qualify the path with the Go package name at least.
Obviously, exposing raw Golang regexp syntax means the macros can not fool with the Golang view of things, things like ^ would defeat attempts to inject a path prefix in the expression supplied by the packager.
Regards,
If you are looking for inspiration, then this [1] archive contains all Fedora .spec files. Grepping for `%gocheck`, it seems that golang-github-gogo-protobuf.spec is using the `-r` option this way:
%gocheck -t protoc-gen-gogo -d test/moredefaults -d test/dashfilename -d test/embedconflict -d test/issue270 -r .*/unsafeunmarshaler -r .*/unsafeboth -r .*/unsafemarshaler -d test/packedNot sure if that helps.
Vít
[1] https://pkgs.fedoraproject.org/repo/rpm-specs-latest.tar.xz
Thanks for mentioning this Vít, I hadn't realised this existed. Will definitely make it much easier to learn from other packagers by grepping through all the spec files in the future.
The regexp flag is advanced use and quite quirky to use. First, regexp means regexp as implemented by Golang (ie, not exactly usual shell regexp syntax). And second, the other simplified flags hide quite a lot of internal Golang complexity, from memory and without testing I’m almost certain that what you think of “./” does not exist for Golang, you need to qualify the path with the Go package name at least.
I think I'm realising that what the `-r` flag is referring to is regex of the path with the package name and not the filename of a test file itself, which is how I was trying to use it.
This is seemingly how it is being used in the case of golang-github-gogo-protobuf.spec at least (seemingly the only spec file existing that is using the `-r` flag). Where `-r .*/unsafeboth` would match "github.com/gogo/protobuf/test/casttype/combos/unsafeboth", "github.com/gogo/protobuf/test/castvalue/combos/unsafeboth", etc.
However it's my understanding that this would match all "*_test.go" files in these matching paths. Whereas I was hoping to exclude a single "*_test.go" at a specific path since I don't want to disable all the other tests.
Unless there is another way, I think that the only way to do what I desire is to include a patch for the deletion of the "_test.go" files I require. At least until something like https://github.com/golang/go/issues/41583 is implemented (and I assume `%gocheck` could make use of).
Le mercredi 17 mars 2021 à 13:49 +0000, Bryce Torcello a écrit :
Unless there is another way, I think that the only way to do what I desire is to include a patch for the deletion of the "_test.go" files I require. At least until something like https://github.com/golang/go/issues/41583%C2%A0is implemented (and I assume `%gocheck` could make use of)
Sure, deleting is the quick and safe way. Flags are more useful when you’re iterating on lots of build and are trying to find a balance without bulk droping all unit tests (which everyone involved in Go packaging has done at one time given how brittle those are)
On 3/17/21 2:49 PM, Bryce Torcello wrote:
However it's my understanding that this would match all "*_test.go" files in these matching paths. Whereas I was hoping to exclude a single "*_test.go" at a specific path since I don't want to disable all the other tests.
Unless there is another way, I think that the only way to do what I desire is to include a patch for the deletion of the "_test.go" files I require. At least until something like https://github.com/golang/go/issues/41583 is implemented (and I assume `%gocheck` could make use of).
I use one of the following to disable one specific test (not the file, just specific tests).
If tests use standard "testing" module: ``` for test in "TestRestart" \ "TestStop" \ "TestActive" \ ; do awk -i inplace '/^func.*'"$test"'(/ { print; print "\tt.Skip("disabled failing test")"; next}1' $(grep -rl $test) done ```
If not: ``` for test in "TestRestart" \ "TestStop" \ "TestActive" \ ; do awk -i inplace '/^func.*'"$test"'/ { print; print "\treturn"; next}1' $(grep -rl $test) done ```
packaging@lists.fedoraproject.org