diff --git a/.gitignore b/.gitignore index 9e9059b19..a1a0ebe21 100644 --- a/.gitignore +++ b/.gitignore @@ -42,11 +42,7 @@ test/integration/*/used_config/ test/integration/*/expected/**/hooks/ test/integration/*/expected_remote/**/hooks/ -test/integration_new/**/actual/ -test/integration_new/**/used_config/ -# these sample hooks waste too much space -test/integration_new/**/expected/**/hooks/ -test/integration_new/**/expected_remote/**/hooks/ +test/integration_new/** oryxBuildBinary __debug_bin diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 1d14c9f50..4fb5cca95 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -32,6 +32,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/integration/components" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" "github.com/jesseduffield/lazygit/pkg/tasks" "github.com/jesseduffield/lazygit/pkg/theme" @@ -426,7 +427,7 @@ func (gui *Gui) initGocui(headless bool, test integrationTypes.IntegrationTest) playMode = gocui.RECORDING } else if Replaying() { playMode = gocui.REPLAYING - } else if test != nil { + } else if test != nil && os.Getenv(components.SANDBOX_ENV_VAR) != "true" { playMode = gocui.REPLAYING_NEW } diff --git a/pkg/integration/README.md b/pkg/integration/README.md index c4d233d07..3c75792ed 100644 --- a/pkg/integration/README.md +++ b/pkg/integration/README.md @@ -61,6 +61,8 @@ The name of a test is based on its path, so the name of the test at `pkg/integra You can pass the KEY_PRESS_DELAY env var to the test runner in order to set a delay in milliseconds between keypresses, which helps for watching a test at a realistic speed to understand what it's doing. Or you can pass the '--slow' flag which sets a pre-set 'slow' key delay. In the tui you can press 't' to run the test in slow mode. +The resultant repo will be stored in `test/integration_new`, so if you're not sure what went wrong you can go there and inspect the repo. + ### Running tests in VSCode If you've opened an integration test file in your editor you can run that file by bringing up the command panel with `cmd+shift+p` and typing 'run task', then selecting the test task you want to run diff --git a/pkg/integration/clients/injector/main.go b/pkg/integration/clients/injector/main.go index 37c76fe3e..0754503e8 100644 --- a/pkg/integration/clients/injector/main.go +++ b/pkg/integration/clients/injector/main.go @@ -39,11 +39,6 @@ func getIntegrationTest() integrationTypes.IntegrationTest { return nil } - if os.Getenv(components.SANDBOX_ENV_VAR) == "true" { - // when in sandbox mode we don't want the test controlling the gui - return nil - } - integrationTestName := os.Getenv(components.TEST_NAME_ENV_VAR) if integrationTestName == "" { panic(fmt.Sprintf( diff --git a/pkg/integration/components/runner.go b/pkg/integration/components/runner.go index eab6f9576..47677b3b9 100644 --- a/pkg/integration/components/runner.go +++ b/pkg/integration/components/runner.go @@ -154,7 +154,7 @@ func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandb cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", TEST_NAME_ENV_VAR, test.Name())) if sandbox { - cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", "SANDBOX", "true")) + cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", SANDBOX_ENV_VAR, "true")) } if keyPressDelay > 0 { diff --git a/pkg/integration/tests/misc/confirm_on_quit.go b/pkg/integration/tests/misc/confirm_on_quit.go new file mode 100644 index 000000000..fc5ea9c5c --- /dev/null +++ b/pkg/integration/tests/misc/confirm_on_quit.go @@ -0,0 +1,25 @@ +package misc + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Quitting with a confirm prompt", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) { + config.UserConfig.ConfirmOnQuit = true + config.UserConfig.Gui.Theme.ActiveBorderColor = []string{"red"} + }, + SetupRepo: func(shell *Shell) {}, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.PressKeys(keys.Universal.Quit) + assert.InConfirm() + assert.MatchCurrentViewContent(Contains("Are you sure you want to quit?")) + input.Confirm() + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index bad90f0cc..3feeb2d81 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -18,6 +18,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/integration/tests/custom_commands" "github.com/jesseduffield/lazygit/pkg/integration/tests/file" "github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase" + "github.com/jesseduffield/lazygit/pkg/integration/tests/misc" "github.com/jesseduffield/lazygit/pkg/integration/tests/stash" ) @@ -25,6 +26,7 @@ import ( // be sure to add it to this list. var tests = []*components.IntegrationTest{ + misc.ConfirmOnQuit, bisect.Basic, bisect.FromOtherBranch, branch.CheckoutByName, diff --git a/test/integration/confirmQuit/config/config.yml b/test/integration/confirmQuit/config/config.yml deleted file mode 100644 index 7227c0b5d..000000000 --- a/test/integration/confirmQuit/config/config.yml +++ /dev/null @@ -1,2 +0,0 @@ -disableStartupPopups: true -confirmOnQuit: true diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/confirmQuit/expected/repo/.git_keep/COMMIT_EDITMSG deleted file mode 100644 index 3829ab872..000000000 --- a/test/integration/confirmQuit/expected/repo/.git_keep/COMMIT_EDITMSG +++ /dev/null @@ -1 +0,0 @@ -myfile1 diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/FETCH_HEAD b/test/integration/confirmQuit/expected/repo/.git_keep/FETCH_HEAD deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/HEAD b/test/integration/confirmQuit/expected/repo/.git_keep/HEAD deleted file mode 100644 index cb089cd89..000000000 --- a/test/integration/confirmQuit/expected/repo/.git_keep/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/master diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/config b/test/integration/confirmQuit/expected/repo/.git_keep/config deleted file mode 100644 index 8ae104545..000000000 --- a/test/integration/confirmQuit/expected/repo/.git_keep/config +++ /dev/null @@ -1,10 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true - ignorecase = true - precomposeunicode = true -[user] - email = CI@example.com - name = CI diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/description b/test/integration/confirmQuit/expected/repo/.git_keep/description deleted file mode 100644 index 498b267a8..000000000 --- a/test/integration/confirmQuit/expected/repo/.git_keep/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/index b/test/integration/confirmQuit/expected/repo/.git_keep/index deleted file mode 100644 index e70e72626..000000000 Binary files a/test/integration/confirmQuit/expected/repo/.git_keep/index and /dev/null differ diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/info/exclude b/test/integration/confirmQuit/expected/repo/.git_keep/info/exclude deleted file mode 100644 index 8e9f2071f..000000000 --- a/test/integration/confirmQuit/expected/repo/.git_keep/info/exclude +++ /dev/null @@ -1,7 +0,0 @@ -# git ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -# *.[oa] -# *~ -.DS_Store diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/logs/HEAD b/test/integration/confirmQuit/expected/repo/.git_keep/logs/HEAD deleted file mode 100644 index d1743395b..000000000 --- a/test/integration/confirmQuit/expected/repo/.git_keep/logs/HEAD +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 544efed4e669ec3bd64b44799175bffac95035f5 CI 1642239015 +1100 commit (initial): myfile1 diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/confirmQuit/expected/repo/.git_keep/logs/refs/heads/master deleted file mode 100644 index d1743395b..000000000 --- a/test/integration/confirmQuit/expected/repo/.git_keep/logs/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 544efed4e669ec3bd64b44799175bffac95035f5 CI 1642239015 +1100 commit (initial): myfile1 diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 b/test/integration/confirmQuit/expected/repo/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 deleted file mode 100644 index 7f2ebf4ee..000000000 Binary files a/test/integration/confirmQuit/expected/repo/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 and /dev/null differ diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/objects/54/4efed4e669ec3bd64b44799175bffac95035f5 b/test/integration/confirmQuit/expected/repo/.git_keep/objects/54/4efed4e669ec3bd64b44799175bffac95035f5 deleted file mode 100644 index 0b96ac6d5..000000000 Binary files a/test/integration/confirmQuit/expected/repo/.git_keep/objects/54/4efed4e669ec3bd64b44799175bffac95035f5 and /dev/null differ diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 b/test/integration/confirmQuit/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 deleted file mode 100644 index 285df3e5f..000000000 Binary files a/test/integration/confirmQuit/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 and /dev/null differ diff --git a/test/integration/confirmQuit/expected/repo/.git_keep/refs/heads/master b/test/integration/confirmQuit/expected/repo/.git_keep/refs/heads/master deleted file mode 100644 index c8e696e5a..000000000 --- a/test/integration/confirmQuit/expected/repo/.git_keep/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -544efed4e669ec3bd64b44799175bffac95035f5 diff --git a/test/integration/confirmQuit/expected/repo/myfile1 b/test/integration/confirmQuit/expected/repo/myfile1 deleted file mode 100644 index a5bce3fd2..000000000 --- a/test/integration/confirmQuit/expected/repo/myfile1 +++ /dev/null @@ -1 +0,0 @@ -test1 diff --git a/test/integration/confirmQuit/recording.json b/test/integration/confirmQuit/recording.json deleted file mode 100644 index fea04afb7..000000000 --- a/test/integration/confirmQuit/recording.json +++ /dev/null @@ -1 +0,0 @@ -{"KeyEvents":[{"Timestamp":466,"Mod":0,"Key":256,"Ch":113},{"Timestamp":890,"Mod":0,"Key":13,"Ch":13}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/confirmQuit/setup.sh b/test/integration/confirmQuit/setup.sh deleted file mode 100644 index ee8276237..000000000 --- a/test/integration/confirmQuit/setup.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e - -cd $1 - -git init - -git config user.email "CI@example.com" -git config user.name "CI" - -echo test1 > myfile1 -git add . -git commit -am "myfile1" diff --git a/test/integration/confirmQuit/test.json b/test/integration/confirmQuit/test.json deleted file mode 100644 index 0386cab89..000000000 --- a/test/integration/confirmQuit/test.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "description": "quit with a confirm", - "speed": 20 -}