From c426df91f39bec79c8269e740f80a84d758ce5f2 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 19 Jan 2024 22:12:47 +0100 Subject: [PATCH] Adapt tests for custom commands to work on Windows The "touch" command isn't available on Windows, but "copy NUL file" seems to be a good approximation. --- .../tests/custom_commands/basic_cmd_at_runtime.go | 8 +++++++- .../tests/custom_commands/basic_cmd_from_config.go | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/integration/tests/custom_commands/basic_cmd_at_runtime.go b/pkg/integration/tests/custom_commands/basic_cmd_at_runtime.go index 9e1d1a185..77a055884 100644 --- a/pkg/integration/tests/custom_commands/basic_cmd_at_runtime.go +++ b/pkg/integration/tests/custom_commands/basic_cmd_at_runtime.go @@ -1,6 +1,8 @@ package custom_commands import ( + "runtime" + "github.com/jesseduffield/lazygit/pkg/config" . "github.com/jesseduffield/lazygit/pkg/integration/components" ) @@ -14,6 +16,10 @@ var BasicCmdAtRuntime = NewIntegrationTest(NewIntegrationTestArgs{ }, SetupConfig: func(cfg *config.AppConfig) {}, Run: func(t *TestDriver, keys config.KeybindingConfig) { + cmd := "touch file.txt" + if runtime.GOOS == "windows" { + cmd = "copy NUL file.txt" + } t.Views().Files(). IsEmpty(). IsFocused(). @@ -21,7 +27,7 @@ var BasicCmdAtRuntime = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Prompt(). Title(Equals("Custom command:")). - Type("touch file.txt"). + Type(cmd). Confirm() t.GlobalPress(keys.Files.RefreshFiles) diff --git a/pkg/integration/tests/custom_commands/basic_cmd_from_config.go b/pkg/integration/tests/custom_commands/basic_cmd_from_config.go index 71b99c2de..d2880b0f0 100644 --- a/pkg/integration/tests/custom_commands/basic_cmd_from_config.go +++ b/pkg/integration/tests/custom_commands/basic_cmd_from_config.go @@ -1,6 +1,8 @@ package custom_commands import ( + "runtime" + "github.com/jesseduffield/lazygit/pkg/config" . "github.com/jesseduffield/lazygit/pkg/integration/components" ) @@ -13,11 +15,15 @@ var BasicCmdFromConfig = NewIntegrationTest(NewIntegrationTestArgs{ shell.EmptyCommit("blah") }, SetupConfig: func(cfg *config.AppConfig) { + cmd := "touch myfile" + if runtime.GOOS == "windows" { + cmd = "copy NUL myfile" + } cfg.UserConfig.CustomCommands = []config.CustomCommand{ { Key: "a", Context: "files", - Command: "touch myfile", + Command: cmd, }, } },