internal/rosa/gnu: test skip helper
All checks were successful
Test / Create distribution (push) Successful in 1m27s
Test / Sandbox (push) Successful in 4m41s
Test / Hakurei (push) Successful in 7m51s
Test / ShareFS (push) Successful in 8m26s
Test / Sandbox (race detector) (push) Successful in 8m29s
Test / Hakurei (race detector) (push) Successful in 11m2s
Test / Flake checks (push) Successful in 1m56s
All checks were successful
Test / Create distribution (push) Successful in 1m27s
Test / Sandbox (push) Successful in 4m41s
Test / Hakurei (push) Successful in 7m51s
Test / ShareFS (push) Successful in 8m26s
Test / Sandbox (race detector) (push) Successful in 8m29s
Test / Hakurei (race detector) (push) Successful in 11m2s
Test / Flake checks (push) Successful in 1m56s
The terribleness of GNU invites interesting helpers. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -2,10 +2,39 @@ package rosa
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"slices"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"hakurei.app/internal/pkg"
|
"hakurei.app/internal/pkg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// skipGNUTests generates a string for skipping specific tests by number in a
|
||||||
|
// GNU test suite. This is nontrivial because the test suite does not support
|
||||||
|
// excluding tests in any way, so ranges for all but the skipped tests have to
|
||||||
|
// be specified instead.
|
||||||
|
//
|
||||||
|
// For example, to skip test 764, ranges around the skipped test must be
|
||||||
|
// specified:
|
||||||
|
//
|
||||||
|
// 1-763 765-
|
||||||
|
//
|
||||||
|
// Tests are numbered starting from 1. The resulting string is unquoted.
|
||||||
|
func skipGNUTests(tests ...int) string {
|
||||||
|
tests = slices.Clone(tests)
|
||||||
|
slices.Sort(tests)
|
||||||
|
|
||||||
|
var buf strings.Builder
|
||||||
|
buf.WriteString("1-")
|
||||||
|
for _, n := range tests {
|
||||||
|
buf.WriteString(strconv.Itoa(n - 1))
|
||||||
|
buf.WriteString(" ")
|
||||||
|
buf.WriteString(strconv.Itoa(n + 1))
|
||||||
|
buf.WriteString("-")
|
||||||
|
}
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
func (t Toolchain) newM4() (pkg.Artifact, string) {
|
func (t Toolchain) newM4() (pkg.Artifact, string) {
|
||||||
const (
|
const (
|
||||||
version = "1.4.21"
|
version = "1.4.21"
|
||||||
|
|||||||
33
internal/rosa/gnu_test.go
Normal file
33
internal/rosa/gnu_test.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package rosa
|
||||||
|
|
||||||
|
import (
|
||||||
|
"slices"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSkipGNUTests(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
tests []int
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{[]int{764}, "1-763 765-"},
|
||||||
|
{[]int{764, 0xcafe, 37, 9}, "1-8 10-36 38-763 765-51965 51967-"},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(strings.Join(slices.Collect(func(yield func(string) bool) {
|
||||||
|
for _, n := range tc.tests {
|
||||||
|
yield(strconv.Itoa(n))
|
||||||
|
}
|
||||||
|
}), ","), func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
if got := skipGNUTests(tc.tests...); got != tc.want {
|
||||||
|
t.Errorf("skipGNUTests: %q, want %q", got, tc.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user