Force Check Duplicates
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user