aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-03-05 16:34:25 +0900
committerOphestra <cat@gensokyo.uk>2026-03-05 16:34:25 +0900
commit159a45c027094d4c92bc89fda99703bccaca57c2 (patch)
treeece79622f5dfd4ca75bb91ef1b5170be85f8df6b /internal
parent0eb2bfa12e3481f2c87b2df3f8ac9d38790299a8 (diff)
internal/rosa: export preset bounds
These are useful for external tooling. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/rosa/all.go12
-rw-r--r--internal/rosa/all_test.go29
2 files changed, 21 insertions, 20 deletions
diff --git a/internal/rosa/all.go b/internal/rosa/all.go
index 28a0ac96..8b2aec14 100644
--- a/internal/rosa/all.go
+++ b/internal/rosa/all.go
@@ -120,8 +120,8 @@ const (
Zlib
Zstd
- // _presetUnexportedStart is the first unexported preset.
- _presetUnexportedStart
+ // PresetUnexportedStart is the first unexported preset.
+ PresetUnexportedStart
buildcatrust = iota - 1
utilMacros
@@ -137,8 +137,8 @@ const (
// part of the [Std] toolchain.
Stage0
- // _presetEnd is the total number of presets and does not denote a preset.
- _presetEnd
+ // PresetEnd is the total number of presets and does not denote a preset.
+ PresetEnd
)
// Metadata is stage-agnostic information of a [PArtifact] not directly
@@ -159,7 +159,7 @@ const Unversioned = "\x00"
var (
// artifactsM is an array of [PArtifact] metadata.
- artifactsM [_presetEnd]Metadata
+ artifactsM [PresetEnd]Metadata
// artifacts stores the result of Metadata.f.
artifacts [_toolchainEnd][len(artifactsM)]pkg.Artifact
@@ -190,7 +190,7 @@ func (t Toolchain) Version(p PArtifact) string {
// ResolveName returns a [PArtifact] by name.
func ResolveName(name string) (p PArtifact, ok bool) {
- for i := range _presetUnexportedStart {
+ for i := range PresetUnexportedStart {
if name == artifactsM[i].Name {
return i, true
}
diff --git a/internal/rosa/all_test.go b/internal/rosa/all_test.go
index 2791402b..08d2d2cb 100644
--- a/internal/rosa/all_test.go
+++ b/internal/rosa/all_test.go
@@ -1,19 +1,20 @@
-package rosa
+package rosa_test
-import "testing"
+import (
+ "testing"
-// PresetEnd is the total PArtifact count exported for testing.
-const PresetEnd = _presetEnd
+ "hakurei.app/internal/rosa"
+)
func TestLoad(t *testing.T) {
t.Parallel()
- for i := range _presetEnd {
- p := PArtifact(i)
- t.Run(GetMetadata(p).Name, func(t *testing.T) {
+ for i := range rosa.PresetEnd {
+ p := rosa.PArtifact(i)
+ t.Run(rosa.GetMetadata(p).Name, func(t *testing.T) {
t.Parallel()
- Std.Load(p)
+ rosa.Std.Load(p)
})
}
}
@@ -21,13 +22,13 @@ func TestLoad(t *testing.T) {
func TestResolveName(t *testing.T) {
t.Parallel()
- for i := range _presetUnexportedStart {
+ for i := range rosa.PresetUnexportedStart {
p := i
- name := GetMetadata(p).Name
+ name := rosa.GetMetadata(p).Name
t.Run(name, func(t *testing.T) {
t.Parallel()
- if got, ok := ResolveName(name); !ok {
+ if got, ok := rosa.ResolveName(name); !ok {
t.Fatal("ResolveName: ok = false")
} else if got != p {
t.Fatalf("ResolveName: %d, want %d", got, p)
@@ -38,13 +39,13 @@ func TestResolveName(t *testing.T) {
func TestResolveNameUnexported(t *testing.T) {
t.Parallel()
- for i := _presetUnexportedStart; i < _presetEnd; i++ {
+ for i := rosa.PresetUnexportedStart; i < rosa.PresetEnd; i++ {
p := i
- name := GetMetadata(p).Name
+ name := rosa.GetMetadata(p).Name
t.Run(name, func(t *testing.T) {
t.Parallel()
- if got, ok := ResolveName(name); ok {
+ if got, ok := rosa.ResolveName(name); ok {
t.Fatalf("ResolveName: resolved unexported preset %d", got)
}
})