Remove validation errors for missing .nss files

This commit is contained in:
2026-04-02 20:15:01 +02:00
parent 77b21081d7
commit af4d23ea48
4 changed files with 193 additions and 9 deletions
+54
View File
@@ -97,6 +97,60 @@ func TestValidateProjectWarnsForUppercaseResourceNames(t *testing.T) {
}
}
func TestValidateProjectWarnsForMissingScriptReferences(t *testing.T) {
root := t.TempDir()
mustMkdir(t, filepath.Join(root, "src", "dialogs"))
mustMkdir(t, filepath.Join(root, "assets"))
mustMkdir(t, filepath.Join(root, "build"))
mustWriteFile(t, filepath.Join(root, "nwn-tool.json"), `{
"module": {
"name": "Test Module",
"resref": "testmod"
},
"paths": {
"source": "src",
"assets": "assets",
"build": "build"
}
}
`)
mustWriteFile(t, filepath.Join(root, "src", "dialogs", "merchant.dlg.json"), `{
"file_type": "DLG ",
"file_version": "V3.2",
"root": {
"struct_type": 0,
"fields": [
{
"label": "Script",
"type": "ResRef",
"value": "open_store"
}
]
}
}
`)
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 warnings only, got errors: %#v", report.Diagnostics)
}
if report.WarningCount() == 0 {
t.Fatalf("expected missing-script warning, got %#v", report.Diagnostics)
}
}
func mustMkdir(t *testing.T, path string) {
t.Helper()
if err := os.MkdirAll(path, 0o755); err != nil {