Dev Testing + AutoGen Activation
This commit is contained in:
@@ -1451,6 +1451,117 @@ func TestPlanHAKsWritesManifestWithoutArchives(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildHAKsWritesConfiguredAutogenManifests(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
mustMkdir(t, filepath.Join(root, "src"))
|
||||
mustMkdir(t, filepath.Join(root, "assets", "part", "belt"))
|
||||
mustMkdir(t, filepath.Join(root, "assets", "vfxs", "head_accessories"))
|
||||
mustMkdir(t, filepath.Join(root, "assets", "vfxs", "head_features", "hair"))
|
||||
mustMkdir(t, filepath.Join(root, "build"))
|
||||
|
||||
mustWriteFile(t, filepath.Join(root, "nwn-tool.json"), `{
|
||||
"module": {
|
||||
"name": "Test Module",
|
||||
"resref": "testmod",
|
||||
"hak_order": ["group:core"]
|
||||
},
|
||||
"paths": {
|
||||
"source": "src",
|
||||
"assets": "assets",
|
||||
"build": "build"
|
||||
},
|
||||
"autogen": {
|
||||
"producers": [
|
||||
{
|
||||
"id": "parts",
|
||||
"root": "part",
|
||||
"include": ["**/*.mdl"],
|
||||
"derive": {
|
||||
"kind": "trailing_numeric_suffix",
|
||||
"group_from": "first_path_segment"
|
||||
},
|
||||
"manifest": {
|
||||
"release_tag": "parts-manifest-current",
|
||||
"asset_name": "sow-parts-manifest.json",
|
||||
"cache_name": "sow-parts-manifest.json"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "head_visualeffects",
|
||||
"root": "vfxs",
|
||||
"include": ["head_accessories/**/*.mdl", "head_features/**/*.mdl"],
|
||||
"derive": {
|
||||
"kind": "model_stem",
|
||||
"group_from": "first_path_segment"
|
||||
},
|
||||
"manifest": {
|
||||
"release_tag": "head-vfx-manifest-current",
|
||||
"asset_name": "sow-head-vfx-manifest.json",
|
||||
"cache_name": "sow-head-vfx-manifest.json"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"haks": [
|
||||
{
|
||||
"name": "core",
|
||||
"priority": 1,
|
||||
"max_bytes": 0,
|
||||
"split": false,
|
||||
"include": ["part/**", "vfxs/**"]
|
||||
}
|
||||
]
|
||||
}
|
||||
`)
|
||||
mustWriteFile(t, filepath.Join(root, "assets", "part", "belt", "pfa0_belt018.mdl"), "belt")
|
||||
mustWriteFile(t, filepath.Join(root, "assets", "vfxs", "head_accessories", "hfx_bandana.mdl"), "bandana")
|
||||
mustWriteFile(t, filepath.Join(root, "assets", "vfxs", "head_features", "hair", "hfx_hair_bangs.mdl"), "hair")
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
result, err := BuildHAKs(p)
|
||||
if err != nil {
|
||||
t.Fatalf("build haks: %v", err)
|
||||
}
|
||||
if len(result.AutogenManifestPaths) != 2 {
|
||||
t.Fatalf("expected 2 autogen manifests, got %d", len(result.AutogenManifestPaths))
|
||||
}
|
||||
|
||||
partsRaw, err := os.ReadFile(filepath.Join(root, "build", "sow-parts-manifest.json"))
|
||||
if err != nil {
|
||||
t.Fatalf("read parts manifest: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(partsRaw), `"id": "parts"`) || !strings.Contains(string(partsRaw), `"row_id": 18`) {
|
||||
t.Fatalf("unexpected parts manifest contents:\n%s", string(partsRaw))
|
||||
}
|
||||
|
||||
headRaw, err := os.ReadFile(filepath.Join(root, "build", "sow-head-vfx-manifest.json"))
|
||||
if err != nil {
|
||||
t.Fatalf("read head visualeffects manifest: %v", err)
|
||||
}
|
||||
text := string(headRaw)
|
||||
for _, want := range []string{
|
||||
`"id": "head_visualeffects"`,
|
||||
`"group": "head_accessories"`,
|
||||
`"model_stem": "hfx_bandana"`,
|
||||
`"group": "head_features"`,
|
||||
`"model_stem": "hfx_hair_bangs"`,
|
||||
} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("expected head visualeffects manifest to contain %q, got:\n%s", want, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildSkipsEmptyHAKGroupsInModuleOrder(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
mustMkdir(t, filepath.Join(root, "src"))
|
||||
|
||||
Reference in New Issue
Block a user