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
+79
View File
@@ -87,6 +87,9 @@ func TestBuildThenExtract(t *testing.T) {
if err := p.Scan(); err != nil {
t.Fatalf("scan after extract: %v", err)
}
if _, err := BuildModule(p); err != nil {
t.Fatalf("rebuild after extract: %v", err)
}
compareResult, err := Compare(p)
if err != nil {
@@ -773,6 +776,82 @@ func TestExtractNormalizesResourceNamesToLowercase(t *testing.T) {
}
}
func TestCompareFailsWhenBuildIsStale(t *testing.T) {
root := t.TempDir()
mustMkdir(t, filepath.Join(root, "src", "module"))
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", "module", "module.ifo.json"), `{
"file_type": "IFO ",
"file_version": "V3.2",
"root": {
"struct_type": 0,
"fields": [
{
"label": "Mod_Name",
"type": "CExoString",
"value": "Original Module"
}
]
}
}
`)
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)
}
if _, err := BuildModule(p); err != nil {
t.Fatalf("build module: %v", err)
}
mustWriteFile(t, filepath.Join(root, "src", "module", "module.ifo.json"), `{
"file_type": "IFO ",
"file_version": "V3.2",
"root": {
"struct_type": 0,
"fields": [
{
"label": "Mod_Name",
"type": "CExoString",
"value": "Updated Module"
}
]
}
}
`)
if err := p.Scan(); err != nil {
t.Fatalf("rescan: %v", err)
}
_, err = Compare(p)
if err == nil {
t.Fatal("expected stale compare error")
}
if !strings.Contains(err.Error(), "built archives are older than source file") {
t.Fatalf("unexpected compare error: %v", err)
}
}
func mustMkdir(t *testing.T, path string) {
t.Helper()
if err := os.MkdirAll(path, 0o755); err != nil {