Skip to content

Commit 62e62de

Browse files
committed
fix: improve test reliability and reduce verbose logging
This commit addresses CI test failures and improves the development experience: **Test Reliability Improvements:** - Fix Java executable detection in integration tests to check direct bin/java location first, preventing bin/bin/java path construction errors - Add proper working directory restoration in test cleanup to prevent 'getwd: no such file or directory' errors in subsequent tests - Skip 'bin' directories when searching for nested Java installations - Add comprehensive Java installation debug test for CI troubleshooting **Verbose Logging Improvements:** - Reduce environment variable logging noise by only logging actual changes - Track original environment variable values to detect meaningful changes - Eliminate redundant logging of unchanged system environment variables - Maintain visibility into actual environment modifications made by mvx **Technical Details:** - Modified EnvironmentManager to track original values for change detection - Enhanced findJavaExecutableWithDebug with proper directory traversal logic - Added createTestEnvironment/cleanupTestEnvironment with directory restoration - Improved test isolation to prevent cross-test contamination These changes significantly improve CI reliability and reduce log verbosity while maintaining full visibility into meaningful environment changes.
1 parent d72a895 commit 62e62de

File tree

3 files changed

+1165
-36
lines changed

3 files changed

+1165
-36
lines changed

pkg/tools/environment.go

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ import (
1111

1212
// EnvironmentManager provides safe environment variable management with special PATH handling
1313
type EnvironmentManager struct {
14-
envVars map[string]string
15-
pathDirs []string
14+
envVars map[string]string
15+
pathDirs []string
16+
originalEnvVars map[string]string // Track original values to detect changes
1617
}
1718

1819
// NewEnvironmentManager creates a new environment manager
1920
func NewEnvironmentManager() *EnvironmentManager {
2021
return &EnvironmentManager{
21-
envVars: make(map[string]string),
22-
pathDirs: []string{},
22+
envVars: make(map[string]string),
23+
pathDirs: []string{},
24+
originalEnvVars: make(map[string]string),
2325
}
2426
}
2527

@@ -35,6 +37,7 @@ func NewEnvironmentManagerFromMap(envVars map[string]string) *EnvironmentManager
3537
}
3638
} else {
3739
em.envVars[key] = value
40+
em.originalEnvVars[key] = value // Track original value
3841
}
3942
}
4043

@@ -46,8 +49,28 @@ func (em *EnvironmentManager) SetEnv(key, value string) {
4649
if key == "PATH" {
4750
panic("Cannot set PATH directly, use AddToPath() or AppendToPath() instead")
4851
}
52+
53+
// Check if this is a new value or a change
54+
oldValue, existed := em.envVars[key]
55+
_, hadOriginal := em.originalEnvVars[key]
56+
57+
// Store the original value if this is the first time we're seeing this key
58+
if !hadOriginal {
59+
em.originalEnvVars[key] = os.Getenv(key)
60+
}
61+
4962
em.envVars[key] = value
50-
util.LogVerbose("Set environment variable %s=%s", key, value)
63+
64+
// Only log if the value actually changed from the original
65+
if !existed {
66+
// New variable being set
67+
if em.originalEnvVars[key] != value {
68+
util.LogVerbose("Set environment variable %s=%s", key, value)
69+
}
70+
} else if oldValue != value {
71+
// Value changed
72+
util.LogVerbose("Updated environment variable %s=%s (was: %s)", key, value, oldValue)
73+
}
5174
}
5275

5376
// GetEnv gets an environment variable

0 commit comments

Comments
 (0)