Dev Testing + AutoGen Activation
This commit is contained in:
@@ -9189,6 +9189,118 @@ func TestBuildNativeWithReleasedPartsManifest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildNativeWithReleasedHeadVisualeffectsManifest(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
projRoot := filepath.Join(root, "project")
|
||||
mkdirAll(t, filepath.Join(projRoot, "src"))
|
||||
mkdirAll(t, filepath.Join(projRoot, "assets"))
|
||||
mkdirAll(t, filepath.Join(projRoot, "build"))
|
||||
mkdirAll(t, filepath.Join(projRoot, "topdata", "data", "visualeffects"))
|
||||
writeFile(t, filepath.Join(projRoot, "topdata", "base_dialog.json"), "{}\n")
|
||||
writeFile(t, filepath.Join(projRoot, "topdata", "data", "visualeffects", "base.json"), `{
|
||||
"output": "visualeffects.2da",
|
||||
"columns": ["Label", "Type_FD", "OrientWithGround", "Imp_HeadCon_Node", "OrientWithObject"],
|
||||
"rows": [
|
||||
{"key": "visualeffects:existing", "id": 17, "Label": "EXISTING", "Type_FD": "F", "OrientWithGround": "0", "Imp_HeadCon_Node": "****", "OrientWithObject": "0"}
|
||||
]
|
||||
}`+"\n")
|
||||
writeFile(t, filepath.Join(projRoot, "topdata", "data", "visualeffects", "lock.json"), `{
|
||||
"visualeffects:existing": 17
|
||||
}`+"\n")
|
||||
mkdirAll(t, filepath.Join(projRoot, "reference"))
|
||||
writeFile(t, filepath.Join(projRoot, "reference", "build.py"), "print('ok')\n")
|
||||
|
||||
manifestJSON := `{
|
||||
"id": "head_visualeffects",
|
||||
"repo": "ShadowsOverWestgate/sow-assets",
|
||||
"ref": "test-manifest",
|
||||
"generated_at": "2026-04-25T00:00:00Z",
|
||||
"entries": [
|
||||
{
|
||||
"group": "head_accessories",
|
||||
"model_stem": "hfx_bandana",
|
||||
"source": "head_accessories/hfx_bandana.mdl"
|
||||
},
|
||||
{
|
||||
"group": "head_features",
|
||||
"model_stem": "hfx_hair_bangs",
|
||||
"source": "head_features/hair/hfx_hair_bangs.mdl"
|
||||
}
|
||||
]
|
||||
}` + "\n"
|
||||
|
||||
var server *httptest.Server
|
||||
server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case "/api/v1/repos/ShadowsOverWestgate/sow-assets/releases/tags/head-vfx-manifest-current":
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"assets":[{"name":"sow-head-vfx-manifest.json","browser_download_url":"` + server.URL + `/downloads/sow-head-vfx-manifest.json"}]}`))
|
||||
case "/downloads/sow-head-vfx-manifest.json":
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(manifestJSON))
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
runGitTest(t, "", "init", "-b", "main", projRoot)
|
||||
runGitTest(t, projRoot, "remote", "add", "origin", server.URL+"/ShadowsOverWestgate/sow-module.git")
|
||||
|
||||
proj := &project.Project{
|
||||
Root: projRoot,
|
||||
Config: project.Config{
|
||||
Module: project.ModuleConfig{Name: "Test", ResRef: "test"},
|
||||
Paths: project.PathConfig{Source: "src", Assets: "assets", Build: "build"},
|
||||
TopData: project.TopDataConfig{
|
||||
Source: "topdata",
|
||||
Build: "build/topdata",
|
||||
},
|
||||
Autogen: project.AutogenConfig{
|
||||
Consumers: []project.AutogenConsumerConfig{
|
||||
{
|
||||
ID: "head_visualeffects",
|
||||
Producer: "head_visualeffects",
|
||||
Dataset: "visualeffects",
|
||||
Mode: "head_visualeffects",
|
||||
Root: "vfxs",
|
||||
Include: []string{"head_accessories/**/*.mdl", "head_features/**/*.mdl"},
|
||||
Derive: project.AutogenDeriveConfig{
|
||||
Kind: "model_stem",
|
||||
GroupFrom: "first_path_segment",
|
||||
},
|
||||
Manifest: project.AutogenManifestConfig{
|
||||
ReleaseTag: "head-vfx-manifest-current",
|
||||
AssetName: "sow-head-vfx-manifest.json",
|
||||
CacheName: "sow-head-vfx-manifest.json",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
result, err := BuildNative(proj, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("BuildNative failed: %v", err)
|
||||
}
|
||||
|
||||
visualeffectsBytes, err := os.ReadFile(filepath.Join(result.Output2DADir, "visualeffects.2da"))
|
||||
if err != nil {
|
||||
t.Fatalf("read visualeffects.2da: %v", err)
|
||||
}
|
||||
text := string(visualeffectsBytes)
|
||||
for _, want := range []string{
|
||||
"0\theadaccessory_BANDANA\tD\t0\thfx_bandana\t1",
|
||||
"1\theadfeature_HAIR_BANGS\tD\t0\thfx_hair_bangs\t1",
|
||||
"17\tEXISTING\tF\t0\t****\t0",
|
||||
} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("expected visualeffects output to contain %q, got:\n%s", want, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildNativeRejectsGitRepoTopDataAssetsOverride(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data", "parts"))
|
||||
|
||||
Reference in New Issue
Block a user