mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-13 22:17:05 +02:00
Merge pull request #2325 from jesseduffield/migrate-even-more-tests
This commit is contained in:
commit
c77df59b9b
6
.gitignore
vendored
6
.gitignore
vendored
@ -42,11 +42,7 @@ test/integration/*/used_config/
|
|||||||
test/integration/*/expected/**/hooks/
|
test/integration/*/expected/**/hooks/
|
||||||
test/integration/*/expected_remote/**/hooks/
|
test/integration/*/expected_remote/**/hooks/
|
||||||
|
|
||||||
test/integration_new/**/actual/
|
test/integration_new/**
|
||||||
test/integration_new/**/used_config/
|
|
||||||
# these sample hooks waste too much space
|
|
||||||
test/integration_new/**/expected/**/hooks/
|
|
||||||
test/integration_new/**/expected_remote/**/hooks/
|
|
||||||
|
|
||||||
oryxBuildBinary
|
oryxBuildBinary
|
||||||
__debug_bin
|
__debug_bin
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands"
|
"github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/tasks"
|
"github.com/jesseduffield/lazygit/pkg/tasks"
|
||||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||||
@ -426,7 +427,7 @@ func (gui *Gui) initGocui(headless bool, test integrationTypes.IntegrationTest)
|
|||||||
playMode = gocui.RECORDING
|
playMode = gocui.RECORDING
|
||||||
} else if Replaying() {
|
} else if Replaying() {
|
||||||
playMode = gocui.REPLAYING
|
playMode = gocui.REPLAYING
|
||||||
} else if test != nil {
|
} else if test != nil && os.Getenv(components.SANDBOX_ENV_VAR) != "true" {
|
||||||
playMode = gocui.REPLAYING_NEW
|
playMode = gocui.REPLAYING_NEW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
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
|
### 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
|
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
|
||||||
|
@ -39,11 +39,6 @@ func getIntegrationTest() integrationTypes.IntegrationTest {
|
|||||||
return nil
|
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)
|
integrationTestName := os.Getenv(components.TEST_NAME_ENV_VAR)
|
||||||
if integrationTestName == "" {
|
if integrationTestName == "" {
|
||||||
panic(fmt.Sprintf(
|
panic(fmt.Sprintf(
|
||||||
|
@ -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()))
|
cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", TEST_NAME_ENV_VAR, test.Name()))
|
||||||
if sandbox {
|
if sandbox {
|
||||||
cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", "SANDBOX", "true"))
|
cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", SANDBOX_ENV_VAR, "true"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if keyPressDelay > 0 {
|
if keyPressDelay > 0 {
|
||||||
|
25
pkg/integration/tests/misc/confirm_on_quit.go
Normal file
25
pkg/integration/tests/misc/confirm_on_quit.go
Normal file
@ -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()
|
||||||
|
},
|
||||||
|
})
|
@ -18,6 +18,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/custom_commands"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/custom_commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/file"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/file"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
|
"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"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/stash"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ import (
|
|||||||
// be sure to add it to this list.
|
// be sure to add it to this list.
|
||||||
|
|
||||||
var tests = []*components.IntegrationTest{
|
var tests = []*components.IntegrationTest{
|
||||||
|
misc.ConfirmOnQuit,
|
||||||
bisect.Basic,
|
bisect.Basic,
|
||||||
bisect.FromOtherBranch,
|
bisect.FromOtherBranch,
|
||||||
branch.CheckoutByName,
|
branch.CheckoutByName,
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
disableStartupPopups: true
|
|
||||||
confirmOnQuit: true
|
|
@ -1 +0,0 @@
|
|||||||
myfile1
|
|
@ -1 +0,0 @@
|
|||||||
ref: refs/heads/master
|
|
@ -1,10 +0,0 @@
|
|||||||
[core]
|
|
||||||
repositoryformatversion = 0
|
|
||||||
filemode = true
|
|
||||||
bare = false
|
|
||||||
logallrefupdates = true
|
|
||||||
ignorecase = true
|
|
||||||
precomposeunicode = true
|
|
||||||
[user]
|
|
||||||
email = CI@example.com
|
|
||||||
name = CI
|
|
@ -1 +0,0 @@
|
|||||||
Unnamed repository; edit this file 'description' to name the repository.
|
|
Binary file not shown.
@ -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
|
|
@ -1 +0,0 @@
|
|||||||
0000000000000000000000000000000000000000 544efed4e669ec3bd64b44799175bffac95035f5 CI <CI@example.com> 1642239015 +1100 commit (initial): myfile1
|
|
@ -1 +0,0 @@
|
|||||||
0000000000000000000000000000000000000000 544efed4e669ec3bd64b44799175bffac95035f5 CI <CI@example.com> 1642239015 +1100 commit (initial): myfile1
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
544efed4e669ec3bd64b44799175bffac95035f5
|
|
@ -1 +0,0 @@
|
|||||||
test1
|
|
@ -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}]}
|
|
@ -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"
|
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"description": "quit with a confirm",
|
|
||||||
"speed": 20
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user