From 68a91523b9e58ee8a9f86723d616e82c0645b64a Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 21 May 2026 23:06:34 +0900 Subject: [PATCH] internal/rosa/package: migrate bison This is the final remaining trivial legacy artifact. Signed-off-by: Ophestra --- internal/rosa/bison.go | 76 ------------------- internal/rosa/builtins.go | 36 +++++++++ .../rosa/{bison_test.go => builtins_test.go} | 12 +-- internal/rosa/package/bison.az | 30 ++++++++ internal/rosa/state.go | 29 ++++--- 5 files changed, 86 insertions(+), 97 deletions(-) delete mode 100644 internal/rosa/bison.go rename internal/rosa/{bison_test.go => builtins_test.go} (68%) create mode 100644 internal/rosa/package/bison.az diff --git a/internal/rosa/bison.go b/internal/rosa/bison.go deleted file mode 100644 index 68f97a68..00000000 --- a/internal/rosa/bison.go +++ /dev/null @@ -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, - }) -} diff --git a/internal/rosa/builtins.go b/internal/rosa/builtins.go index 78123921..b0ec65b1 100644 --- a/internal/rosa/builtins.go +++ b/internal/rosa/builtins.go @@ -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() +} diff --git a/internal/rosa/bison_test.go b/internal/rosa/builtins_test.go similarity index 68% rename from internal/rosa/bison_test.go rename to internal/rosa/builtins_test.go index 94d82618..e18ba461 100644 --- a/internal/rosa/bison_test.go +++ b/internal/rosa/builtins_test.go @@ -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() diff --git a/internal/rosa/package/bison.az b/internal/rosa/package/bison.az new file mode 100644 index 00000000..39a0eb3d --- /dev/null +++ b/internal/rosa/package/bison.az @@ -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, + ]; +} diff --git a/internal/rosa/state.go b/internal/rosa/state.go index 3fae800c..4a324094 100644 --- a/internal/rosa/state.go +++ b/internal/rosa/state.go @@ -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(