Fix validation steps for image files
This commit is contained in:
@@ -111,6 +111,7 @@ var extensionTypes = map[string]uint16{
|
||||
"shd": 0x0815,
|
||||
"mtr": 0x0818,
|
||||
"lod": 0x081E,
|
||||
"png": 0x083E,
|
||||
}
|
||||
|
||||
var typeExtensions map[uint16]string
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/erf"
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/gff"
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/project"
|
||||
)
|
||||
|
||||
func TestDebugModuleIFO(t *testing.T) {
|
||||
root := "/home/vicky/Projects/sow-ShadowsOverWestgate/repositories/sow-module"
|
||||
p, err := project.Load(root)
|
||||
if err != nil { t.Fatal(err) }
|
||||
if err := p.Scan(); err != nil { t.Fatal(err) }
|
||||
exp, err := expectedResources(p)
|
||||
if err != nil { t.Fatal(err) }
|
||||
gotArchive, err := readArchive(filepath.Join(p.BuildDir(), p.Config.Module.ResRef+".mod"))
|
||||
if err != nil { t.Fatal(err) }
|
||||
got := archiveIndex(gotArchive)
|
||||
e := exp["module.ifo"].Bytes
|
||||
a := got["module.ifo"].Data
|
||||
fmt.Printf("EQUAL=%v\n", bytes.Equal(e,a))
|
||||
fmt.Printf("EXPECTED=%s\n", string(e))
|
||||
fmt.Printf("ACTUAL=%s\n", string(a))
|
||||
|
||||
var edoc gff.Document
|
||||
sourceRaw, _ := os.ReadFile(filepath.Join(root, "src/module/module.ifo.json"))
|
||||
_ = json.Unmarshal(sourceRaw, &edoc)
|
||||
fmt.Printf("SOURCE=%s\n", string(sourceRaw))
|
||||
|
||||
mod, _ := erf.Read(bytes.NewReader(mustRead(filepath.Join(p.BuildDir(), p.Config.Module.ResRef+".mod"))))
|
||||
_ = mod
|
||||
}
|
||||
|
||||
func mustRead(path string) []byte { b, _ := os.ReadFile(path); return b }
|
||||
@@ -19,7 +19,7 @@ var SourceExtensions = []string{
|
||||
}
|
||||
|
||||
var AssetExtensions = []string{
|
||||
".2da", ".bik", ".dds", ".dwk", ".itp", ".lod", ".lyt", ".mdl", ".mdx", ".mtr", ".plt", ".pwk", ".set", ".shd", ".tga", ".txi", ".uti", ".vis", ".wav", ".wok",
|
||||
".2da", ".bik", ".bmp", ".dds", ".dwk", ".itp", ".jpg", ".lod", ".lyt", ".mdl", ".mdx", ".mtr", ".plt", ".png", ".pwk", ".set", ".shd", ".tga", ".txi", ".uti", ".vis", ".wav", ".wok",
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
|
||||
@@ -8073,7 +8073,7 @@ func TestBuildAndPackageIncludesCompiled2DAAndTopAssets(t *testing.T) {
|
||||
"columns": ["Label"],
|
||||
"rows": [{"id": 0, "Label": "TEST_LABEL"}]
|
||||
}`+"\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "assets", "gui", "testicon.tga"), "icon-data")
|
||||
writeFile(t, filepath.Join(root, "topdata", "assets", "gui", "testicon.png"), "icon-data")
|
||||
|
||||
proj := testProject(root)
|
||||
proj.Config.TopData.ReferenceBuilder = ""
|
||||
@@ -8106,7 +8106,7 @@ func TestBuildAndPackageIncludesCompiled2DAAndTopAssets(t *testing.T) {
|
||||
if key == "repadjust.2da" {
|
||||
found2DA = true
|
||||
}
|
||||
if key == "testicon.tga" {
|
||||
if key == "testicon.png" {
|
||||
foundAsset = true
|
||||
}
|
||||
}
|
||||
@@ -8114,13 +8114,31 @@ func TestBuildAndPackageIncludesCompiled2DAAndTopAssets(t *testing.T) {
|
||||
t.Fatalf("expected repadjust.2da in top package")
|
||||
}
|
||||
if !foundAsset {
|
||||
t.Fatalf("expected testicon.tga in top package")
|
||||
t.Fatalf("expected testicon.png in top package")
|
||||
}
|
||||
if _, err := os.Stat(result.OutputTLKPath); err != nil {
|
||||
t.Fatalf("expected packaged tlk output: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateProjectAcceptsPNGTopPackageAsset(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data", "repadjust"))
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "assets", "gui"))
|
||||
writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "repadjust", "base.json"), `{
|
||||
"output": "repadjust.2da",
|
||||
"columns": ["Label"],
|
||||
"rows": [{"id": 0, "Label": "TEST_LABEL"}]
|
||||
}`+"\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "assets", "gui", "testicon.png"), "icon-data")
|
||||
|
||||
report := ValidateProject(testProject(root))
|
||||
if report.HasErrors() {
|
||||
t.Fatalf("expected png topdata asset to validate, got %#v", report.Diagnostics)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildPackageRequiresExistingCompiledOutput(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data", "repadjust"))
|
||||
|
||||
Reference in New Issue
Block a user