diff --git a/config.go b/config.go index 5f0cf2b..3db76bf 100644 --- a/config.go +++ b/config.go @@ -22,6 +22,13 @@ func getActuallyProvidedFlags() map[string]bool { return result } +func maybeGetConfig(override *config.Config) *config.Config { + if override != nil { + return override + } + return getConfig() +} + func getConfig() *config.Config { showVersion := false ignoreConfig := false diff --git a/main.go b/main.go index 0cd8fa0..0229d2e 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "runtime" "runtime/pprof" + "github.com/liamg/aminal/config" "github.com/liamg/aminal/gui" "github.com/liamg/aminal/platform" "github.com/liamg/aminal/terminal" @@ -20,11 +21,12 @@ func init() { } func main() { - initialize(nil) + initialize(nil, nil) } -func initialize(unitTestfunc callback) { - conf := getConfig() +func initialize(unitTestfunc callback, configOverride *config.Config) { + conf := maybeGetConfig(configOverride) + logger, err := getLogger(conf) if err != nil { fmt.Printf("Failed to create logger: %s\n", err) diff --git a/main_test.go b/main_test.go index 5ef9b88..ab91005 100644 --- a/main_test.go +++ b/main_test.go @@ -6,10 +6,12 @@ import ( "flag" "fmt" "os" + "runtime" "strings" "testing" "time" + "github.com/liamg/aminal/config" "github.com/liamg/aminal/gui" "github.com/liamg/aminal/terminal" @@ -123,7 +125,7 @@ func TestCursorMovement(t *testing.T) { g.Close() } - initialize(testFunc) + initialize(testFunc, testConfig()) }) } @@ -159,7 +161,7 @@ func TestScreenFeatures(t *testing.T) { g.Close() } - initialize(testFunc) + initialize(testFunc, testConfig()) }) } @@ -184,7 +186,7 @@ func TestSixel(t *testing.T) { g.Close() } - initialize(testFunc) + initialize(testFunc, testConfig()) }) } @@ -192,3 +194,14 @@ func TestSixel(t *testing.T) { func TestExit(t *testing.T) { os.Exit(0) } + +func testConfig() *config.Config { + c := config.DefaultConfig() + + // Use a vanilla shell on POSIX to help ensure consistency. + if runtime.GOOS != "windows" { + c.Shell = "/bin/sh" + } + + return c +}