@@ -2,6 +2,7 @@ package main
22
33import (
44 "os"
5+ "os/exec"
56 "path/filepath"
67 "testing"
78)
@@ -108,14 +109,26 @@ func TestConfigurationMissingRequired(t *testing.T) {
108109
109110// TestConfigurationEmpty tests handling of empty configuration
110111func TestConfigurationEmpty (t * testing.T ) {
112+ if os .Getenv ("TEST_CONFIGURATION_EMPTY_SUBPROCESS" ) == "1" {
113+ tmpFile := os .Getenv ("TEST_CONFIGURATION_EMPTY_FILE" )
114+ var config Configuration
115+ config .getConfiguration (tmpFile )
116+ return
117+ }
118+
111119 tmpFile := filepath .Join (t .TempDir (), "empty_config.yml" )
112120 os .WriteFile (tmpFile , []byte ("" ), 0644 )
113121
114- var config Configuration
115- config .getConfiguration (tmpFile )
122+ cmd := exec .Command (os .Args [0 ], "-test.run=TestConfigurationEmpty" )
123+ cmd .Env = append (os .Environ (), "TEST_CONFIGURATION_EMPTY_SUBPROCESS=1" , "TEST_CONFIGURATION_EMPTY_FILE=" + tmpFile )
124+ err := cmd .Run ()
116125
117- // Verify no panic occurred
118- t .Log ("Empty configuration handled gracefully" )
126+ // We expect an exit error here because LogFatal calls os.Exit(1)
127+ if e , ok := err .(* exec.ExitError ); ok && ! e .Success () {
128+ t .Log ("Empty configuration triggered exit as expected" )
129+ return
130+ }
131+ t .Fatalf ("process ran with err %v, want exit status 1" , err )
119132}
120133
121134// TestConfigurationYARAWithRC4 tests YARA section with RC4 encryption
0 commit comments