diff --git a/info_test.go b/info_test.go index 8436a49..5f09db7 100644 --- a/info_test.go +++ b/info_test.go @@ -34,6 +34,10 @@ func TestEnv_PS(t *testing.T) { } func TestEnv_DIR_HOME(t *testing.T) { + if ch := os.Getenv("CORE_HOME"); ch != "" { + assert.Equal(t, ch, core.Env("DIR_HOME")) + return + } home, err := os.UserHomeDir() require.NoError(t, err) assert.Equal(t, home, core.Env("DIR_HOME")) diff --git a/path.go b/path.go index 023419d..d977e9c 100644 --- a/path.go +++ b/path.go @@ -1,8 +1,8 @@ // SPDX-License-Identifier: EUPL-1.2 // OS-aware filesystem path operations for the Core framework. -// Zero filepath import — uses Env("DS") for the separator and -// Core string primitives for all path manipulation. +// Uses Env("DS") for the separator and Core string primitives +// for path manipulation. filepath imported only for PathGlob. // // Path anchors relative segments to DIR_HOME: // @@ -29,6 +29,9 @@ import "path/filepath" func Path(segments ...string) string { ds := Env("DS") home := Env("DIR_HOME") + if home == "" { + home = "." + } if len(segments) == 0 { return home } diff --git a/path_test.go b/path_test.go index 56a3ac7..3f18b06 100644 --- a/path_test.go +++ b/path_test.go @@ -19,7 +19,8 @@ func TestPath_Relative(t *testing.T) { } func TestPath_Absolute(t *testing.T) { - assert.Equal(t, "/tmp/workspace", core.Path("/tmp", "workspace")) + ds := core.Env("DS") + assert.Equal(t, "/tmp"+ds+"workspace", core.Path("/tmp", "workspace")) } func TestPath_Empty(t *testing.T) { @@ -35,7 +36,8 @@ func TestPath_Cleans(t *testing.T) { } func TestPath_CleanDoubleSlash(t *testing.T) { - assert.Equal(t, "/tmp/file", core.Path("/tmp//file")) + ds := core.Env("DS") + assert.Equal(t, ds+"tmp"+ds+"file", core.Path("/tmp//file")) } func TestPathBase(t *testing.T) {