Pipeline Planning

This commit is contained in:
2026-04-14 01:08:38 +02:00
parent 5bd4a58bff
commit b766ff1348
3 changed files with 161 additions and 29 deletions
+69
View File
@@ -1160,6 +1160,75 @@ func TestBuildExcludesOptionalHAKsFromModuleOrder(t *testing.T) {
}
}
func TestPlanHAKsWritesManifestWithoutArchives(t *testing.T) {
root := t.TempDir()
mustMkdir(t, filepath.Join(root, "src"))
mustMkdir(t, filepath.Join(root, "assets", "core"))
mustMkdir(t, filepath.Join(root, "build"))
mustWriteFile(t, filepath.Join(root, "nwn-tool.json"), `{
"module": {
"name": "Test Module",
"resref": "testmod",
"hak_order": ["group:core"]
},
"paths": {
"source": "src",
"assets": "assets",
"build": "build"
},
"haks": [
{
"name": "core",
"priority": 1,
"max_bytes": 0,
"split": false,
"include": ["core/**"]
}
]
}
`)
mustWriteFile(t, filepath.Join(root, "assets", "core", "a.tga"), "core-data")
p, err := project.Load(root)
if err != nil {
t.Fatalf("load project: %v", err)
}
if err := p.ValidateLayout(); err != nil {
t.Fatalf("validate layout: %v", err)
}
if err := p.Scan(); err != nil {
t.Fatalf("scan: %v", err)
}
result, err := PlanHAKs(p)
if err != nil {
t.Fatalf("plan haks: %v", err)
}
if len(result.HAKPaths) != 0 {
t.Fatalf("expected no hak outputs for plan-only, got %d", len(result.HAKPaths))
}
manifestPath := filepath.Join(root, "build", "haks.json")
rawManifest, err := os.ReadFile(manifestPath)
if err != nil {
t.Fatalf("read manifest: %v", err)
}
var manifest BuildManifest
if err := json.Unmarshal(rawManifest, &manifest); err != nil {
t.Fatalf("parse manifest: %v", err)
}
if len(manifest.HAKs) != 1 {
t.Fatalf("expected 1 manifest hak entry, got %d", len(manifest.HAKs))
}
if manifest.HAKs[0].ContentHash == "" {
t.Fatal("expected plan-only manifest to include content hash")
}
if _, err := os.Stat(filepath.Join(root, "build", "core.hak")); !os.IsNotExist(err) {
t.Fatalf("expected no built hak archive, got err=%v", err)
}
}
func TestBuildSkipsEmptyHAKGroupsInModuleOrder(t *testing.T) {
root := t.TempDir()
mustMkdir(t, filepath.Join(root, "src"))