From 2312801d4353c2bf1ca6757dfe7c1e4cb968bb8a Mon Sep 17 00:00:00 2001 From: Snider Date: Sun, 22 Mar 2026 10:12:52 +0000 Subject: [PATCH] fix: address CodeRabbit review findings - TestEnv_DIR_HOME checks CORE_HOME override first - Path tests use Env("DS") instead of hardcoded "/" - Path() falls back to "." when DIR_HOME is empty - Doc comment no longer claims "zero filepath import" Co-Authored-By: Virgil --- info_test.go | 4 ++++ path.go | 7 +++++-- path_test.go | 6 ++++-- 3 files changed, 13 insertions(+), 4 deletions(-) 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) { -- 2.45.3