Force Check Duplicates

This commit is contained in:
2026-04-04 09:34:36 +02:00
parent 38ee1e21e0
commit 9313769649
4 changed files with 52 additions and 2 deletions
+2
View File
@@ -35,6 +35,8 @@ tools/ built development binary output
- `sow-module` uses `sow-toolkit` for `build-module`, `extract`, `validate`, `compare`, and `apply-hak-manifest`
- `sow-assets` uses `sow-toolkit` for `build-haks` and validation
- validation now fails early if duplicate asset resources would collide inside the same generated HAK
- duplicate resources split across different HAK groups remain warnings because later HAK order can still override earlier content at runtime
- `sow-module` now also uses `sow-toolkit` for the early topdata bridge:
- `validate-topdata`
- `build-topdata`
+1 -1
View File
@@ -1052,7 +1052,7 @@ func TestBuildHAKsFailsForDuplicateResourcesInSameHAK(t *testing.T) {
if err == nil {
t.Fatal("expected duplicate same-hak build error")
}
if !strings.Contains(err.Error(), "conflicts") {
if !strings.Contains(err.Error(), "validation failed with 1 error(s)") {
t.Fatalf("unexpected error: %v", err)
}
}
+1 -1
View File
@@ -312,7 +312,7 @@ func classifyAssetDuplicates(report *Report, occurrences map[string][]assetOccur
slices.Sort(paths)
if len(groups) == 1 {
report.add(entries[0].Path, fmt.Sprintf("duplicate asset resource %s appears multiple times in hak group %q (%s); build will fail if duplicates land in the same generated hak", key, groups[0], strings.Join(paths, ", ")), SeverityWarning)
report.add(entries[0].Path, fmt.Sprintf("duplicate asset resource %s appears multiple times in hak group %q (%s); build will fail if duplicates land in the same generated hak", key, groups[0], strings.Join(paths, ", ")), SeverityError)
continue
}
+48
View File
@@ -54,6 +54,54 @@ func TestValidateProjectWarnsForCrossHAKDuplicateAssets(t *testing.T) {
}
}
func TestValidateProjectErrorsForSameHAKDuplicateAssets(t *testing.T) {
root := t.TempDir()
mustMkdir(t, filepath.Join(root, "src"))
mustMkdir(t, filepath.Join(root, "assets", "core", "a"))
mustMkdir(t, filepath.Join(root, "assets", "core", "b"))
mustMkdir(t, filepath.Join(root, "build"))
mustWriteFile(t, filepath.Join(root, "nwn-tool.json"), `{
"module": {
"name": "Test Assets",
"resref": "testassets"
},
"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", "shared.mdl"), "one")
mustWriteFile(t, filepath.Join(root, "assets", "core", "b", "shared.mdl"), "two")
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)
}
report := ValidateProject(p)
if !report.HasErrors() {
t.Fatalf("expected same-hak duplicate to be an error, got %#v", report.Diagnostics)
}
if report.ErrorCount() != 1 {
t.Fatalf("expected 1 error, got %d (%#v)", report.ErrorCount(), report.Diagnostics)
}
if report.WarningCount() != 0 {
t.Fatalf("expected no warnings, got %d (%#v)", report.WarningCount(), report.Diagnostics)
}
}
func TestValidateProjectWarnsForUppercaseResourceNames(t *testing.T) {
root := t.TempDir()
mustMkdir(t, filepath.Join(root, "src", "blueprints", "items"))