internal/rosa/package: migrate bison
All checks were successful
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 2m48s
Test / Hakurei (push) Successful in 3m47s
Test / ShareFS (push) Successful in 3m44s
Test / Sandbox (race detector) (push) Successful in 5m27s
Test / Hakurei (race detector) (push) Successful in 6m31s
Test / Flake checks (push) Successful in 1m21s

This is the final remaining trivial legacy artifact.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-21 23:06:34 +09:00
parent 5647321622
commit 68a91523b9
5 changed files with 86 additions and 97 deletions

View File

@@ -1,76 +0,0 @@
package rosa
import (
"slices"
"strconv"
"strings"
"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
if tests[0] != 1 {
buf.WriteString("1-")
}
for i, n := range tests {
if n != 1 && (i == 0 || tests[i-1] != n-1) {
buf.WriteString(strconv.Itoa(n - 1))
buf.WriteString(" ")
}
if i == len(tests)-1 || tests[i+1] != n+1 {
buf.WriteString(strconv.Itoa(n + 1))
buf.WriteString("-")
}
}
return buf.String()
}
func (t Toolchain) newBison() (pkg.Artifact, string) {
const (
version = "3.8.2"
checksum = "BhRM6K7URj1LNOkIDCFDctSErLS-Xo5d9ba9seg10o6ACrgC1uNhED7CQPgIY29Y"
)
return t.NewPackage("bison", version, newTar(
"https://ftpmirror.gnu.org/gnu/bison/bison-"+version+".tar.gz",
checksum,
pkg.TarGzip,
), nil, &MakeHelper{
Check: []string{
"TESTSUITEFLAGS=" + jobsFlagE + "' " + skipGNUTests(
// clang miscompiles (SIGILL)
764,
) + "'",
"check",
},
},
H("m4"),
_diffutils,
H("sed"),
), version
}
func init() {
native.mustRegister(Toolchain.newBison, &Metadata{
Name: "bison",
Description: "a general-purpose parser generator",
Website: "https://www.gnu.org/software/bison/",
ID: 193,
})
}

View File

@@ -2,6 +2,8 @@ package rosa
import (
"path"
"slices"
"strconv"
"strings"
"hakurei.app/internal/pkg"
@@ -68,3 +70,37 @@ func newFromGitHubRelease(
compression,
)
}
// 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 ...int64) string {
tests = slices.Clone(tests)
slices.Sort(tests)
var buf strings.Builder
if tests[0] != 1 {
buf.WriteString("1-")
}
for i, n := range tests {
if n != 1 && (i == 0 || tests[i-1] != n-1) {
buf.WriteString(strconv.Itoa(int(n - 1)))
buf.WriteString(" ")
}
if i == len(tests)-1 || tests[i+1] != n+1 {
buf.WriteString(strconv.Itoa(int(n + 1)))
buf.WriteString("-")
}
}
return buf.String()
}

View File

@@ -11,18 +11,18 @@ func TestSkipGNUTests(t *testing.T) {
t.Parallel()
testCases := []struct {
tests []int
tests []int64
want string
}{
{[]int{764}, "1-763 765-"},
{[]int{764, 0xcafe, 37, 9}, "1-8 10-36 38-763 765-51965 51967-"},
{[]int{1, 2, 0xbed}, "3-3052 3054-"},
{[]int{3, 4}, "1-2 5-"},
{[]int64{764}, "1-763 765-"},
{[]int64{764, 0xcafe, 37, 9}, "1-8 10-36 38-763 765-51965 51967-"},
{[]int64{1, 2, 0xbed}, "3-3052 3054-"},
{[]int64{3, 4}, "1-2 5-"},
}
for _, tc := range testCases {
t.Run(strings.Join(slices.Collect(func(yield func(string) bool) {
for _, n := range tc.tests {
yield(strconv.Itoa(n))
yield(strconv.Itoa(int(n)))
}
}), ","), func(t *testing.T) {
t.Parallel()

View File

@@ -0,0 +1,30 @@
package bison {
description = "a general-purpose parser generator";
website = "https://www.gnu.org/software/bison";
anitya = 193;
version* = "3.8.2";
source = remoteTar {
url = "https://ftpmirror.gnu.org/gnu/bison/bison-"+version+".tar.gz";
checksum = "BhRM6K7URj1LNOkIDCFDctSErLS-Xo5d9ba9seg10o6ACrgC1uNhED7CQPgIY29Y";
compress = gzip;
};
exec = make {
check = [
"TESTSUITEFLAGS=" + jobsFlagE + "' " + skipGNUTests {
tests = [
// clang miscompiles (SIGILL)
764,
];
} + "'",
"check",
];
};
inputs = [
m4,
diffutils,
sed,
];
}

View File

@@ -369,21 +369,6 @@ func (s *S) MustRegister(name string, f Artifact) {
}
}
// mustRegister registers an [Artifact] with the old function signature.
//
// Deprecated: Artifacts should be migrated to Register.
func (s *S) mustRegister(
f func(t Toolchain) (pkg.Artifact, string),
meta *Metadata,
) {
s.MustRegister(meta.Name, func(t Toolchain) (*Metadata, pkg.Artifact) {
v := *meta
a, version := f(t)
v.Version = version
return &v, a
})
}
// count returns the number of [Artifact] registered to s.
func (s *S) count() int {
return int(s.artifactCount.Load())
@@ -599,6 +584,20 @@ func (s *S) getFrame() azalea.Frame {
return
}},
k("skipGNUTests"): {F: func(
args azalea.FArgs,
) (v any, set bool, err error) {
var tests []int64
if err = args.Apply(map[unique.Handle[azalea.Ident]]any{
k("tests"): &tests,
}); err != nil {
return
}
v = skipGNUTests(tests...)
set = true
return
}},
// intenral/pkg built-ins
k("remoteTar"): {F: func(