Native Workflow Support
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/erf"
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/project"
|
||||
)
|
||||
|
||||
@@ -8061,6 +8062,85 @@ func TestBuildNativeWithSiblingAssetsRepo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildPackageIncludesCompiled2DAAndTopAssets(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.tga"), "icon-data")
|
||||
|
||||
proj := testProject(root)
|
||||
proj.Config.TopData.ReferenceBuilder = ""
|
||||
|
||||
result, err := BuildPackage(proj, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("BuildPackage failed: %v", err)
|
||||
}
|
||||
if result.OutputHAKPath != filepath.Join(root, "build", PackageHAKFileName) {
|
||||
t.Fatalf("unexpected hak path: %s", result.OutputHAKPath)
|
||||
}
|
||||
if result.OutputTLKPath != filepath.Join(root, "build", PackageTLKFileName) {
|
||||
t.Fatalf("unexpected tlk path: %s", result.OutputTLKPath)
|
||||
}
|
||||
|
||||
input, err := os.Open(result.OutputHAKPath)
|
||||
if err != nil {
|
||||
t.Fatalf("open hak: %v", err)
|
||||
}
|
||||
defer input.Close()
|
||||
archive, err := erf.Read(input)
|
||||
if err != nil {
|
||||
t.Fatalf("read hak: %v", err)
|
||||
}
|
||||
found2DA := false
|
||||
foundAsset := false
|
||||
for _, resource := range archive.Resources {
|
||||
ext, _ := erf.ExtensionForResourceType(resource.Type)
|
||||
key := strings.ToLower(resource.Name) + "." + ext
|
||||
if key == "repadjust.2da" {
|
||||
found2DA = true
|
||||
}
|
||||
if key == "testicon.tga" {
|
||||
foundAsset = true
|
||||
}
|
||||
}
|
||||
if !found2DA {
|
||||
t.Fatalf("expected repadjust.2da in top package")
|
||||
}
|
||||
if !foundAsset {
|
||||
t.Fatalf("expected testicon.tga in top package")
|
||||
}
|
||||
if _, err := os.Stat(result.OutputTLKPath); err != nil {
|
||||
t.Fatalf("expected packaged tlk output: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateProjectErrorsOnTopPackageAssetCollision(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", "repadjust.2da"), "collision")
|
||||
|
||||
report := ValidateProject(testProject(root))
|
||||
if !report.HasErrors() {
|
||||
t.Fatalf("expected topdata asset collision to be an error")
|
||||
}
|
||||
if !strings.Contains(diagnosticsText(report.Diagnostics), "collides with compiled topdata output") {
|
||||
t.Fatalf("expected collision diagnostic, got %#v", report.Diagnostics)
|
||||
}
|
||||
}
|
||||
|
||||
func diagnosticsText(diags []Diagnostic) string {
|
||||
lines := make([]string, 0, len(diags))
|
||||
for _, diag := range diags {
|
||||
|
||||
Reference in New Issue
Block a user