Compare commits

...

6 Commits

Author SHA1 Message Date
Stefan Haller
8311933de4 Fix running integration tests on Windows
At least they now work when using
  go run cmd/integration_test/main.go cli
or
  go run cmd/integration_test/main.go tui

I haven't been able to get them to run headless (i.e. using
"go test pkg/integration/clients/*.go"), which prevents us from running them on
CI.
2024-01-20 18:32:39 +01:00
stk
0afcc3d34d Skip some more tests that don't work on Windows
It might be possible to make them work somehow, but for now I'm focusing on
getting things green as quickly as possible.
2024-01-20 18:32:39 +01:00
Stefan Haller
23613b8063 Skip complex_cmd_at_runtime.go test on Windows 2024-01-19 23:19:30 +01:00
Stefan Haller
c426df91f3 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.
2024-01-19 22:29:06 +01:00
Stefan Haller
7274d86d54 Skip tests for credentials on Windows
They use test/files/pre-push, which doesn't work on Windows.
2024-01-19 22:02:35 +01:00
Stefan Haller
d9324019a3 Add __debug_bin.exe to .gitignore
It is created on Windows when debugging lazygit using VS Code.
2024-01-19 22:02:33 +01:00
12 changed files with 46 additions and 12 deletions

1
.gitignore vendored
View File

@@ -39,6 +39,7 @@ test/_results/**
oryxBuildBinary
__debug_bin
__debug_bin.exe
.worktrees
demo/output/*

View File

@@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
lazycoreUtils "github.com/jesseduffield/lazycore/pkg/utils"
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
@@ -254,11 +255,16 @@ func getLazygitCommand(
}
func tempLazygitPath() string {
return filepath.Join("/tmp", "lazygit", "test_lazygit")
filename := "test_lazygit"
if runtime.GOOS == "windows" {
filename = "test_lazygit.exe"
}
return filepath.Join(os.TempDir(), "lazygit", filename)
}
func raceDetectorLogsPath() string {
return filepath.Join("/tmp", "lazygit", "race_log")
return filepath.Join(os.TempDir(), "lazygit", "race_log")
}
func findOrCreateDir(path string) {

View File

@@ -2,6 +2,7 @@ package components
import (
"os"
"path/filepath"
"strconv"
"strings"
@@ -223,7 +224,7 @@ func testNameFromCurrentFilePath() string {
}
func TestNameFromFilePath(path string) string {
name := strings.Split(path, "integration/tests/")[1]
name := strings.Split(filepath.ToSlash(path), "integration/tests/")[1]
return name[:len(name)-len(".go")]
}

View File

@@ -1,6 +1,8 @@
package branch
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@@ -8,7 +10,7 @@ import (
var DeleteRemoteBranchWithCredentialPrompt = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Delete a remote branch where credentials are required",
ExtraCmdArgs: []string{},
Skip: false,
Skip: runtime.GOOS == "windows",
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {

View File

@@ -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)

View File

@@ -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,
},
}
},

View File

@@ -1,6 +1,8 @@
package custom_commands
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@@ -8,7 +10,7 @@ import (
var ComplexCmdAtRuntime = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using a custom command provided at runtime to create a new file, via a shell command. We invoke custom commands through a shell already. This test proves that we can run a shell within a shell, which requires complex escaping.",
ExtraCmdArgs: []string{},
Skip: false,
Skip: runtime.GOOS == "windows",
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("blah")
},

View File

@@ -1,6 +1,8 @@
package custom_commands
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@@ -8,7 +10,7 @@ import (
var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using a custom command reffering prompt responses by name",
ExtraCmdArgs: []string{},
Skip: false,
Skip: runtime.GOOS == "windows",
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("blah")
},

View File

@@ -1,6 +1,8 @@
package custom_commands
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@@ -10,7 +12,7 @@ import (
var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using menuFromCommand prompt type",
ExtraCmdArgs: []string{},
Skip: false,
Skip: runtime.GOOS == "windows",
SetupRepo: func(shell *Shell) {
shell.
EmptyCommit("foo").

View File

@@ -1,6 +1,8 @@
package custom_commands
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@@ -8,7 +10,7 @@ import (
var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using a custom command with multiple prompts",
ExtraCmdArgs: []string{},
Skip: false,
Skip: runtime.GOOS == "windows",
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("blah")
},

View File

@@ -1,6 +1,8 @@
package misc
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@@ -10,7 +12,7 @@ import (
var CopyToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Copy a branch name to the clipboard using custom clipboard command template",
ExtraCmdArgs: []string{},
Skip: false,
Skip: runtime.GOOS == "windows",
SetupConfig: func(config *config.AppConfig) {
config.UserConfig.OS.CopyToClipboardCmd = "echo {{text}} > clipboard"
},

View File

@@ -1,6 +1,8 @@
package sync
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@@ -8,7 +10,7 @@ import (
var PushWithCredentialPrompt = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Push a commit to a pre-configured upstream, where credentials are required",
ExtraCmdArgs: []string{},
Skip: false,
Skip: runtime.GOOS == "windows",
SetupConfig: func(config *config.AppConfig) {
},
SetupRepo: func(shell *Shell) {