paths.build fix
build-binaries / build-binaries (pull_request) Successful in 2m18s
test-image / build-image (pull_request) Successful in 51s
test / test (pull_request) Successful in 1m30s

This commit is contained in:
2026-06-21 20:28:44 +02:00
parent 3315f8b7eb
commit 5559479755
3 changed files with 58 additions and 0 deletions
+46
View File
@@ -1113,6 +1113,52 @@ func TestValidateLayoutAllowsMissingAssetsDir(t *testing.T) {
}
}
// paths.build is an OUTPUT dir the builder creates (MkdirAll) before writing, so
// a bare clone with no build dir yet must still validate/build with no pre-step
// (R2/parity). Only a build path that exists but is not a directory is an error.
func TestValidateLayoutAllowsMissingBuildDir(t *testing.T) {
root := t.TempDir()
mkdirAll(t, filepath.Join(root, "src"))
// deliberately do NOT create build/
proj := &Project{
Root: root,
Config: Config{
Module: ModuleConfig{Name: "Test", ResRef: "test"},
Paths: PathConfig{Source: "src", Build: "build"},
},
}
if err := proj.ValidateLayout(); err != nil {
t.Fatalf("ValidateLayout returned error for missing build dir: %v", err)
}
if _, err := os.Stat(filepath.Join(root, "build")); !errors.Is(err, os.ErrNotExist) {
t.Fatalf("expected missing build dir to remain absent, got err=%v", err)
}
}
// A build path that exists but is a regular file is still a hard error.
func TestValidateLayoutRejectsBuildDirThatIsAFile(t *testing.T) {
root := t.TempDir()
mkdirAll(t, filepath.Join(root, "src"))
if err := os.WriteFile(filepath.Join(root, "build"), []byte("i am a file, not a dir"), 0o644); err != nil {
t.Fatal(err)
}
proj := &Project{
Root: root,
Config: Config{
Module: ModuleConfig{Name: "Test", ResRef: "test"},
Paths: PathConfig{Source: "src", Build: "build"},
},
}
err := proj.ValidateLayout()
if err == nil || !strings.Contains(err.Error(), "paths.build must be a directory") {
t.Fatalf("expected paths.build-must-be-a-directory error, got %v", err)
}
}
func TestValidateLayoutRejectsInvalidTopDataPackageOutputNames(t *testing.T) {
root := t.TempDir()
mkdirAll(t, filepath.Join(root, "src"))