diff --git a/.gitignore b/.gitignore index f5ba66f88..e9ed453a2 100644 --- a/.gitignore +++ b/.gitignore @@ -33,11 +33,19 @@ lazygit.exe !.gitmodules_keep test/git_server/data + +# we'll scrap these lines once we've fully moved over to the new integration test approach test/integration/*/actual/ test/integration/*/used_config/ # these sample hooks waste too much space 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/ + oryxBuildBinary -__debug_bin \ No newline at end of file +__debug_bin diff --git a/main.go b/main.go index e21751c27..651d2be09 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/env" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/integration" "github.com/jesseduffield/lazygit/pkg/logs" "github.com/jesseduffield/lazygit/pkg/utils" yaml "github.com/jesseduffield/yaml" @@ -150,6 +151,10 @@ func main() { log.Fatal(err.Error()) } + if test, ok := integration.CurrentIntegrationTest(); ok { + test.SetupConfig(appConfig) + } + common, err := app.NewCommon(appConfig) if err != nil { log.Fatal(err) diff --git a/pkg/gui/assert.go b/pkg/gui/assert.go new file mode 100644 index 000000000..43ecc26d8 --- /dev/null +++ b/pkg/gui/assert.go @@ -0,0 +1,88 @@ +package gui + +import ( + "fmt" + "time" + + "github.com/jesseduffield/lazygit/pkg/integration/types" +) + +type AssertImpl struct { + gui *Gui +} + +var _ types.Assert = &AssertImpl{} + +func (self *AssertImpl) WorkingTreeFileCount(expectedCount int) { + self.assertWithRetries(func() (bool, string) { + actualCount := len(self.gui.State.Model.Files) + + return actualCount == expectedCount, fmt.Sprintf( + "Expected %d changed working tree files, but got %d", + expectedCount, actualCount, + ) + }) +} + +func (self *AssertImpl) CommitCount(expectedCount int) { + self.assertWithRetries(func() (bool, string) { + actualCount := len(self.gui.State.Model.Commits) + + return actualCount == expectedCount, fmt.Sprintf( + "Expected %d commits present, but got %d", + expectedCount, actualCount, + ) + }) +} + +func (self *AssertImpl) HeadCommitMessage(expectedMessage string) { + self.assertWithRetries(func() (bool, string) { + if len(self.gui.State.Model.Commits) == 0 { + return false, "Expected at least one commit to be present" + } + + headCommit := self.gui.State.Model.Commits[0] + if headCommit.Name != expectedMessage { + return false, fmt.Sprintf( + "Expected commit message to be '%s', but got '%s'", + expectedMessage, headCommit.Name, + ) + } + + return true, "" + }) +} + +func (self *AssertImpl) CurrentViewName(expectedViewName string) { + self.assertWithRetries(func() (bool, string) { + actual := self.gui.currentViewName() + return actual == expectedViewName, fmt.Sprintf("Expected current view name to be '%s', but got '%s'", expectedViewName, actual) + }) +} + +func (self *AssertImpl) CurrentBranchName(expectedViewName string) { + self.assertWithRetries(func() (bool, string) { + actual := self.gui.helpers.Refs.GetCheckedOutRef().Name + return actual == expectedViewName, fmt.Sprintf("Expected current branch name to be '%s', but got '%s'", expectedViewName, actual) + }) +} + +func (self *AssertImpl) assertWithRetries(test func() (bool, string)) { + waitTimes := []int{0, 100, 200, 400, 800, 1600} + + var message string + for _, waitTime := range waitTimes { + time.Sleep(time.Duration(waitTime) * time.Millisecond) + + var ok bool + ok, message = test() + if ok { + return + } + } + + self.gui.g.Close() + // need to give the gui time to close + time.Sleep(time.Millisecond * 100) + panic(message) +} diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index bb5821a57..f7c8926f5 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -31,6 +31,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" "github.com/jesseduffield/lazygit/pkg/tasks" "github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/updates" @@ -418,12 +419,14 @@ var RuneReplacements = map[rune]string{ } func (gui *Gui) initGocui(headless bool) (*gocui.Gui, error) { - recordEvents := recordingEvents() + recordEvents := integration.RecordingEvents() playMode := gocui.NORMAL if recordEvents { playMode = gocui.RECORDING - } else if replaying() { + } else if integration.Replaying() { playMode = gocui.REPLAYING + } else if integration.IntegrationTestName() != "" { + playMode = gocui.REPLAYING_NEW } g, err := gocui.NewGui(gocui.OutputTrue, OverlappingEdges, playMode, headless, RuneReplacements) @@ -475,7 +478,7 @@ func (gui *Gui) viewTabMap() map[string][]context.TabView { // Run: setup the gui with keybindings and start the mainloop func (gui *Gui) Run(startArgs types.StartArgs) error { - g, err := gui.initGocui(headless()) + g, err := gui.initGocui(integration.Headless()) if err != nil { return err } @@ -490,23 +493,7 @@ func (gui *Gui) Run(startArgs types.StartArgs) error { }) deadlock.Opts.Disable = !gui.Debug - if replaying() { - gui.g.RecordingConfig = gocui.RecordingConfig{ - Speed: getRecordingSpeed(), - Leeway: 100, - } - - var err error - gui.g.Recording, err = gui.loadRecording() - if err != nil { - return err - } - - go utils.Safe(func() { - time.Sleep(time.Second * 40) - log.Fatal("40 seconds is up, lazygit recording took too long to complete") - }) - } + gui.handleTestMode() gui.g.OnSearchEscape = gui.onSearchEscape if err := gui.Config.ReloadUserConfig(); err != nil { @@ -593,7 +580,7 @@ func (gui *Gui) RunAndHandleError(startArgs types.StartArgs) error { } } - if err := gui.saveRecording(gui.g.Recording); err != nil { + if err := integration.SaveRecording(gui.g.Recording); err != nil { return err } @@ -627,7 +614,7 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess oscommands.ICmdObj) (bool, gui.Mutexes.SubprocessMutex.Lock() defer gui.Mutexes.SubprocessMutex.Unlock() - if replaying() { + if integration.Replaying() { // we do not yet support running subprocesses within integration tests. So if // we're replaying an integration test and we're inside this method, something // has gone wrong, so we should fail diff --git a/pkg/gui/gui_test.go b/pkg/gui/gui_test.go index d2345d5d0..2565392e6 100644 --- a/pkg/gui/gui_test.go +++ b/pkg/gui/gui_test.go @@ -3,6 +3,9 @@ package gui +// this is the new way of running tests. See pkg/integration/integration_tests/commit.go +// for an example + import ( "fmt" "io" @@ -14,60 +17,37 @@ import ( "github.com/creack/pty" "github.com/jesseduffield/lazygit/pkg/integration" + "github.com/jesseduffield/lazygit/pkg/integration/types" "github.com/stretchr/testify/assert" ) -// This file is quite similar to integration/main.go. The main difference is that this file is -// run via `go test` whereas the other is run via `test/lazyintegration/main.go` which provides -// a convenient gui wrapper around our integration tests. The `go test` approach is better -// for CI and for running locally in the background to ensure you haven't broken -// anything while making changes. If you want to visually see what's happening when a test is run, -// you'll need to take the other approach -// -// As for this file, to run an integration test, e.g. for test 'commit', go: -// go test pkg/gui/gui_test.go -run /commit -// -// To update a snapshot for an integration test, pass UPDATE_SNAPSHOTS=true -// UPDATE_SNAPSHOTS=true go test pkg/gui/gui_test.go -run /commit -// -// integration tests are run in test/integration//actual and the final test does -// not clean up that directory so you can cd into it to see for yourself what -// happened when a test fails. -// -// To override speed, pass e.g. `SPEED=1` as an env var. Otherwise we start each test -// at a high speed and then drop down to lower speeds upon each failure until finally -// trying at the original playback speed (speed 1). A speed of 2 represents twice the -// original playback speed. Speed may be a decimal. - func Test(t *testing.T) { if testing.Short() { t.Skip("Skipping integration tests in short mode") } mode := integration.GetModeFromEnv() - speedEnv := os.Getenv("SPEED") includeSkipped := os.Getenv("INCLUDE_SKIPPED") != "" parallelTotal := tryConvert(os.Getenv("PARALLEL_TOTAL"), 1) parallelIndex := tryConvert(os.Getenv("PARALLEL_INDEX"), 0) testNumber := 0 - err := integration.RunTests( + err := integration.RunTestsNew( t.Logf, runCmdHeadless, - func(test *integration.Test, f func(*testing.T) error) { + func(test types.Test, f func(*testing.T) error) { defer func() { testNumber += 1 }() if testNumber%parallelTotal != parallelIndex { return } - t.Run(test.Name, func(t *testing.T) { + t.Run(test.Name(), func(t *testing.T) { err := f(t) assert.NoError(t, err) }) }, mode, - speedEnv, func(t *testing.T, expected string, actual string, prefix string) { t.Helper() assert.Equal(t, expected, actual, fmt.Sprintf("Unexpected %s. Expected:\n%s\nActual:\n%s\n", prefix, expected, actual)) diff --git a/pkg/gui/input.go b/pkg/gui/input.go new file mode 100644 index 000000000..c6424c077 --- /dev/null +++ b/pkg/gui/input.go @@ -0,0 +1,93 @@ +package gui + +import ( + "time" + + "github.com/gdamore/tcell/v2" + "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/gui/keybindings" + "github.com/jesseduffield/lazygit/pkg/integration/types" +) + +type InputImpl struct { + g *gocui.Gui + keys config.KeybindingConfig +} + +var _ types.Input = &InputImpl{} + +func (self *InputImpl) PushKeys(keyStrs ...string) { + for _, keyStr := range keyStrs { + self.pushKey(keyStr) + } +} + +func (self *InputImpl) pushKey(keyStr string) { + key := keybindings.GetKey(keyStr) + + var r rune + var tcellKey tcell.Key + switch v := key.(type) { + case rune: + r = v + tcellKey = tcell.KeyRune + case gocui.Key: + tcellKey = tcell.Key(v) + } + + self.g.ReplayedEvents.Keys <- gocui.NewTcellKeyEventWrapper( + tcell.NewEventKey(tcellKey, r, tcell.ModNone), + 0, + ) +} + +func (self *InputImpl) SwitchToStatusWindow() { + self.pushKey(self.keys.Universal.JumpToBlock[0]) +} + +func (self *InputImpl) SwitchToFilesWindow() { + self.pushKey(self.keys.Universal.JumpToBlock[1]) +} + +func (self *InputImpl) SwitchToBranchesWindow() { + self.pushKey(self.keys.Universal.JumpToBlock[2]) +} + +func (self *InputImpl) SwitchToCommitsWindow() { + self.pushKey(self.keys.Universal.JumpToBlock[3]) +} + +func (self *InputImpl) SwitchToStashWindow() { + self.pushKey(self.keys.Universal.JumpToBlock[4]) +} + +func (self *InputImpl) Type(content string) { + for _, char := range content { + self.pushKey(string(char)) + } +} + +func (self *InputImpl) Confirm() { + self.pushKey(self.keys.Universal.Confirm) +} + +func (self *InputImpl) Cancel() { + self.pushKey(self.keys.Universal.Return) +} + +func (self *InputImpl) Select() { + self.pushKey(self.keys.Universal.Select) +} + +func (self *InputImpl) NextItem() { + self.pushKey(self.keys.Universal.NextItem) +} + +func (self *InputImpl) PreviousItem() { + self.pushKey(self.keys.Universal.PrevItem) +} + +func (self *InputImpl) Wait(milliseconds int) { + time.Sleep(time.Duration(milliseconds) * time.Millisecond) +} diff --git a/pkg/gui/old_gui_test.go b/pkg/gui/old_gui_test.go new file mode 100644 index 000000000..12e33432d --- /dev/null +++ b/pkg/gui/old_gui_test.go @@ -0,0 +1,76 @@ +//go:build !windows +// +build !windows + +package gui + +import ( + "fmt" + "os" + "testing" + + "github.com/jesseduffield/lazygit/pkg/integration" + "github.com/stretchr/testify/assert" +) + +// Deprecated: this is the old way of running tests. See pkg/gui/gui_test.go for the new way. + +// This file is quite similar to integration/main.go. The main difference is that this file is +// run via `go test` whereas the other is run via `test/lazyintegration/main.go` which provides +// a convenient gui wrapper around our integration tests. The `go test` approach is better +// for CI and for running locally in the background to ensure you haven't broken +// anything while making changes. If you want to visually see what's happening when a test is run, +// you'll need to take the other approach +// +// As for this file, to run an integration test, e.g. for test 'commit', go: +// go test pkg/gui/old_gui_test.go -run /commit +// +// To update a snapshot for an integration test, pass UPDATE_SNAPSHOTS=true +// UPDATE_SNAPSHOTS=true go test pkg/gui/old_gui_test.go -run /commit +// +// integration tests are run in test/integration//actual and the final test does +// not clean up that directory so you can cd into it to see for yourself what +// happened when a test fails. +// +// To override speed, pass e.g. `SPEED=1` as an env var. Otherwise we start each test +// at a high speed and then drop down to lower speeds upon each failure until finally +// trying at the original playback speed (speed 1). A speed of 2 represents twice the +// original playback speed. Speed may be a decimal. + +func TestOld(t *testing.T) { + if testing.Short() { + t.Skip("Skipping integration tests in short mode") + } + + mode := integration.GetModeFromEnv() + speedEnv := os.Getenv("SPEED") + includeSkipped := os.Getenv("INCLUDE_SKIPPED") != "" + + parallelTotal := tryConvert(os.Getenv("PARALLEL_TOTAL"), 1) + parallelIndex := tryConvert(os.Getenv("PARALLEL_INDEX"), 0) + testNumber := 0 + + err := integration.RunTests( + t.Logf, + runCmdHeadless, + func(test *integration.Test, f func(*testing.T) error) { + defer func() { testNumber += 1 }() + if testNumber%parallelTotal != parallelIndex { + return + } + + t.Run(test.Name, func(t *testing.T) { + err := f(t) + assert.NoError(t, err) + }) + }, + mode, + speedEnv, + func(t *testing.T, expected string, actual string, prefix string) { + t.Helper() + assert.Equal(t, expected, actual, fmt.Sprintf("Unexpected %s. Expected:\n%s\nActual:\n%s\n", prefix, expected, actual)) + }, + includeSkipped, + ) + + assert.NoError(t, err) +} diff --git a/pkg/gui/test_mode.go b/pkg/gui/test_mode.go new file mode 100644 index 000000000..88e42e440 --- /dev/null +++ b/pkg/gui/test_mode.go @@ -0,0 +1,63 @@ +package gui + +import ( + "fmt" + "log" + "time" + + "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/integration" + "github.com/jesseduffield/lazygit/pkg/utils" +) + +func (gui *Gui) handleTestMode() { + if integration.PlayingIntegrationTest() { + test, ok := integration.CurrentIntegrationTest() + + if !ok { + panic(fmt.Sprintf("test %s not found", integration.IntegrationTestName())) + } + + go func() { + time.Sleep(time.Millisecond * 100) + + test.Run( + &integration.ShellImpl{}, + &InputImpl{g: gui.g, keys: gui.Config.GetUserConfig().Keybinding}, + &AssertImpl{gui: gui}, + gui.c.UserConfig.Keybinding, + ) + + gui.g.Update(func(*gocui.Gui) error { + return gocui.ErrQuit + }) + + time.Sleep(time.Second * 1) + + log.Fatal("gocui should have already exited") + }() + + go utils.Safe(func() { + time.Sleep(time.Second * 40) + log.Fatal("40 seconds is up, lazygit recording took too long to complete") + }) + } + + if integration.Replaying() { + gui.g.RecordingConfig = gocui.RecordingConfig{ + Speed: integration.GetRecordingSpeed(), + Leeway: 100, + } + + var err error + gui.g.Recording, err = integration.LoadRecording() + if err != nil { + panic(err) + } + + go utils.Safe(func() { + time.Sleep(time.Second * 40) + log.Fatal("40 seconds is up, lazygit recording took too long to complete") + }) + } +} diff --git a/pkg/integration/env.go b/pkg/integration/env.go new file mode 100644 index 000000000..7cdc72267 --- /dev/null +++ b/pkg/integration/env.go @@ -0,0 +1,46 @@ +package integration + +import ( + "os" + + "github.com/jesseduffield/generics/slices" + "github.com/jesseduffield/lazygit/pkg/integration/types" +) + +func Headless() bool { + return os.Getenv("HEADLESS") != "" +} + +// NEW integration test format stuff + +func IntegrationTestName() string { + return os.Getenv("LAZYGIT_TEST_NAME") +} + +func CurrentIntegrationTest() (types.Test, bool) { + if !PlayingIntegrationTest() { + return nil, false + } + + return slices.Find(Tests, func(test types.Test) bool { + return test.Name() == IntegrationTestName() + }) +} + +func PlayingIntegrationTest() bool { + return IntegrationTestName() != "" +} + +// OLD integration test format stuff + +func Replaying() bool { + return os.Getenv("REPLAY_EVENTS_FROM") != "" +} + +func RecordingEvents() bool { + return recordEventsTo() != "" +} + +func recordEventsTo() string { + return os.Getenv("RECORD_EVENTS_TO") +} diff --git a/pkg/integration/integration.go b/pkg/integration/integration.go index 4172f3e49..853dae0d9 100644 --- a/pkg/integration/integration.go +++ b/pkg/integration/integration.go @@ -1,72 +1,29 @@ package integration import ( - "encoding/json" "errors" "fmt" "io/ioutil" - "log" "os" "os/exec" "path/filepath" - "strconv" - "strings" "testing" - "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" - "github.com/jesseduffield/lazygit/pkg/secureexec" + "github.com/jesseduffield/lazygit/pkg/integration/integration_tests" + "github.com/jesseduffield/lazygit/pkg/integration/types" ) -// This package is for running our integration test suite. See docs/Integration_Tests.md for more info +// this is the integration runner for the new and improved integration interface -type Test struct { - Name string `json:"name"` - Speed float64 `json:"speed"` - Description string `json:"description"` - ExtraCmdArgs string `json:"extraCmdArgs"` - Skip bool `json:"skip"` -} +// re-exporting this so that clients only need to import one package +var Tests = integration_tests.Tests -type Mode int - -const ( - // default: for when we're just running a test and comparing to the snapshot - TEST = iota - // for when we want to record a test and set the snapshot based on the result - RECORD - // when we just want to use the setup of the test for our own sandboxing purposes. - // This does not record the session and does not create/update snapshots - SANDBOX - // running a test but updating the snapshot - UPDATE_SNAPSHOT -) - -func GetModeFromEnv() Mode { - switch os.Getenv("MODE") { - case "record": - return RECORD - case "", "test": - return TEST - case "updateSnapshot": - return UPDATE_SNAPSHOT - case "sandbox": - return SANDBOX - default: - log.Fatalf("unknown test mode: %s, must be one of [test, record, update, sandbox]", os.Getenv("MODE")) - panic("unreachable") - } -} - -// this function is used by both `go test` and from our lazyintegration gui, but -// errors need to be handled differently in each (for example go test is always -// working with *testing.T) so we pass in any differences as args here. -func RunTests( +func RunTestsNew( logf func(format string, formatArgs ...interface{}), runCmd func(cmd *exec.Cmd) error, - fnWrapper func(test *Test, f func(*testing.T) error), + fnWrapper func(test types.Test, f func(*testing.T) error), mode Mode, - speedEnv string, onFail func(t *testing.T, expected string, actual string, prefix string), includeSkipped bool, ) error { @@ -76,7 +33,7 @@ func RunTests( return err } - testDir := filepath.Join(rootDir, "test", "integration") + testDir := filepath.Join(rootDir, "test", "integration_new") osCommand := oscommands.NewDummyOSCommand() err = osCommand.Cmd.New("go build -o " + tempLazygitPath()).Run() @@ -84,115 +41,94 @@ func RunTests( return err } - tests, err := LoadTests(testDir) - if err != nil { - return err - } - - for _, test := range tests { + for _, test := range Tests { test := test fnWrapper(test, func(t *testing.T) error { //nolint: thelper - if test.Skip && !includeSkipped { - logf("skipping test: %s", test.Name) + if test.Skip() && !includeSkipped { + logf("skipping test: %s", test.Name()) return nil } - speeds := getTestSpeeds(test.Speed, mode, speedEnv) - testPath := filepath.Join(testDir, test.Name) + testPath := filepath.Join(testDir, test.Name()) + actualDir := filepath.Join(testPath, "actual") expectedDir := filepath.Join(testPath, "expected") actualRepoDir := filepath.Join(actualDir, "repo") logf("path: %s", testPath) - for i, speed := range speeds { - if mode != SANDBOX && mode != RECORD { - logf("%s: attempting test at speed %f\n", test.Name, speed) - } + findOrCreateDir(testPath) + prepareIntegrationTestDir(actualDir) + findOrCreateDir(actualRepoDir) + err := createFixtureNew(test, actualRepoDir, rootDir) + if err != nil { + return err + } - findOrCreateDir(testPath) - prepareIntegrationTestDir(actualDir) - findOrCreateDir(actualRepoDir) - err := createFixture(testPath, actualRepoDir) + configDir := filepath.Join(testPath, "used_config") + + cmd, err := getLazygitCommandNew(test, testPath, rootDir) + if err != nil { + return err + } + + err = runCmd(cmd) + if err != nil { + return err + } + + if mode == UPDATE_SNAPSHOT { + // create/update snapshot + err = oscommands.CopyDir(actualDir, expectedDir) if err != nil { return err } - configDir := filepath.Join(testPath, "used_config") + if err := renameSpecialPaths(expectedDir); err != nil { + return err + } - cmd, err := getLazygitCommand(testPath, rootDir, mode, speed, test.ExtraCmdArgs) + logf("%s", "updated snapshot") + } else { + if err := validateSameRepos(expectedDir, actualDir); err != nil { + return err + } + + // iterate through each repo in the expected dir and comparet to the corresponding repo in the actual dir + expectedFiles, err := ioutil.ReadDir(expectedDir) if err != nil { return err } - err = runCmd(cmd) - if err != nil { - return err - } + for _, f := range expectedFiles { + if !f.IsDir() { + return errors.New("unexpected file (as opposed to directory) in integration test 'expected' directory") + } - if mode == UPDATE_SNAPSHOT || mode == RECORD { - // create/update snapshot - err = oscommands.CopyDir(actualDir, expectedDir) + // get corresponding file name from actual dir + actualRepoPath := filepath.Join(actualDir, f.Name()) + expectedRepoPath := filepath.Join(expectedDir, f.Name()) + + actualRepo, expectedRepo, err := generateSnapshots(actualRepoPath, expectedRepoPath) if err != nil { return err } - if err := renameSpecialPaths(expectedDir); err != nil { - return err - } - - logf("%s", "updated snapshot") - } else { - if err := validateSameRepos(expectedDir, actualDir); err != nil { - return err - } - - // iterate through each repo in the expected dir and comparet to the corresponding repo in the actual dir - expectedFiles, err := ioutil.ReadDir(expectedDir) - if err != nil { - return err - } - - success := true - for _, f := range expectedFiles { - if !f.IsDir() { - return errors.New("unexpected file (as opposed to directory) in integration test 'expected' directory") - } - - // get corresponding file name from actual dir - actualRepoPath := filepath.Join(actualDir, f.Name()) - expectedRepoPath := filepath.Join(expectedDir, f.Name()) - - actualRepo, expectedRepo, err := generateSnapshots(actualRepoPath, expectedRepoPath) + if expectedRepo != actualRepo { + // get the log file and print it + bytes, err := ioutil.ReadFile(filepath.Join(configDir, "development.log")) if err != nil { return err } + logf("%s", string(bytes)) - if expectedRepo != actualRepo { - success = false - // if the snapshot doesn't match and we haven't tried all playback speeds different we'll retry at a slower speed - if i < len(speeds)-1 { - break - } - - // get the log file and print it - bytes, err := ioutil.ReadFile(filepath.Join(configDir, "development.log")) - if err != nil { - return err - } - logf("%s", string(bytes)) - - onFail(t, expectedRepo, actualRepo, f.Name()) - } - } - - if success { - logf("%s: success at speed %f\n", test.Name, speed) - break + onFail(t, expectedRepo, actualRepo, f.Name()) } } } + logf("test passed: %s", test.Name()) + return nil }) } @@ -200,344 +136,35 @@ func RunTests( return nil } -// validates that the actual and expected dirs have the same repo names (doesn't actually check the contents of the repos) -func validateSameRepos(expectedDir string, actualDir string) error { - // iterate through each repo in the expected dir and compare to the corresponding repo in the actual dir - expectedFiles, err := ioutil.ReadDir(expectedDir) - if err != nil { - return err - } - - var actualFiles []os.FileInfo - actualFiles, err = ioutil.ReadDir(actualDir) - if err != nil { - return err - } - - expectedFileNames := slices.Map(expectedFiles, getFileName) - actualFileNames := slices.Map(actualFiles, getFileName) - if !slices.Equal(expectedFileNames, actualFileNames) { - return fmt.Errorf("expected and actual repo dirs do not match: expected: %s, actual: %s", expectedFileNames, actualFileNames) - } - - return nil -} - -func getFileName(f os.FileInfo) string { - return f.Name() -} - -func prepareIntegrationTestDir(actualDir string) { - // remove contents of integration test directory - dir, err := ioutil.ReadDir(actualDir) - if err != nil { - if os.IsNotExist(err) { - err = os.Mkdir(actualDir, 0o777) - if err != nil { - panic(err) - } - } else { - panic(err) - } - } - for _, d := range dir { - os.RemoveAll(filepath.Join(actualDir, d.Name())) - } -} - -func GetRootDirectory() string { - path, err := os.Getwd() - if err != nil { +func createFixtureNew(test types.Test, actualDir string, rootDir string) error { + if err := os.Chdir(actualDir); err != nil { panic(err) } - for { - _, err := os.Stat(filepath.Join(path, ".git")) + shell := &ShellImpl{} + shell.RunCommand("git init") + shell.RunCommand(`git config user.email "CI@example.com"`) + shell.RunCommand(`git config user.name "CI"`) - if err == nil { - return path - } + test.SetupRepo(shell) - if !os.IsNotExist(err) { - panic(err) - } - - path = filepath.Dir(path) - - if path == "/" { - log.Fatal("must run in lazygit folder or child folder") - } - } -} - -func createFixture(testPath, actualDir string) error { - bashScriptPath := filepath.Join(testPath, "setup.sh") - cmd := secureexec.Command("bash", bashScriptPath, actualDir) - - if output, err := cmd.CombinedOutput(); err != nil { - return errors.New(string(output)) - } - - return nil -} - -func tempLazygitPath() string { - return filepath.Join("/tmp", "lazygit", "test_lazygit") -} - -func getTestSpeeds(testStartSpeed float64, mode Mode, speedStr string) []float64 { - if mode != TEST { - // have to go at original speed if updating snapshots in case we go to fast and create a junk snapshot - return []float64{1.0} - } - - if speedStr != "" { - speed, err := strconv.ParseFloat(speedStr, 64) - if err != nil { - panic(err) - } - return []float64{speed} - } - - // default is 10, 5, 1 - startSpeed := 10.0 - if testStartSpeed != 0 { - startSpeed = testStartSpeed - } - speeds := []float64{startSpeed} - if startSpeed > 5 { - speeds = append(speeds, 5) - } - speeds = append(speeds, 1, 1) - - return speeds -} - -func LoadTests(testDir string) ([]*Test, error) { - paths, err := filepath.Glob(filepath.Join(testDir, "/*/test.json")) - if err != nil { - return nil, err - } - - tests := make([]*Test, len(paths)) - - for i, path := range paths { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - test := &Test{} - - err = json.Unmarshal(data, test) - if err != nil { - return nil, err - } - - test.Name = strings.TrimPrefix(filepath.Dir(path), testDir+"/") - - tests[i] = test - } - - return tests, nil -} - -func findOrCreateDir(path string) { - _, err := os.Stat(path) - if err != nil { - if os.IsNotExist(err) { - err = os.MkdirAll(path, 0o777) - if err != nil { - panic(err) - } - } else { - panic(err) - } - } -} - -// note that we don't actually store this snapshot in the lazygit repo. -// Instead we store the whole expected git repo of our test, so that -// we can easily change what we want to compare without needing to regenerate -// snapshots for each test. -func generateSnapshot(dir string) (string, error) { - osCommand := oscommands.NewDummyOSCommand() - - _, err := os.Stat(filepath.Join(dir, ".git")) - if err != nil { - return "git directory not found", nil - } - - snapshot := "" - - cmdStrs := []string{ - `remote show -n origin`, // remote branches - // TODO: find a way to bring this back without breaking tests - // `ls-remote origin`, - `status`, // file tree - `log --pretty=%B|%an|%ae -p -1`, // log - `tag -n`, // tags - `stash list`, // stash - `submodule foreach 'git status'`, // submodule status - `submodule foreach 'git log --pretty=%B -p -1'`, // submodule log - `submodule foreach 'git tag -n'`, // submodule tags - `submodule foreach 'git stash list'`, // submodule stash - } - - for _, cmdStr := range cmdStrs { - // ignoring error for now. If there's an error it could be that there are no results - output, _ := osCommand.Cmd.New(fmt.Sprintf("git -C %s %s", dir, cmdStr)).RunWithOutput() - - snapshot += fmt.Sprintf("git %s:\n%s\n", cmdStr, output) - } - - snapshot += "files in repo:\n" - err = filepath.Walk(dir, func(path string, f os.FileInfo, err error) error { - if err != nil { - return err - } - - if f.IsDir() { - if f.Name() == ".git" { - return filepath.SkipDir - } - return nil - } - - bytes, err := ioutil.ReadFile(path) - if err != nil { - return err - } - - relativePath, err := filepath.Rel(dir, path) - if err != nil { - return err - } - snapshot += fmt.Sprintf("path: %s\ncontent:\n%s\n", relativePath, string(bytes)) - - return nil - }) - - if err != nil { - return "", err - } - - return snapshot, nil -} - -func generateSnapshots(actualDir string, expectedDir string) (string, string, error) { - actual, err := generateSnapshot(actualDir) - if err != nil { - return "", "", err - } - - // there are a couple of reasons we're not generating the snapshot in expectedDir directly: - // Firstly we don't want to have to revert our .git file back to .git_keep. - // Secondly, the act of calling git commands like 'git status' actually changes the index - // for some reason, and we don't want to leave your lazygit working tree dirty as a result. - expectedDirCopyDir := filepath.Join(filepath.Dir(expectedDir), "expected_dir_test") - err = oscommands.CopyDir(expectedDir, expectedDirCopyDir) - if err != nil { - return "", "", err - } - - defer func() { - err := os.RemoveAll(expectedDirCopyDir) - if err != nil { - panic(err) - } - }() - - if err := restoreSpecialPaths(expectedDirCopyDir); err != nil { - return "", "", err - } - - expected, err := generateSnapshot(expectedDirCopyDir) - if err != nil { - return "", "", err - } - - return actual, expected, nil -} - -func getPathsToRename(dir string, needle string, contains string) []string { - pathsToRename := []string{} - - err := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error { - if err != nil { - return err - } - - if f.Name() == needle && (contains == "" || strings.Contains(path, contains)) { - pathsToRename = append(pathsToRename, path) - } - - return nil - }) - if err != nil { + // changing directory back to rootDir after the setup is done + if err := os.Chdir(rootDir); err != nil { panic(err) } - return pathsToRename -} - -var specialPathMappings = []struct{ original, new, contains string }{ - // git refuses to track .git or .gitmodules in subdirectories so we need to rename them - {".git", ".git_keep", ""}, - {".gitmodules", ".gitmodules_keep", ""}, - // we also need git to ignore the contents of our test gitignore files so that - // we actually commit files that are ignored within the test. - {".gitignore", "lg_ignore_file", ""}, - // this is the .git/info/exclude file. We're being a little more specific here - // so that we don't accidentally mess with some other file named 'exclude' in the test. - {"exclude", "lg_exclude_file", ".git/info/exclude"}, -} - -func renameSpecialPaths(dir string) error { - for _, specialPath := range specialPathMappings { - for _, path := range getPathsToRename(dir, specialPath.original, specialPath.contains) { - err := os.Rename(path, filepath.Join(filepath.Dir(path), specialPath.new)) - if err != nil { - return err - } - } - } - return nil } -func restoreSpecialPaths(dir string) error { - for _, specialPath := range specialPathMappings { - for _, path := range getPathsToRename(dir, specialPath.new, specialPath.contains) { - err := os.Rename(path, filepath.Join(filepath.Dir(path), specialPath.original)) - if err != nil { - return err - } - } - } - - return nil -} - -func getLazygitCommand(testPath string, rootDir string, mode Mode, speed float64, extraCmdArgs string) (*exec.Cmd, error) { +func getLazygitCommandNew(test types.Test, testPath string, rootDir string) (*exec.Cmd, error) { osCommand := oscommands.NewDummyOSCommand() - replayPath := filepath.Join(testPath, "recording.json") templateConfigDir := filepath.Join(rootDir, "test", "default_test_config") actualRepoDir := filepath.Join(testPath, "actual", "repo") - exists, err := osCommand.FileExists(filepath.Join(testPath, "config")) - if err != nil { - return nil, err - } - - if exists { - templateConfigDir = filepath.Join(testPath, "config") - } - configDir := filepath.Join(testPath, "used_config") - err = os.RemoveAll(configDir) + err := os.RemoveAll(configDir) if err != nil { return nil, err } @@ -546,17 +173,11 @@ func getLazygitCommand(testPath string, rootDir string, mode Mode, speed float64 return nil, err } - cmdStr := fmt.Sprintf("%s -debug --use-config-dir=%s --path=%s %s", tempLazygitPath(), configDir, actualRepoDir, extraCmdArgs) + cmdStr := fmt.Sprintf("%s -debug --use-config-dir=%s --path=%s %s", tempLazygitPath(), configDir, actualRepoDir, test.ExtraCmdArgs()) cmdObj := osCommand.Cmd.New(cmdStr) - cmdObj.AddEnvVars(fmt.Sprintf("SPEED=%f", speed)) - switch mode { - case RECORD: - cmdObj.AddEnvVars(fmt.Sprintf("RECORD_EVENTS_TO=%s", replayPath)) - case TEST, UPDATE_SNAPSHOT: - cmdObj.AddEnvVars(fmt.Sprintf("REPLAY_EVENTS_FROM=%s", replayPath)) - } + cmdObj.AddEnvVars(fmt.Sprintf("LAZYGIT_TEST_NAME=%s", test.Name())) return cmdObj.GetCmd(), nil } diff --git a/pkg/integration/integration_old.go b/pkg/integration/integration_old.go new file mode 100644 index 000000000..579892e3b --- /dev/null +++ b/pkg/integration/integration_old.go @@ -0,0 +1,564 @@ +package integration + +import ( + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" + "strconv" + "strings" + "testing" + + "github.com/jesseduffield/generics/slices" + "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/secureexec" +) + +// This package is for running our integration test suite. See docs/Integration_Tests.md for more info. + +// Deprecated: This file is part of the old way of doing things. See integration.go for the new way + +type Test struct { + Name string `json:"name"` + Speed float64 `json:"speed"` + Description string `json:"description"` + ExtraCmdArgs string `json:"extraCmdArgs"` + Skip bool `json:"skip"` +} + +type Mode int + +const ( + // default: for when we're just running a test and comparing to the snapshot + TEST = iota + // for when we want to record a test and set the snapshot based on the result + RECORD + // when we just want to use the setup of the test for our own sandboxing purposes. + // This does not record the session and does not create/update snapshots + SANDBOX + // running a test but updating the snapshot + UPDATE_SNAPSHOT +) + +func GetModeFromEnv() Mode { + switch os.Getenv("MODE") { + case "record": + return RECORD + case "", "test": + return TEST + case "updateSnapshot": + return UPDATE_SNAPSHOT + case "sandbox": + return SANDBOX + default: + log.Fatalf("unknown test mode: %s, must be one of [test, record, updateSnapshot, sandbox]", os.Getenv("MODE")) + panic("unreachable") + } +} + +// this function is used by both `go test` and from our lazyintegration gui, but +// errors need to be handled differently in each (for example go test is always +// working with *testing.T) so we pass in any differences as args here. +func RunTests( + logf func(format string, formatArgs ...interface{}), + runCmd func(cmd *exec.Cmd) error, + fnWrapper func(test *Test, f func(*testing.T) error), + mode Mode, + speedEnv string, + onFail func(t *testing.T, expected string, actual string, prefix string), + includeSkipped bool, +) error { + rootDir := GetRootDirectory() + err := os.Chdir(rootDir) + if err != nil { + return err + } + + testDir := filepath.Join(rootDir, "test", "integration") + + osCommand := oscommands.NewDummyOSCommand() + err = osCommand.Cmd.New("go build -o " + tempLazygitPath()).Run() + if err != nil { + return err + } + + tests, err := LoadTests(testDir) + if err != nil { + return err + } + + for _, test := range tests { + test := test + + fnWrapper(test, func(t *testing.T) error { //nolint: thelper + if test.Skip && !includeSkipped { + logf("skipping test: %s", test.Name) + return nil + } + + speeds := getTestSpeeds(test.Speed, mode, speedEnv) + testPath := filepath.Join(testDir, test.Name) + actualDir := filepath.Join(testPath, "actual") + expectedDir := filepath.Join(testPath, "expected") + actualRepoDir := filepath.Join(actualDir, "repo") + logf("path: %s", testPath) + + for i, speed := range speeds { + if mode != SANDBOX && mode != RECORD { + logf("%s: attempting test at speed %f\n", test.Name, speed) + } + + findOrCreateDir(testPath) + prepareIntegrationTestDir(actualDir) + findOrCreateDir(actualRepoDir) + err := createFixture(testPath, actualRepoDir) + if err != nil { + return err + } + + configDir := filepath.Join(testPath, "used_config") + + cmd, err := getLazygitCommand(testPath, rootDir, mode, speed, test.ExtraCmdArgs) + if err != nil { + return err + } + + err = runCmd(cmd) + if err != nil { + return err + } + + if mode == UPDATE_SNAPSHOT || mode == RECORD { + // create/update snapshot + err = oscommands.CopyDir(actualDir, expectedDir) + if err != nil { + return err + } + + if err := renameSpecialPaths(expectedDir); err != nil { + return err + } + + logf("%s", "updated snapshot") + } else { + if err := validateSameRepos(expectedDir, actualDir); err != nil { + return err + } + + // iterate through each repo in the expected dir and comparet to the corresponding repo in the actual dir + expectedFiles, err := ioutil.ReadDir(expectedDir) + if err != nil { + return err + } + + success := true + for _, f := range expectedFiles { + if !f.IsDir() { + return errors.New("unexpected file (as opposed to directory) in integration test 'expected' directory") + } + + // get corresponding file name from actual dir + actualRepoPath := filepath.Join(actualDir, f.Name()) + expectedRepoPath := filepath.Join(expectedDir, f.Name()) + + actualRepo, expectedRepo, err := generateSnapshots(actualRepoPath, expectedRepoPath) + if err != nil { + return err + } + + if expectedRepo != actualRepo { + success = false + // if the snapshot doesn't match and we haven't tried all playback speeds different we'll retry at a slower speed + if i < len(speeds)-1 { + break + } + + // get the log file and print it + bytes, err := ioutil.ReadFile(filepath.Join(configDir, "development.log")) + if err != nil { + return err + } + logf("%s", string(bytes)) + + onFail(t, expectedRepo, actualRepo, f.Name()) + } + } + + if success { + logf("%s: success at speed %f\n", test.Name, speed) + break + } + } + } + + return nil + }) + } + + return nil +} + +// validates that the actual and expected dirs have the same repo names (doesn't actually check the contents of the repos) +func validateSameRepos(expectedDir string, actualDir string) error { + // iterate through each repo in the expected dir and compare to the corresponding repo in the actual dir + expectedFiles, err := ioutil.ReadDir(expectedDir) + if err != nil { + return err + } + + var actualFiles []os.FileInfo + actualFiles, err = ioutil.ReadDir(actualDir) + if err != nil { + return err + } + + expectedFileNames := slices.Map(expectedFiles, getFileName) + actualFileNames := slices.Map(actualFiles, getFileName) + if !slices.Equal(expectedFileNames, actualFileNames) { + return fmt.Errorf("expected and actual repo dirs do not match: expected: %s, actual: %s", expectedFileNames, actualFileNames) + } + + return nil +} + +func getFileName(f os.FileInfo) string { + return f.Name() +} + +func prepareIntegrationTestDir(actualDir string) { + // remove contents of integration test directory + dir, err := ioutil.ReadDir(actualDir) + if err != nil { + if os.IsNotExist(err) { + err = os.Mkdir(actualDir, 0o777) + if err != nil { + panic(err) + } + } else { + panic(err) + } + } + for _, d := range dir { + os.RemoveAll(filepath.Join(actualDir, d.Name())) + } +} + +func GetRootDirectory() string { + path, err := os.Getwd() + if err != nil { + panic(err) + } + + for { + _, err := os.Stat(filepath.Join(path, ".git")) + + if err == nil { + return path + } + + if !os.IsNotExist(err) { + panic(err) + } + + path = filepath.Dir(path) + + if path == "/" { + log.Fatal("must run in lazygit folder or child folder") + } + } +} + +func createFixture(testPath, actualDir string) error { + bashScriptPath := filepath.Join(testPath, "setup.sh") + cmd := secureexec.Command("bash", bashScriptPath, actualDir) + + if output, err := cmd.CombinedOutput(); err != nil { + return errors.New(string(output)) + } + + return nil +} + +func tempLazygitPath() string { + return filepath.Join("/tmp", "lazygit", "test_lazygit") +} + +func getTestSpeeds(testStartSpeed float64, mode Mode, speedStr string) []float64 { + if mode != TEST { + // have to go at original speed if updating snapshots in case we go to fast and create a junk snapshot + return []float64{1.0} + } + + if speedStr != "" { + speed, err := strconv.ParseFloat(speedStr, 64) + if err != nil { + panic(err) + } + return []float64{speed} + } + + // default is 10, 5, 1 + startSpeed := 10.0 + if testStartSpeed != 0 { + startSpeed = testStartSpeed + } + speeds := []float64{startSpeed} + if startSpeed > 5 { + speeds = append(speeds, 5) + } + speeds = append(speeds, 1, 1) + + return speeds +} + +func LoadTests(testDir string) ([]*Test, error) { + paths, err := filepath.Glob(filepath.Join(testDir, "/*/test.json")) + if err != nil { + return nil, err + } + + tests := make([]*Test, len(paths)) + + for i, path := range paths { + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + + test := &Test{} + + err = json.Unmarshal(data, test) + if err != nil { + return nil, err + } + + test.Name = strings.TrimPrefix(filepath.Dir(path), testDir+"/") + + tests[i] = test + } + + return tests, nil +} + +func findOrCreateDir(path string) { + _, err := os.Stat(path) + if err != nil { + if os.IsNotExist(err) { + err = os.MkdirAll(path, 0o777) + if err != nil { + panic(err) + } + } else { + panic(err) + } + } +} + +// note that we don't actually store this snapshot in the lazygit repo. +// Instead we store the whole expected git repo of our test, so that +// we can easily change what we want to compare without needing to regenerate +// snapshots for each test. +func generateSnapshot(dir string) (string, error) { + osCommand := oscommands.NewDummyOSCommand() + + _, err := os.Stat(filepath.Join(dir, ".git")) + if err != nil { + return "git directory not found", nil + } + + snapshot := "" + + cmdStrs := []string{ + `remote show -n origin`, // remote branches + // TODO: find a way to bring this back without breaking tests + // `ls-remote origin`, + `status`, // file tree + `log --pretty=%B|%an|%ae -p -1`, // log + `tag -n`, // tags + `stash list`, // stash + `submodule foreach 'git status'`, // submodule status + `submodule foreach 'git log --pretty=%B -p -1'`, // submodule log + `submodule foreach 'git tag -n'`, // submodule tags + `submodule foreach 'git stash list'`, // submodule stash + } + + for _, cmdStr := range cmdStrs { + // ignoring error for now. If there's an error it could be that there are no results + output, _ := osCommand.Cmd.New(fmt.Sprintf("git -C %s %s", dir, cmdStr)).RunWithOutput() + + snapshot += fmt.Sprintf("git %s:\n%s\n", cmdStr, output) + } + + snapshot += "files in repo:\n" + err = filepath.Walk(dir, func(path string, f os.FileInfo, err error) error { + if err != nil { + return err + } + + if f.IsDir() { + if f.Name() == ".git" { + return filepath.SkipDir + } + return nil + } + + bytes, err := ioutil.ReadFile(path) + if err != nil { + return err + } + + relativePath, err := filepath.Rel(dir, path) + if err != nil { + return err + } + snapshot += fmt.Sprintf("path: %s\ncontent:\n%s\n", relativePath, string(bytes)) + + return nil + }) + + if err != nil { + return "", err + } + + return snapshot, nil +} + +func generateSnapshots(actualDir string, expectedDir string) (string, string, error) { + actual, err := generateSnapshot(actualDir) + if err != nil { + return "", "", err + } + + // there are a couple of reasons we're not generating the snapshot in expectedDir directly: + // Firstly we don't want to have to revert our .git file back to .git_keep. + // Secondly, the act of calling git commands like 'git status' actually changes the index + // for some reason, and we don't want to leave your lazygit working tree dirty as a result. + expectedDirCopyDir := filepath.Join(filepath.Dir(expectedDir), "expected_dir_test") + err = oscommands.CopyDir(expectedDir, expectedDirCopyDir) + if err != nil { + return "", "", err + } + + defer func() { + err := os.RemoveAll(expectedDirCopyDir) + if err != nil { + panic(err) + } + }() + + if err := restoreSpecialPaths(expectedDirCopyDir); err != nil { + return "", "", err + } + + expected, err := generateSnapshot(expectedDirCopyDir) + if err != nil { + return "", "", err + } + + return actual, expected, nil +} + +func getPathsToRename(dir string, needle string, contains string) []string { + pathsToRename := []string{} + + err := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error { + if err != nil { + return err + } + + if f.Name() == needle && (contains == "" || strings.Contains(path, contains)) { + pathsToRename = append(pathsToRename, path) + } + + return nil + }) + if err != nil { + panic(err) + } + + return pathsToRename +} + +var specialPathMappings = []struct{ original, new, contains string }{ + // git refuses to track .git or .gitmodules in subdirectories so we need to rename them + {".git", ".git_keep", ""}, + {".gitmodules", ".gitmodules_keep", ""}, + // we also need git to ignore the contents of our test gitignore files so that + // we actually commit files that are ignored within the test. + {".gitignore", "lg_ignore_file", ""}, + // this is the .git/info/exclude file. We're being a little more specific here + // so that we don't accidentally mess with some other file named 'exclude' in the test. + {"exclude", "lg_exclude_file", ".git/info/exclude"}, +} + +func renameSpecialPaths(dir string) error { + for _, specialPath := range specialPathMappings { + for _, path := range getPathsToRename(dir, specialPath.original, specialPath.contains) { + err := os.Rename(path, filepath.Join(filepath.Dir(path), specialPath.new)) + if err != nil { + return err + } + } + } + + return nil +} + +func restoreSpecialPaths(dir string) error { + for _, specialPath := range specialPathMappings { + for _, path := range getPathsToRename(dir, specialPath.new, specialPath.contains) { + err := os.Rename(path, filepath.Join(filepath.Dir(path), specialPath.original)) + if err != nil { + return err + } + } + } + + return nil +} + +func getLazygitCommand(testPath string, rootDir string, mode Mode, speed float64, extraCmdArgs string) (*exec.Cmd, error) { + osCommand := oscommands.NewDummyOSCommand() + + replayPath := filepath.Join(testPath, "recording.json") + templateConfigDir := filepath.Join(rootDir, "test", "default_test_config") + actualRepoDir := filepath.Join(testPath, "actual", "repo") + + exists, err := osCommand.FileExists(filepath.Join(testPath, "config")) + if err != nil { + return nil, err + } + + if exists { + templateConfigDir = filepath.Join(testPath, "config") + } + + configDir := filepath.Join(testPath, "used_config") + + err = os.RemoveAll(configDir) + if err != nil { + return nil, err + } + err = oscommands.CopyDir(templateConfigDir, configDir) + if err != nil { + return nil, err + } + + cmdStr := fmt.Sprintf("%s -debug --use-config-dir=%s --path=%s %s", tempLazygitPath(), configDir, actualRepoDir, extraCmdArgs) + + cmdObj := osCommand.Cmd.New(cmdStr) + cmdObj.AddEnvVars(fmt.Sprintf("SPEED=%f", speed)) + + switch mode { + case RECORD: + cmdObj.AddEnvVars(fmt.Sprintf("RECORD_EVENTS_TO=%s", replayPath)) + case TEST, UPDATE_SNAPSHOT: + cmdObj.AddEnvVars(fmt.Sprintf("REPLAY_EVENTS_FROM=%s", replayPath)) + } + + return cmdObj.GetCmd(), nil +} diff --git a/pkg/integration/integration_tests/branch/suggestions.go b/pkg/integration/integration_tests/branch/suggestions.go new file mode 100644 index 000000000..ff37ec9be --- /dev/null +++ b/pkg/integration/integration_tests/branch/suggestions.go @@ -0,0 +1,40 @@ +package branch + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/integration/types" +) + +var Suggestions = types.NewTest(types.NewTestArgs{ + Description: "Checking out a branch with name suggestions", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell types.Shell) { + shell. + EmptyCommit("my commit message"). + NewBranch("new-branch"). + NewBranch("new-branch-2"). + NewBranch("new-branch-3"). + NewBranch("branch-to-checkout"). + NewBranch("other-new-branch-2"). + NewBranch("other-new-branch-3") + }, + Run: func(shell types.Shell, input types.Input, assert types.Assert, keys config.KeybindingConfig) { + input.SwitchToBranchesWindow() + + input.PushKeys(keys.Branches.CheckoutBranchByName) + assert.CurrentViewName("confirmation") + + input.Type("branch-to") + + input.PushKeys(keys.Universal.TogglePanel) + assert.CurrentViewName("suggestions") + + // we expect the first suggestion to be the branch we want because it most + // closely matches what we typed in + input.Confirm() + + assert.CurrentBranchName("branch-to-checkout") + }, +}) diff --git a/pkg/integration/integration_tests/commit/commit.go b/pkg/integration/integration_tests/commit/commit.go new file mode 100644 index 000000000..777653bc0 --- /dev/null +++ b/pkg/integration/integration_tests/commit/commit.go @@ -0,0 +1,32 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/integration/types" +) + +var Commit = types.NewTest(types.NewTestArgs{ + Description: "Staging a couple files and committing", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell types.Shell) { + shell.CreateFile("myfile", "myfile content") + shell.CreateFile("myfile2", "myfile2 content") + }, + Run: func(shell types.Shell, input types.Input, assert types.Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.Select() + input.NextItem() + input.Select() + input.PushKeys(keys.Files.CommitChanges) + + commitMessage := "my commit message" + input.Type(commitMessage) + input.Confirm() + + assert.CommitCount(1) + assert.HeadCommitMessage(commitMessage) + }, +}) diff --git a/pkg/integration/integration_tests/commit/new_branch.go b/pkg/integration/integration_tests/commit/new_branch.go new file mode 100644 index 000000000..d70515280 --- /dev/null +++ b/pkg/integration/integration_tests/commit/new_branch.go @@ -0,0 +1,38 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/integration/types" +) + +var NewBranch = types.NewTest(types.NewTestArgs{ + Description: "Creating a new branch from a commit", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell types.Shell) { + shell. + EmptyCommit("commit 1"). + EmptyCommit("commit 2"). + EmptyCommit("commit 3") + }, + Run: func(shell types.Shell, input types.Input, assert types.Assert, keys config.KeybindingConfig) { + assert.CommitCount(3) + + input.SwitchToCommitsWindow() + assert.CurrentViewName("commits") + input.NextItem() + + input.PushKeys(keys.Universal.New) + + assert.CurrentViewName("confirmation") + + branchName := "my-branch-name" + input.Type(branchName) + input.Confirm() + + assert.CommitCount(2) + assert.HeadCommitMessage("commit 2") + assert.CurrentBranchName(branchName) + }, +}) diff --git a/pkg/integration/integration_tests/tests.go b/pkg/integration/integration_tests/tests.go new file mode 100644 index 000000000..1470ef178 --- /dev/null +++ b/pkg/integration/integration_tests/tests.go @@ -0,0 +1,16 @@ +package integration_tests + +import ( + "github.com/jesseduffield/lazygit/pkg/integration/integration_tests/branch" + "github.com/jesseduffield/lazygit/pkg/integration/integration_tests/commit" + "github.com/jesseduffield/lazygit/pkg/integration/types" +) + +// Here is where we lists the actual tests that will run. When you create a new test, +// be sure to add it to this list. + +var Tests = []types.Test{ + commit.Commit, + commit.NewBranch, + branch.Suggestions, +} diff --git a/pkg/gui/recording.go b/pkg/integration/recording.go similarity index 62% rename from pkg/gui/recording.go rename to pkg/integration/recording.go index 9edd50f08..3fa72aac1 100644 --- a/pkg/gui/recording.go +++ b/pkg/integration/recording.go @@ -1,4 +1,4 @@ -package gui +package integration import ( "encoding/json" @@ -10,23 +10,10 @@ import ( "github.com/jesseduffield/gocui" ) -func recordingEvents() bool { - return recordEventsTo() != "" -} +// this all relates to the old way of doing integration tests where you record yourself +// and then replay the events. -func recordEventsTo() string { - return os.Getenv("RECORD_EVENTS_TO") -} - -func replaying() bool { - return os.Getenv("REPLAY_EVENTS_FROM") != "" -} - -func headless() bool { - return os.Getenv("HEADLESS") != "" -} - -func getRecordingSpeed() float64 { +func GetRecordingSpeed() float64 { // humans are slow so this speeds things up. speed := 1.0 envReplaySpeed := os.Getenv("SPEED") @@ -40,7 +27,7 @@ func getRecordingSpeed() float64 { return speed } -func (gui *Gui) loadRecording() (*gocui.Recording, error) { +func LoadRecording() (*gocui.Recording, error) { path := os.Getenv("REPLAY_EVENTS_FROM") data, err := ioutil.ReadFile(path) @@ -58,8 +45,8 @@ func (gui *Gui) loadRecording() (*gocui.Recording, error) { return recording, nil } -func (gui *Gui) saveRecording(recording *gocui.Recording) error { - if !recordingEvents() { +func SaveRecording(recording *gocui.Recording) error { + if !RecordingEvents() { return nil } diff --git a/pkg/integration/shell.go b/pkg/integration/shell.go new file mode 100644 index 000000000..69bccb66c --- /dev/null +++ b/pkg/integration/shell.go @@ -0,0 +1,53 @@ +package integration + +import ( + "fmt" + "io/ioutil" + "os" + + "github.com/jesseduffield/lazygit/pkg/integration/types" + "github.com/jesseduffield/lazygit/pkg/secureexec" + "github.com/mgutz/str" +) + +type ShellImpl struct{} + +var _ types.Shell = &ShellImpl{} + +func (s *ShellImpl) RunCommand(cmdStr string) types.Shell { + args := str.ToArgv(cmdStr) + cmd := secureexec.Command(args[0], args[1:]...) + cmd.Env = os.Environ() + + output, err := cmd.CombinedOutput() + if err != nil { + panic(fmt.Sprintf("error running command: %s\n%s", cmdStr, string(output))) + } + + return s +} + +func (s *ShellImpl) CreateFile(path string, content string) types.Shell { + err := ioutil.WriteFile(path, []byte(content), 0o644) + if err != nil { + panic(fmt.Sprintf("error creating file: %s\n%s", path, err)) + } + + return s +} + +func (s *ShellImpl) NewBranch(name string) types.Shell { + return s.RunCommand("git checkout -b " + name) +} + +func (s *ShellImpl) GitAddAll() types.Shell { + return s.RunCommand("git add -A") +} + +func (s *ShellImpl) Commit(message string) types.Shell { + return s.RunCommand(fmt.Sprintf("git commit -m \"%s\"", message)) +} + +func (s *ShellImpl) EmptyCommit(message string) types.Shell { + return s.RunCommand(fmt.Sprintf("git commit --allow-empty -m \"%s\"", message)) +} diff --git a/pkg/integration/types/types.go b/pkg/integration/types/types.go new file mode 100644 index 000000000..29b303f35 --- /dev/null +++ b/pkg/integration/types/types.go @@ -0,0 +1,152 @@ +package types + +import ( + "strings" + + "github.com/jesseduffield/lazygit/pkg/config" + "github.com/jesseduffield/lazygit/pkg/utils" +) + +type Test interface { + Name() string + Description() string + // this is called before lazygit is run, for the sake of preparing the repo + SetupRepo(Shell) + // this gives you the default config and lets you set whatever values on it you like, + // so that they appear when lazygit runs + SetupConfig(config *config.AppConfig) + // this is called upon lazygit starting + Run(Shell, Input, Assert, config.KeybindingConfig) + // e.g. '-debug' + ExtraCmdArgs() string + // for tests that are flakey and when we don't have time to fix them + Skip() bool +} + +// this is for running shell commands, mostly for the sake of setting up the repo +// but you can also run the commands from within lazygit to emulate things happening +// in the background. +// Implementation is at pkg/integration/shell.go +type Shell interface { + RunCommand(command string) Shell + CreateFile(name string, content string) Shell + NewBranch(branchName string) Shell + GitAddAll() Shell + Commit(message string) Shell + EmptyCommit(message string) Shell +} + +// through this interface our test interacts with the lazygit gui +// Implementation is at pkg/gui/input.go +type Input interface { + // key is something like 'w' or ''. It's best not to pass a direct value, + // but instead to go through the default user config to get a more meaningful key name + PushKeys(keys ...string) + // for typing into a popup prompt + Type(content string) + // for when you want to allow lazygit to process something before continuing + Wait(milliseconds int) + // going straight to a particular side window + SwitchToStatusWindow() + SwitchToFilesWindow() + SwitchToBranchesWindow() + SwitchToCommitsWindow() + SwitchToStashWindow() + // i.e. pressing enter + Confirm() + // i.e. pressing escape + Cancel() + // i.e. pressing space + Select() + // i.e. pressing down arrow + NextItem() + // i.e. pressing up arrow + PreviousItem() +} + +// through this interface we assert on the state of the lazygit gui +type Assert interface { + WorkingTreeFileCount(int) + CommitCount(int) + HeadCommitMessage(string) + CurrentViewName(expectedViewName string) + CurrentBranchName(expectedBranchName string) +} + +type TestImpl struct { + name string + description string + extraCmdArgs string + skip bool + setupRepo func(shell Shell) + setupConfig func(config *config.AppConfig) + run func( + shell Shell, + input Input, + assert Assert, + keys config.KeybindingConfig, + ) +} + +type NewTestArgs struct { + Description string + SetupRepo func(shell Shell) + SetupConfig func(config *config.AppConfig) + Run func(shell Shell, input Input, assert Assert, keys config.KeybindingConfig) + ExtraCmdArgs string + Skip bool +} + +func NewTest(args NewTestArgs) *TestImpl { + return &TestImpl{ + name: testNameFromFilePath(), + description: args.Description, + extraCmdArgs: args.ExtraCmdArgs, + skip: args.Skip, + setupRepo: args.SetupRepo, + setupConfig: args.SetupConfig, + run: args.Run, + } +} + +var _ Test = (*TestImpl)(nil) + +func (self *TestImpl) Name() string { + return self.name +} + +func (self *TestImpl) Description() string { + return self.description +} + +func (self *TestImpl) ExtraCmdArgs() string { + return self.extraCmdArgs +} + +func (self *TestImpl) Skip() bool { + return self.skip +} + +func (self *TestImpl) SetupConfig(config *config.AppConfig) { + self.setupConfig(config) +} + +func (self *TestImpl) SetupRepo(shell Shell) { + self.setupRepo(shell) +} + +func (self *TestImpl) Run( + shell Shell, + input Input, + assert Assert, + keys config.KeybindingConfig, +) { + self.run(shell, input, assert, keys) +} + +func testNameFromFilePath() string { + path := utils.FilePath(3) + name := strings.Split(path, "integration/integration_tests/")[1] + + return name[:len(name)-len(".go")] +} diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 3f882c2b5..2f33862e8 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -128,3 +128,10 @@ func StackTrace() string { n := runtime.Stack(buf, false) return fmt.Sprintf("%s\n", buf[:n]) } + +// returns the path of the file that calls the function. +// 'skip' is the number of stack frames to skip. +func FilePath(skip int) string { + _, path, _, _ := runtime.Caller(skip) + return path +} diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/branchSuggestions/expected/repo/.git_keep/COMMIT_EDITMSG deleted file mode 100644 index dc3ab4abe..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/COMMIT_EDITMSG +++ /dev/null @@ -1 +0,0 @@ -file0 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/HEAD b/test/integration/branchSuggestions/expected/repo/.git_keep/HEAD deleted file mode 100644 index e2b7d4d2e..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/new-branch-3 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/index b/test/integration/branchSuggestions/expected/repo/.git_keep/index deleted file mode 100644 index fbde0e92a..000000000 Binary files a/test/integration/branchSuggestions/expected/repo/.git_keep/index and /dev/null differ diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/HEAD b/test/integration/branchSuggestions/expected/repo/.git_keep/logs/HEAD deleted file mode 100644 index 4deacbbf3..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/HEAD +++ /dev/null @@ -1,8 +0,0 @@ -0000000000000000000000000000000000000000 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 commit (initial): file0 -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 checkout: moving from master to new-branch -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 checkout: moving from new-branch to new-branch-2 -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 checkout: moving from new-branch-2 to new-branch-3 -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 checkout: moving from new-branch-3 to old-branch -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 checkout: moving from old-branch to old-branch-2 -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 checkout: moving from old-branch-2 to old-branch-3 -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675450 +1000 checkout: moving from old-branch-3 to new-branch-3 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/master deleted file mode 100644 index 8c6dabf38..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 commit (initial): file0 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/new-branch b/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/new-branch deleted file mode 100644 index 530a272f0..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/new-branch +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 branch: Created from HEAD diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-2 b/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-2 deleted file mode 100644 index 530a272f0..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-2 +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 branch: Created from HEAD diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-3 b/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-3 deleted file mode 100644 index 530a272f0..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-3 +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 branch: Created from HEAD diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/old-branch b/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/old-branch deleted file mode 100644 index 530a272f0..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/old-branch +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 branch: Created from HEAD diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/old-branch-2 b/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/old-branch-2 deleted file mode 100644 index 530a272f0..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/old-branch-2 +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 branch: Created from HEAD diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/old-branch-3 b/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/old-branch-3 deleted file mode 100644 index 530a272f0..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/logs/refs/heads/old-branch-3 +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 CI 1617675445 +1000 branch: Created from HEAD diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 b/test/integration/branchSuggestions/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 deleted file mode 100644 index 79fcadf67..000000000 Binary files a/test/integration/branchSuggestions/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 and /dev/null differ diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da b/test/integration/branchSuggestions/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da deleted file mode 100644 index 06c9cb73d..000000000 Binary files a/test/integration/branchSuggestions/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da and /dev/null differ diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/objects/75/e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 b/test/integration/branchSuggestions/expected/repo/.git_keep/objects/75/e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 deleted file mode 100644 index 16270b9a6..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/objects/75/e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 +++ /dev/null @@ -1,2 +0,0 @@ -xA -0Fa9ĀU4)<=o魭D4vWc% >VTQ՚4}pYz{x >8UGgafsc2'7u+ \ No newline at end of file diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/master b/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/master deleted file mode 100644 index ae478b1c7..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/new-branch b/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/new-branch deleted file mode 100644 index ae478b1c7..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/new-branch +++ /dev/null @@ -1 +0,0 @@ -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/new-branch-2 b/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/new-branch-2 deleted file mode 100644 index ae478b1c7..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/new-branch-2 +++ /dev/null @@ -1 +0,0 @@ -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/new-branch-3 b/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/new-branch-3 deleted file mode 100644 index ae478b1c7..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/new-branch-3 +++ /dev/null @@ -1 +0,0 @@ -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/old-branch b/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/old-branch deleted file mode 100644 index ae478b1c7..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/old-branch +++ /dev/null @@ -1 +0,0 @@ -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/old-branch-2 b/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/old-branch-2 deleted file mode 100644 index ae478b1c7..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/old-branch-2 +++ /dev/null @@ -1 +0,0 @@ -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/old-branch-3 b/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/old-branch-3 deleted file mode 100644 index ae478b1c7..000000000 --- a/test/integration/branchSuggestions/expected/repo/.git_keep/refs/heads/old-branch-3 +++ /dev/null @@ -1 +0,0 @@ -75e9e90a1d58c37d97d46a543dfbfd0f33fc52d8 diff --git a/test/integration/branchSuggestions/expected/repo/file0 b/test/integration/branchSuggestions/expected/repo/file0 deleted file mode 100644 index 38143ad4a..000000000 --- a/test/integration/branchSuggestions/expected/repo/file0 +++ /dev/null @@ -1 +0,0 @@ -test0 diff --git a/test/integration/branchSuggestions/recording.json b/test/integration/branchSuggestions/recording.json deleted file mode 100644 index 207dbcb3f..000000000 --- a/test/integration/branchSuggestions/recording.json +++ /dev/null @@ -1 +0,0 @@ -{"KeyEvents":[{"Timestamp":639,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1752,"Mod":0,"Key":256,"Ch":99},{"Timestamp":2183,"Mod":0,"Key":256,"Ch":110},{"Timestamp":2271,"Mod":0,"Key":256,"Ch":101},{"Timestamp":2327,"Mod":0,"Key":256,"Ch":119},{"Timestamp":2599,"Mod":0,"Key":256,"Ch":45},{"Timestamp":3583,"Mod":0,"Key":9,"Ch":9},{"Timestamp":3880,"Mod":0,"Key":258,"Ch":0},{"Timestamp":4175,"Mod":0,"Key":13,"Ch":13},{"Timestamp":4815,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/branchSuggestions/setup.sh b/test/integration/branchSuggestions/setup.sh deleted file mode 100644 index d67fa9291..000000000 --- a/test/integration/branchSuggestions/setup.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -set -e - -cd $1 - -git init - -git config user.email "CI@example.com" -git config user.name "CI" - -echo test0 > file0 -git add . -git commit -am file0 - -git checkout -b new-branch -git checkout -b new-branch-2 -git checkout -b new-branch-3 -git checkout -b old-branch -git checkout -b old-branch-2 -git checkout -b old-branch-3 diff --git a/test/integration/branchSuggestions/test.json b/test/integration/branchSuggestions/test.json deleted file mode 100644 index fafad1962..000000000 --- a/test/integration/branchSuggestions/test.json +++ /dev/null @@ -1 +0,0 @@ -{ "description": "Checking out a branch with name suggestions", "speed": 100 } diff --git a/test/integration/commit/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/commit/expected/repo/.git_keep/COMMIT_EDITMSG deleted file mode 100644 index 01f9a2aac..000000000 --- a/test/integration/commit/expected/repo/.git_keep/COMMIT_EDITMSG +++ /dev/null @@ -1 +0,0 @@ -commit diff --git a/test/integration/commit/expected/repo/.git_keep/index b/test/integration/commit/expected/repo/.git_keep/index deleted file mode 100644 index e0cf62690..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/index and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/logs/HEAD b/test/integration/commit/expected/repo/.git_keep/logs/HEAD deleted file mode 100644 index 66475b1c1..000000000 --- a/test/integration/commit/expected/repo/.git_keep/logs/HEAD +++ /dev/null @@ -1,5 +0,0 @@ -0000000000000000000000000000000000000000 3df3d8761bc0f0828596b11845aeac175b7b7393 CI 1617671339 +1000 commit (initial): myfile1 -3df3d8761bc0f0828596b11845aeac175b7b7393 a7d53cc21fd53100f955377be379423b0e386274 CI 1617671339 +1000 commit: myfile2 -a7d53cc21fd53100f955377be379423b0e386274 4ba4f1ed711a9081fab21bc222469aa5176a01f8 CI 1617671339 +1000 commit: myfile3 -4ba4f1ed711a9081fab21bc222469aa5176a01f8 1440bc6cc888a09dca2329d1060eec6de78d9d21 CI 1617671339 +1000 commit: myfile4 -1440bc6cc888a09dca2329d1060eec6de78d9d21 e7560e2cd4783a261ad32496cefed2d9f69a46e7 CI 1617671342 +1000 commit: commit diff --git a/test/integration/commit/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/commit/expected/repo/.git_keep/logs/refs/heads/master deleted file mode 100644 index 66475b1c1..000000000 --- a/test/integration/commit/expected/repo/.git_keep/logs/refs/heads/master +++ /dev/null @@ -1,5 +0,0 @@ -0000000000000000000000000000000000000000 3df3d8761bc0f0828596b11845aeac175b7b7393 CI 1617671339 +1000 commit (initial): myfile1 -3df3d8761bc0f0828596b11845aeac175b7b7393 a7d53cc21fd53100f955377be379423b0e386274 CI 1617671339 +1000 commit: myfile2 -a7d53cc21fd53100f955377be379423b0e386274 4ba4f1ed711a9081fab21bc222469aa5176a01f8 CI 1617671339 +1000 commit: myfile3 -4ba4f1ed711a9081fab21bc222469aa5176a01f8 1440bc6cc888a09dca2329d1060eec6de78d9d21 CI 1617671339 +1000 commit: myfile4 -1440bc6cc888a09dca2329d1060eec6de78d9d21 e7560e2cd4783a261ad32496cefed2d9f69a46e7 CI 1617671342 +1000 commit: commit diff --git a/test/integration/commit/expected/repo/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 b/test/integration/commit/expected/repo/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 deleted file mode 100644 index 7f2ebf4ee..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/14/40bc6cc888a09dca2329d1060eec6de78d9d21 b/test/integration/commit/expected/repo/.git_keep/objects/14/40bc6cc888a09dca2329d1060eec6de78d9d21 deleted file mode 100644 index 0a95d28ba..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/14/40bc6cc888a09dca2329d1060eec6de78d9d21 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 b/test/integration/commit/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 deleted file mode 100644 index f74bf2335..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce b/test/integration/commit/expected/repo/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce deleted file mode 100644 index 0a734f981..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/2f/6174050380438f14b16658a356e762435ca591 b/test/integration/commit/expected/repo/.git_keep/objects/2f/6174050380438f14b16658a356e762435ca591 deleted file mode 100644 index 31ae3f5ba..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/2f/6174050380438f14b16658a356e762435ca591 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/30/a1ca3481fdec3245b02aeacfb72ddfe2a433be b/test/integration/commit/expected/repo/.git_keep/objects/30/a1ca3481fdec3245b02aeacfb72ddfe2a433be deleted file mode 100644 index aca754d63..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/30/a1ca3481fdec3245b02aeacfb72ddfe2a433be and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/3d/f3d8761bc0f0828596b11845aeac175b7b7393 b/test/integration/commit/expected/repo/.git_keep/objects/3d/f3d8761bc0f0828596b11845aeac175b7b7393 deleted file mode 100644 index 9abdddbd3..000000000 --- a/test/integration/commit/expected/repo/.git_keep/objects/3d/f3d8761bc0f0828596b11845aeac175b7b7393 +++ /dev/null @@ -1,3 +0,0 @@ -xA -0@Q9iI -"BW=FL!R"~r*Jd ¬D "\S.0p~6fw LzLɝ})2r, \ No newline at end of file diff --git a/test/integration/commit/expected/repo/.git_keep/objects/4b/a4f1ed711a9081fab21bc222469aa5176a01f8 b/test/integration/commit/expected/repo/.git_keep/objects/4b/a4f1ed711a9081fab21bc222469aa5176a01f8 deleted file mode 100644 index b67f58f76..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/4b/a4f1ed711a9081fab21bc222469aa5176a01f8 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/4f/346f1ad5ba2917da2109e2eaa2f2dfbb86f10f b/test/integration/commit/expected/repo/.git_keep/objects/4f/346f1ad5ba2917da2109e2eaa2f2dfbb86f10f deleted file mode 100644 index 953241815..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/4f/346f1ad5ba2917da2109e2eaa2f2dfbb86f10f and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 b/test/integration/commit/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 deleted file mode 100644 index 285df3e5f..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/commit/expected/repo/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 deleted file mode 100644 index 96d2e71a6..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/a7/d53cc21fd53100f955377be379423b0e386274 b/test/integration/commit/expected/repo/.git_keep/objects/a7/d53cc21fd53100f955377be379423b0e386274 deleted file mode 100644 index 77d08ca03..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/a7/d53cc21fd53100f955377be379423b0e386274 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 b/test/integration/commit/expected/repo/.git_keep/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 deleted file mode 100644 index d39fa7d2f..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b b/test/integration/commit/expected/repo/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b deleted file mode 100644 index 9b771fc2f..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/objects/e7/560e2cd4783a261ad32496cefed2d9f69a46e7 b/test/integration/commit/expected/repo/.git_keep/objects/e7/560e2cd4783a261ad32496cefed2d9f69a46e7 deleted file mode 100644 index 9eb3492d1..000000000 Binary files a/test/integration/commit/expected/repo/.git_keep/objects/e7/560e2cd4783a261ad32496cefed2d9f69a46e7 and /dev/null differ diff --git a/test/integration/commit/expected/repo/.git_keep/refs/heads/master b/test/integration/commit/expected/repo/.git_keep/refs/heads/master deleted file mode 100644 index c641d5ee6..000000000 --- a/test/integration/commit/expected/repo/.git_keep/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -e7560e2cd4783a261ad32496cefed2d9f69a46e7 diff --git a/test/integration/commit/expected/repo/myfile1 b/test/integration/commit/expected/repo/myfile1 deleted file mode 100644 index a5bce3fd2..000000000 --- a/test/integration/commit/expected/repo/myfile1 +++ /dev/null @@ -1 +0,0 @@ -test1 diff --git a/test/integration/commit/expected/repo/myfile2 b/test/integration/commit/expected/repo/myfile2 deleted file mode 100644 index 180cf8328..000000000 --- a/test/integration/commit/expected/repo/myfile2 +++ /dev/null @@ -1 +0,0 @@ -test2 diff --git a/test/integration/commit/expected/repo/myfile3 b/test/integration/commit/expected/repo/myfile3 deleted file mode 100644 index df6b0d2bc..000000000 --- a/test/integration/commit/expected/repo/myfile3 +++ /dev/null @@ -1 +0,0 @@ -test3 diff --git a/test/integration/commit/expected/repo/myfile4 b/test/integration/commit/expected/repo/myfile4 deleted file mode 100644 index d234c5e05..000000000 --- a/test/integration/commit/expected/repo/myfile4 +++ /dev/null @@ -1 +0,0 @@ -test4 diff --git a/test/integration/commit/expected/repo/myfile5 b/test/integration/commit/expected/repo/myfile5 deleted file mode 100644 index 4f346f1ad..000000000 --- a/test/integration/commit/expected/repo/myfile5 +++ /dev/null @@ -1 +0,0 @@ -test5 diff --git a/test/integration/commit/recording.json b/test/integration/commit/recording.json deleted file mode 100644 index eb45c9fde..000000000 --- a/test/integration/commit/recording.json +++ /dev/null @@ -1 +0,0 @@ -{"KeyEvents":[{"Timestamp":527,"Mod":0,"Key":256,"Ch":32},{"Timestamp":830,"Mod":0,"Key":256,"Ch":99},{"Timestamp":1127,"Mod":0,"Key":256,"Ch":99},{"Timestamp":1190,"Mod":0,"Key":256,"Ch":111},{"Timestamp":1335,"Mod":0,"Key":256,"Ch":109},{"Timestamp":1447,"Mod":0,"Key":256,"Ch":109},{"Timestamp":1583,"Mod":0,"Key":256,"Ch":105},{"Timestamp":1606,"Mod":0,"Key":256,"Ch":116},{"Timestamp":1935,"Mod":0,"Key":13,"Ch":13},{"Timestamp":2353,"Mod":0,"Key":27,"Ch":0}],"ResizeEvents":[{"Timestamp":0,"Width":127,"Height":35}]} diff --git a/test/integration/commit/setup.sh b/test/integration/commit/setup.sh deleted file mode 100644 index c6c6a9271..000000000 --- a/test/integration/commit/setup.sh +++ /dev/null @@ -1,24 +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" -echo test2 > myfile2 -git add . -git commit -am "myfile2" -echo test3 > myfile3 -git add . -git commit -am "myfile3" -echo test4 > myfile4 -git add . -git commit -am "myfile4" -echo test5 > myfile5 diff --git a/test/integration/commit/test.json b/test/integration/commit/test.json deleted file mode 100644 index 60bfe9319..000000000 --- a/test/integration/commit/test.json +++ /dev/null @@ -1 +0,0 @@ -{ "description": "stage a file and commit the change", "speed": 15 } diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/commitsNewBranch/expected/repo/.git_keep/COMMIT_EDITMSG deleted file mode 100644 index 6c493ff74..000000000 --- a/test/integration/commitsNewBranch/expected/repo/.git_keep/COMMIT_EDITMSG +++ /dev/null @@ -1 +0,0 @@ -file2 diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/HEAD b/test/integration/commitsNewBranch/expected/repo/.git_keep/HEAD deleted file mode 100644 index 78bc9f37b..000000000 --- a/test/integration/commitsNewBranch/expected/repo/.git_keep/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/lol diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/index b/test/integration/commitsNewBranch/expected/repo/.git_keep/index deleted file mode 100644 index 577a68b72..000000000 Binary files a/test/integration/commitsNewBranch/expected/repo/.git_keep/index and /dev/null differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/logs/HEAD b/test/integration/commitsNewBranch/expected/repo/.git_keep/logs/HEAD deleted file mode 100644 index 67065fbb9..000000000 --- a/test/integration/commitsNewBranch/expected/repo/.git_keep/logs/HEAD +++ /dev/null @@ -1,4 +0,0 @@ -0000000000000000000000000000000000000000 9901fd9b7766be600bed07f55f1794a759527a98 CI 1617674232 +1000 commit (initial): file0 -9901fd9b7766be600bed07f55f1794a759527a98 0029f9bf66e346d47ede6a501abb5b82bee60096 CI 1617674232 +1000 commit: file1 -0029f9bf66e346d47ede6a501abb5b82bee60096 e1cb250774fb8606d33062518d0ae03831130249 CI 1617674232 +1000 commit: file2 -e1cb250774fb8606d33062518d0ae03831130249 0029f9bf66e346d47ede6a501abb5b82bee60096 CI 1617674249 +1000 checkout: moving from master to lol diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/logs/refs/heads/lol b/test/integration/commitsNewBranch/expected/repo/.git_keep/logs/refs/heads/lol deleted file mode 100644 index 1202f15d1..000000000 --- a/test/integration/commitsNewBranch/expected/repo/.git_keep/logs/refs/heads/lol +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 0029f9bf66e346d47ede6a501abb5b82bee60096 CI 1617674249 +1000 branch: Created from 0029f9bf66e346d47ede6a501abb5b82bee60096 diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/commitsNewBranch/expected/repo/.git_keep/logs/refs/heads/master deleted file mode 100644 index 5c02b3b2c..000000000 --- a/test/integration/commitsNewBranch/expected/repo/.git_keep/logs/refs/heads/master +++ /dev/null @@ -1,3 +0,0 @@ -0000000000000000000000000000000000000000 9901fd9b7766be600bed07f55f1794a759527a98 CI 1617674232 +1000 commit (initial): file0 -9901fd9b7766be600bed07f55f1794a759527a98 0029f9bf66e346d47ede6a501abb5b82bee60096 CI 1617674232 +1000 commit: file1 -0029f9bf66e346d47ede6a501abb5b82bee60096 e1cb250774fb8606d33062518d0ae03831130249 CI 1617674232 +1000 commit: file2 diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/00/29f9bf66e346d47ede6a501abb5b82bee60096 b/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/00/29f9bf66e346d47ede6a501abb5b82bee60096 deleted file mode 100644 index e5731eb1f..000000000 Binary files a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/00/29f9bf66e346d47ede6a501abb5b82bee60096 and /dev/null differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 b/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 deleted file mode 100644 index f74bf2335..000000000 Binary files a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 and /dev/null differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 b/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 deleted file mode 100644 index 79fcadf67..000000000 Binary files a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/1e/3e67b999db1576ad1ee08bf4f02bdf29e49442 and /dev/null differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da b/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da deleted file mode 100644 index 06c9cb73d..000000000 Binary files a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/38/143ad4a0fe2ab6ee53c2ef89a5d9e2bd9535da and /dev/null differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/99/01fd9b7766be600bed07f55f1794a759527a98 b/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/99/01fd9b7766be600bed07f55f1794a759527a98 deleted file mode 100644 index cd2e8264c..000000000 Binary files a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/99/01fd9b7766be600bed07f55f1794a759527a98 and /dev/null differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/9e/88a70dc8d82dd2afbfd50176ef78e18823bc2c b/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/9e/88a70dc8d82dd2afbfd50176ef78e18823bc2c deleted file mode 100644 index 0e95eb06d..000000000 Binary files a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/9e/88a70dc8d82dd2afbfd50176ef78e18823bc2c and /dev/null differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 b/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 deleted file mode 100644 index 285df3e5f..000000000 Binary files a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 and /dev/null differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641 b/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641 deleted file mode 100644 index 2e9066287..000000000 --- a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/d0/76cc9cc09acaa2d36fbc7a95fd3e2306494641 +++ /dev/null @@ -1,2 +0,0 @@ -x+)JMU03c040031QHI5`ֶww.hT[H - yW5Ɨ(| ^-W(x9 \ No newline at end of file diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/e1/cb250774fb8606d33062518d0ae03831130249 b/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/e1/cb250774fb8606d33062518d0ae03831130249 deleted file mode 100644 index fc22897cc..000000000 Binary files a/test/integration/commitsNewBranch/expected/repo/.git_keep/objects/e1/cb250774fb8606d33062518d0ae03831130249 and /dev/null differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/refs/heads/lol b/test/integration/commitsNewBranch/expected/repo/.git_keep/refs/heads/lol deleted file mode 100644 index e92394760..000000000 --- a/test/integration/commitsNewBranch/expected/repo/.git_keep/refs/heads/lol +++ /dev/null @@ -1 +0,0 @@ -0029f9bf66e346d47ede6a501abb5b82bee60096 diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/refs/heads/master b/test/integration/commitsNewBranch/expected/repo/.git_keep/refs/heads/master deleted file mode 100644 index d5689ed85..000000000 --- a/test/integration/commitsNewBranch/expected/repo/.git_keep/refs/heads/master +++ /dev/null @@ -1 +0,0 @@ -e1cb250774fb8606d33062518d0ae03831130249 diff --git a/test/integration/commitsNewBranch/expected/repo/file0 b/test/integration/commitsNewBranch/expected/repo/file0 deleted file mode 100644 index 38143ad4a..000000000 --- a/test/integration/commitsNewBranch/expected/repo/file0 +++ /dev/null @@ -1 +0,0 @@ -test0 diff --git a/test/integration/commitsNewBranch/expected/repo/file1 b/test/integration/commitsNewBranch/expected/repo/file1 deleted file mode 100644 index a5bce3fd2..000000000 --- a/test/integration/commitsNewBranch/expected/repo/file1 +++ /dev/null @@ -1 +0,0 @@ -test1 diff --git a/test/integration/commitsNewBranch/recording.json b/test/integration/commitsNewBranch/recording.json deleted file mode 100644 index ca4d07a4a..000000000 --- a/test/integration/commitsNewBranch/recording.json +++ /dev/null @@ -1 +0,0 @@ -{"KeyEvents":[{"Timestamp":972,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1243,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1812,"Mod":0,"Key":256,"Ch":120},{"Timestamp":2683,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3018,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3033,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3050,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3067,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3084,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3100,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3363,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3499,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3628,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3771,"Mod":0,"Key":258,"Ch":0},{"Timestamp":3908,"Mod":0,"Key":258,"Ch":0},{"Timestamp":4051,"Mod":0,"Key":258,"Ch":0},{"Timestamp":4259,"Mod":0,"Key":258,"Ch":0},{"Timestamp":4883,"Mod":0,"Key":258,"Ch":0},{"Timestamp":5124,"Mod":0,"Key":258,"Ch":0},{"Timestamp":5355,"Mod":0,"Key":258,"Ch":0},{"Timestamp":6083,"Mod":0,"Key":258,"Ch":0},{"Timestamp":6563,"Mod":0,"Key":258,"Ch":0},{"Timestamp":7210,"Mod":0,"Key":258,"Ch":0},{"Timestamp":9475,"Mod":0,"Key":258,"Ch":0},{"Timestamp":10395,"Mod":0,"Key":258,"Ch":0},{"Timestamp":11019,"Mod":0,"Key":258,"Ch":0},{"Timestamp":11346,"Mod":0,"Key":258,"Ch":0},{"Timestamp":11587,"Mod":0,"Key":258,"Ch":0},{"Timestamp":11771,"Mod":0,"Key":258,"Ch":0},{"Timestamp":11883,"Mod":0,"Key":258,"Ch":0},{"Timestamp":12003,"Mod":0,"Key":258,"Ch":0},{"Timestamp":12132,"Mod":0,"Key":258,"Ch":0},{"Timestamp":12268,"Mod":0,"Key":258,"Ch":0},{"Timestamp":12395,"Mod":0,"Key":258,"Ch":0},{"Timestamp":12539,"Mod":0,"Key":258,"Ch":0},{"Timestamp":12667,"Mod":0,"Key":258,"Ch":0},{"Timestamp":12804,"Mod":0,"Key":258,"Ch":0},{"Timestamp":12947,"Mod":0,"Key":258,"Ch":0},{"Timestamp":13075,"Mod":0,"Key":258,"Ch":0},{"Timestamp":13211,"Mod":0,"Key":258,"Ch":0},{"Timestamp":13347,"Mod":0,"Key":258,"Ch":0},{"Timestamp":13475,"Mod":0,"Key":258,"Ch":0},{"Timestamp":13620,"Mod":0,"Key":258,"Ch":0},{"Timestamp":13771,"Mod":0,"Key":258,"Ch":0},{"Timestamp":13883,"Mod":0,"Key":258,"Ch":0},{"Timestamp":14027,"Mod":0,"Key":258,"Ch":0},{"Timestamp":14405,"Mod":0,"Key":27,"Ch":0},{"Timestamp":15540,"Mod":0,"Key":258,"Ch":0},{"Timestamp":15995,"Mod":0,"Key":256,"Ch":110},{"Timestamp":17267,"Mod":0,"Key":256,"Ch":108},{"Timestamp":17396,"Mod":0,"Key":256,"Ch":111},{"Timestamp":17547,"Mod":0,"Key":256,"Ch":108},{"Timestamp":17675,"Mod":0,"Key":13,"Ch":13},{"Timestamp":20195,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/commitsNewBranch/setup.sh b/test/integration/commitsNewBranch/setup.sh deleted file mode 100644 index 4e35cf543..000000000 --- a/test/integration/commitsNewBranch/setup.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -set -e - -cd $1 - -git init - -git config user.email "CI@example.com" -git config user.name "CI" - -echo test0 > file0 -git add . -git commit -am file0 - -echo test1 > file1 -git add . -git commit -am file1 - -echo test2 > file2 -git add . -git commit -am file2 diff --git a/test/integration/commitsNewBranch/test.json b/test/integration/commitsNewBranch/test.json deleted file mode 100644 index d760dcc6c..000000000 --- a/test/integration/commitsNewBranch/test.json +++ /dev/null @@ -1 +0,0 @@ -{ "description": "Reverting a commit. Note here that our snapshot test fails if the commit SHA is included in the message hence the renaming of the revert commit after creating it", "speed": 20 } diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/branch/suggestions/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..8a744b4fe --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +my commit message diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/branch/suggestions/expected/repo/.git_keep/FETCH_HEAD similarity index 100% rename from test/integration/branchSuggestions/expected/repo/.git_keep/FETCH_HEAD rename to test/integration_new/branch/suggestions/expected/repo/.git_keep/FETCH_HEAD diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/HEAD b/test/integration_new/branch/suggestions/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..3b627c921 --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/branch-to-checkout diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/config b/test/integration_new/branch/suggestions/expected/repo/.git_keep/config similarity index 100% rename from test/integration/branchSuggestions/expected/repo/.git_keep/config rename to test/integration_new/branch/suggestions/expected/repo/.git_keep/config diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/description b/test/integration_new/branch/suggestions/expected/repo/.git_keep/description similarity index 100% rename from test/integration/branchSuggestions/expected/repo/.git_keep/description rename to test/integration_new/branch/suggestions/expected/repo/.git_keep/description diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/index b/test/integration_new/branch/suggestions/expected/repo/.git_keep/index new file mode 100644 index 000000000..65d675154 Binary files /dev/null and b/test/integration_new/branch/suggestions/expected/repo/.git_keep/index differ diff --git a/test/integration/branchSuggestions/expected/repo/.git_keep/info/exclude b/test/integration_new/branch/suggestions/expected/repo/.git_keep/info/exclude similarity index 100% rename from test/integration/branchSuggestions/expected/repo/.git_keep/info/exclude rename to test/integration_new/branch/suggestions/expected/repo/.git_keep/info/exclude diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/HEAD b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..e97c3aa0e --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1,8 @@ +0000000000000000000000000000000000000000 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 commit (initial): my commit message +1682dc1949e1937af44b5270fec5c1ac9256c6a1 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 checkout: moving from master to new-branch +1682dc1949e1937af44b5270fec5c1ac9256c6a1 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 checkout: moving from new-branch to new-branch-2 +1682dc1949e1937af44b5270fec5c1ac9256c6a1 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 checkout: moving from new-branch-2 to new-branch-3 +1682dc1949e1937af44b5270fec5c1ac9256c6a1 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 checkout: moving from new-branch-3 to branch-to-checkout +1682dc1949e1937af44b5270fec5c1ac9256c6a1 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 checkout: moving from branch-to-checkout to other-new-branch-2 +1682dc1949e1937af44b5270fec5c1ac9256c6a1 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 checkout: moving from other-new-branch-2 to other-new-branch-3 +1682dc1949e1937af44b5270fec5c1ac9256c6a1 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 checkout: moving from other-new-branch-3 to branch-to-checkout diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/branch-to-checkout b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/branch-to-checkout new file mode 100644 index 000000000..6b7fc9713 --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/branch-to-checkout @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 branch: Created from HEAD diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..7475970dc --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 commit (initial): my commit message diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/new-branch b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/new-branch new file mode 100644 index 000000000..6b7fc9713 --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/new-branch @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 branch: Created from HEAD diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-2 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-2 new file mode 100644 index 000000000..6b7fc9713 --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-2 @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 branch: Created from HEAD diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-3 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-3 new file mode 100644 index 000000000..6b7fc9713 --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/new-branch-3 @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 branch: Created from HEAD diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/other-new-branch-2 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/other-new-branch-2 new file mode 100644 index 000000000..6b7fc9713 --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/other-new-branch-2 @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 branch: Created from HEAD diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/other-new-branch-3 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/other-new-branch-3 new file mode 100644 index 000000000..6b7fc9713 --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/logs/refs/heads/other-new-branch-3 @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 1682dc1949e1937af44b5270fec5c1ac9256c6a1 CI 1659873850 +1000 branch: Created from HEAD diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/objects/16/82dc1949e1937af44b5270fec5c1ac9256c6a1 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/objects/16/82dc1949e1937af44b5270fec5c1ac9256c6a1 new file mode 100644 index 000000000..45c339c12 Binary files /dev/null and b/test/integration_new/branch/suggestions/expected/repo/.git_keep/objects/16/82dc1949e1937af44b5270fec5c1ac9256c6a1 differ diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 new file mode 100644 index 000000000..adf64119a Binary files /dev/null and b/test/integration_new/branch/suggestions/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 differ diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/branch-to-checkout b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/branch-to-checkout new file mode 100644 index 000000000..23eeb4fdc --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/branch-to-checkout @@ -0,0 +1 @@ +1682dc1949e1937af44b5270fec5c1ac9256c6a1 diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/master b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..23eeb4fdc --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +1682dc1949e1937af44b5270fec5c1ac9256c6a1 diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/new-branch b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/new-branch new file mode 100644 index 000000000..23eeb4fdc --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/new-branch @@ -0,0 +1 @@ +1682dc1949e1937af44b5270fec5c1ac9256c6a1 diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/new-branch-2 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/new-branch-2 new file mode 100644 index 000000000..23eeb4fdc --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/new-branch-2 @@ -0,0 +1 @@ +1682dc1949e1937af44b5270fec5c1ac9256c6a1 diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/new-branch-3 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/new-branch-3 new file mode 100644 index 000000000..23eeb4fdc --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/new-branch-3 @@ -0,0 +1 @@ +1682dc1949e1937af44b5270fec5c1ac9256c6a1 diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/other-new-branch-2 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/other-new-branch-2 new file mode 100644 index 000000000..23eeb4fdc --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/other-new-branch-2 @@ -0,0 +1 @@ +1682dc1949e1937af44b5270fec5c1ac9256c6a1 diff --git a/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/other-new-branch-3 b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/other-new-branch-3 new file mode 100644 index 000000000..23eeb4fdc --- /dev/null +++ b/test/integration_new/branch/suggestions/expected/repo/.git_keep/refs/heads/other-new-branch-3 @@ -0,0 +1 @@ +1682dc1949e1937af44b5270fec5c1ac9256c6a1 diff --git a/test/integration_new/commit/commit/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/commit/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..8a744b4fe --- /dev/null +++ b/test/integration_new/commit/commit/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +my commit message diff --git a/test/integration/commit/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/commit/expected/repo/.git_keep/FETCH_HEAD similarity index 100% rename from test/integration/commit/expected/repo/.git_keep/FETCH_HEAD rename to test/integration_new/commit/commit/expected/repo/.git_keep/FETCH_HEAD diff --git a/test/integration/commit/expected/repo/.git_keep/HEAD b/test/integration_new/commit/commit/expected/repo/.git_keep/HEAD similarity index 100% rename from test/integration/commit/expected/repo/.git_keep/HEAD rename to test/integration_new/commit/commit/expected/repo/.git_keep/HEAD diff --git a/test/integration/commit/expected/repo/.git_keep/config b/test/integration_new/commit/commit/expected/repo/.git_keep/config similarity index 100% rename from test/integration/commit/expected/repo/.git_keep/config rename to test/integration_new/commit/commit/expected/repo/.git_keep/config diff --git a/test/integration/commit/expected/repo/.git_keep/description b/test/integration_new/commit/commit/expected/repo/.git_keep/description similarity index 100% rename from test/integration/commit/expected/repo/.git_keep/description rename to test/integration_new/commit/commit/expected/repo/.git_keep/description diff --git a/test/integration_new/commit/commit/expected/repo/.git_keep/index b/test/integration_new/commit/commit/expected/repo/.git_keep/index new file mode 100644 index 000000000..d72d7c026 Binary files /dev/null and b/test/integration_new/commit/commit/expected/repo/.git_keep/index differ diff --git a/test/integration/commit/expected/repo/.git_keep/info/exclude b/test/integration_new/commit/commit/expected/repo/.git_keep/info/exclude similarity index 100% rename from test/integration/commit/expected/repo/.git_keep/info/exclude rename to test/integration_new/commit/commit/expected/repo/.git_keep/info/exclude diff --git a/test/integration_new/commit/commit/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/commit/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..cc260688d --- /dev/null +++ b/test/integration_new/commit/commit/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 460150760ff1f381c3f5769b919cb73107c5871a CI 1659863059 +1000 commit (initial): my commit message diff --git a/test/integration_new/commit/commit/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/commit/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..cc260688d --- /dev/null +++ b/test/integration_new/commit/commit/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 460150760ff1f381c3f5769b919cb73107c5871a CI 1659863059 +1000 commit (initial): my commit message diff --git a/test/integration_new/commit/commit/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 b/test/integration_new/commit/commit/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 new file mode 100644 index 000000000..57198442f Binary files /dev/null and b/test/integration_new/commit/commit/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 differ diff --git a/test/integration_new/commit/commit/expected/repo/.git_keep/objects/46/0150760ff1f381c3f5769b919cb73107c5871a b/test/integration_new/commit/commit/expected/repo/.git_keep/objects/46/0150760ff1f381c3f5769b919cb73107c5871a new file mode 100644 index 000000000..4792ad56d Binary files /dev/null and b/test/integration_new/commit/commit/expected/repo/.git_keep/objects/46/0150760ff1f381c3f5769b919cb73107c5871a differ diff --git a/test/integration_new/commit/commit/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 b/test/integration_new/commit/commit/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 new file mode 100644 index 000000000..c4b48a2f0 Binary files /dev/null and b/test/integration_new/commit/commit/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 differ diff --git a/test/integration_new/commit/commit/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 b/test/integration_new/commit/commit/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 new file mode 100644 index 000000000..98345f609 Binary files /dev/null and b/test/integration_new/commit/commit/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 differ diff --git a/test/integration_new/commit/commit/expected/repo/.git_keep/refs/heads/master b/test/integration_new/commit/commit/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..a21004dfc --- /dev/null +++ b/test/integration_new/commit/commit/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +460150760ff1f381c3f5769b919cb73107c5871a diff --git a/test/integration_new/commit/commit/expected/repo/myfile b/test/integration_new/commit/commit/expected/repo/myfile new file mode 100644 index 000000000..ada566156 --- /dev/null +++ b/test/integration_new/commit/commit/expected/repo/myfile @@ -0,0 +1 @@ +myfile content \ No newline at end of file diff --git a/test/integration_new/commit/commit/expected/repo/myfile2 b/test/integration_new/commit/commit/expected/repo/myfile2 new file mode 100644 index 000000000..9704090f8 --- /dev/null +++ b/test/integration_new/commit/commit/expected/repo/myfile2 @@ -0,0 +1 @@ +myfile2 content \ No newline at end of file diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/new_branch/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..68d1ef3ef --- /dev/null +++ b/test/integration_new/commit/new_branch/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +commit 3 diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/new_branch/expected/repo/.git_keep/FETCH_HEAD similarity index 100% rename from test/integration/commitsNewBranch/expected/repo/.git_keep/FETCH_HEAD rename to test/integration_new/commit/new_branch/expected/repo/.git_keep/FETCH_HEAD diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/HEAD b/test/integration_new/commit/new_branch/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..634a851e9 --- /dev/null +++ b/test/integration_new/commit/new_branch/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/my-branch-name diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/config b/test/integration_new/commit/new_branch/expected/repo/.git_keep/config similarity index 100% rename from test/integration/commitsNewBranch/expected/repo/.git_keep/config rename to test/integration_new/commit/new_branch/expected/repo/.git_keep/config diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/description b/test/integration_new/commit/new_branch/expected/repo/.git_keep/description similarity index 100% rename from test/integration/commitsNewBranch/expected/repo/.git_keep/description rename to test/integration_new/commit/new_branch/expected/repo/.git_keep/description diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/index b/test/integration_new/commit/new_branch/expected/repo/.git_keep/index new file mode 100644 index 000000000..65d675154 Binary files /dev/null and b/test/integration_new/commit/new_branch/expected/repo/.git_keep/index differ diff --git a/test/integration/commitsNewBranch/expected/repo/.git_keep/info/exclude b/test/integration_new/commit/new_branch/expected/repo/.git_keep/info/exclude similarity index 100% rename from test/integration/commitsNewBranch/expected/repo/.git_keep/info/exclude rename to test/integration_new/commit/new_branch/expected/repo/.git_keep/info/exclude diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/new_branch/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..b641844cb --- /dev/null +++ b/test/integration_new/commit/new_branch/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1,4 @@ +0000000000000000000000000000000000000000 470038e1336649b2965305f9f6a82501a836810e CI 1659865912 +1000 commit (initial): commit 1 +470038e1336649b2965305f9f6a82501a836810e c8bec8f2b323cbb476e708bd10c145ea7cc9f726 CI 1659865912 +1000 commit: commit 2 +c8bec8f2b323cbb476e708bd10c145ea7cc9f726 62a60693a2e154e745ee353f67a05156d0532c23 CI 1659865912 +1000 commit: commit 3 +62a60693a2e154e745ee353f67a05156d0532c23 c8bec8f2b323cbb476e708bd10c145ea7cc9f726 CI 1659865912 +1000 checkout: moving from master to my-branch-name diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/new_branch/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..57ad94e9f --- /dev/null +++ b/test/integration_new/commit/new_branch/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1,3 @@ +0000000000000000000000000000000000000000 470038e1336649b2965305f9f6a82501a836810e CI 1659865912 +1000 commit (initial): commit 1 +470038e1336649b2965305f9f6a82501a836810e c8bec8f2b323cbb476e708bd10c145ea7cc9f726 CI 1659865912 +1000 commit: commit 2 +c8bec8f2b323cbb476e708bd10c145ea7cc9f726 62a60693a2e154e745ee353f67a05156d0532c23 CI 1659865912 +1000 commit: commit 3 diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/logs/refs/heads/my-branch-name b/test/integration_new/commit/new_branch/expected/repo/.git_keep/logs/refs/heads/my-branch-name new file mode 100644 index 000000000..7e8364dfe --- /dev/null +++ b/test/integration_new/commit/new_branch/expected/repo/.git_keep/logs/refs/heads/my-branch-name @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 c8bec8f2b323cbb476e708bd10c145ea7cc9f726 CI 1659865912 +1000 branch: Created from c8bec8f2b323cbb476e708bd10c145ea7cc9f726 diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/47/0038e1336649b2965305f9f6a82501a836810e b/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/47/0038e1336649b2965305f9f6a82501a836810e new file mode 100644 index 000000000..5099d76b8 Binary files /dev/null and b/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/47/0038e1336649b2965305f9f6a82501a836810e differ diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 new file mode 100644 index 000000000..adf64119a Binary files /dev/null and b/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 differ diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/62/a60693a2e154e745ee353f67a05156d0532c23 b/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/62/a60693a2e154e745ee353f67a05156d0532c23 new file mode 100644 index 000000000..5e0ed3632 Binary files /dev/null and b/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/62/a60693a2e154e745ee353f67a05156d0532c23 differ diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/c8/bec8f2b323cbb476e708bd10c145ea7cc9f726 b/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/c8/bec8f2b323cbb476e708bd10c145ea7cc9f726 new file mode 100644 index 000000000..a9c5a5ed8 --- /dev/null +++ b/test/integration_new/commit/new_branch/expected/repo/.git_keep/objects/c8/bec8f2b323cbb476e708bd10c145ea7cc9f726 @@ -0,0 +1,2 @@ +xK +1]kAD#tP00Df\Q<=:XBR(I$$r1׬ҮYDAcJiM-I~_wfLM?mO=]RXGf#g_9> \ No newline at end of file diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/refs/heads/master b/test/integration_new/commit/new_branch/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..5c73ff150 --- /dev/null +++ b/test/integration_new/commit/new_branch/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +62a60693a2e154e745ee353f67a05156d0532c23 diff --git a/test/integration_new/commit/new_branch/expected/repo/.git_keep/refs/heads/my-branch-name b/test/integration_new/commit/new_branch/expected/repo/.git_keep/refs/heads/my-branch-name new file mode 100644 index 000000000..75da99d74 --- /dev/null +++ b/test/integration_new/commit/new_branch/expected/repo/.git_keep/refs/heads/my-branch-name @@ -0,0 +1 @@ +c8bec8f2b323cbb476e708bd10c145ea7cc9f726 diff --git a/test/runner/main.go b/test/runner/main.go index 58ccd591f..ea6af59e8 100644 --- a/test/runner/main.go +++ b/test/runner/main.go @@ -11,6 +11,8 @@ import ( "github.com/stretchr/testify/assert" ) +// Deprecated: This file is part of the old way of doing things. See test/runner_new/main.go for the new way + // see docs/Integration_Tests.md // This file can be invoked directly, but you might find it easier to go through // test/lazyintegration/main.go, which provides a convenient gui wrapper to integration tests. diff --git a/test/runner_new/main.go b/test/runner_new/main.go new file mode 100644 index 000000000..19a5dba03 --- /dev/null +++ b/test/runner_new/main.go @@ -0,0 +1,76 @@ +package main + +import ( + "fmt" + "log" + "os" + "os/exec" + "testing" + + "github.com/jesseduffield/lazygit/pkg/integration" + "github.com/jesseduffield/lazygit/pkg/integration/types" + "github.com/stretchr/testify/assert" +) + +// see docs/Integration_Tests.md +// This file can be invoked directly, but you might find it easier to go through +// test/lazyintegration/main.go, which provides a convenient gui wrapper to integration tests. +// +// If invoked directly, you can specify a test by passing it as the first argument. +// You can also specify that you want to record a test by passing MODE=record +// as an env var. + +func main() { + mode := integration.GetModeFromEnv() + includeSkipped := os.Getenv("INCLUDE_SKIPPED") == "true" + selectedTestName := os.Args[1] + + // check if our given test name actually exists + if selectedTestName != "" { + found := false + for _, test := range integration.Tests { + if test.Name() == selectedTestName { + found = true + break + } + } + if !found { + log.Fatalf("test %s not found. Perhaps you forgot to add it to `pkg/integration/integration_tests/tests.go`?", selectedTestName) + } + } + + err := integration.RunTestsNew( + log.Printf, + runCmdInTerminal, + func(test types.Test, f func(*testing.T) error) { + if selectedTestName != "" && test.Name() != selectedTestName { + return + } + if err := f(nil); err != nil { + log.Print(err.Error()) + } + }, + mode, + func(_t *testing.T, expected string, actual string, prefix string) { //nolint:thelper + assert.Equal(MockTestingT{}, expected, actual, fmt.Sprintf("Unexpected %s. Expected:\n%s\nActual:\n%s\n", prefix, expected, actual)) + }, + includeSkipped, + ) + if err != nil { + log.Print(err.Error()) + } +} + +type MockTestingT struct{} + +func (t MockTestingT) Errorf(format string, args ...interface{}) { + fmt.Printf(format, args...) +} + +func runCmdInTerminal(cmd *exec.Cmd) error { + cmd.Stdout = os.Stdout + cmd.Stdin = os.Stdin + cmd.Stderr = os.Stderr + + return cmd.Run() +} diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go index 03d3b3adc..0c76bfee7 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/vendor/github.com/jesseduffield/gocui/gui.go @@ -108,6 +108,8 @@ const ( NORMAL PlayMode = iota RECORDING REPLAYING + // for the new form of integration tests + REPLAYING_NEW ) type Recording struct { @@ -116,8 +118,8 @@ type Recording struct { } type replayedEvents struct { - keys chan *TcellKeyEventWrapper - resizes chan *TcellResizeEventWrapper + Keys chan *TcellKeyEventWrapper + Resizes chan *TcellResizeEventWrapper } type RecordingConfig struct { @@ -216,10 +218,10 @@ func NewGui(mode OutputMode, supportOverlaps bool, playMode PlayMode, headless b KeyEvents: []*TcellKeyEventWrapper{}, ResizeEvents: []*TcellResizeEventWrapper{}, } - } else if playMode == REPLAYING { + } else if playMode == REPLAYING || playMode == REPLAYING_NEW { g.ReplayedEvents = replayedEvents{ - keys: make(chan *TcellKeyEventWrapper), - resizes: make(chan *TcellResizeEventWrapper), + Keys: make(chan *TcellKeyEventWrapper), + Resizes: make(chan *TcellResizeEventWrapper), } } @@ -1420,7 +1422,7 @@ func (g *Gui) replayRecording() { case <-ticker.C: timeWaited += 1 if timeWaited >= timeToWait { - g.ReplayedEvents.keys <- event + g.ReplayedEvents.Keys <- event break middle } case <-g.stop: @@ -1453,7 +1455,7 @@ func (g *Gui) replayRecording() { case <-ticker.C: timeWaited += 1 if timeWaited >= timeToWait { - g.ReplayedEvents.resizes <- event + g.ReplayedEvents.Resizes <- event break middle2 } case <-g.stop: diff --git a/vendor/github.com/jesseduffield/gocui/tcell_driver.go b/vendor/github.com/jesseduffield/gocui/tcell_driver.go index c5555e30d..81d30fe91 100644 --- a/vendor/github.com/jesseduffield/gocui/tcell_driver.go +++ b/vendor/github.com/jesseduffield/gocui/tcell_driver.go @@ -232,11 +232,11 @@ func (g *Gui) timeSinceStart() int64 { // pollEvent get tcell.Event and transform it into gocuiEvent func (g *Gui) pollEvent() GocuiEvent { var tev tcell.Event - if g.PlayMode == REPLAYING { + if g.PlayMode == REPLAYING || g.PlayMode == REPLAYING_NEW { select { - case ev := <-g.ReplayedEvents.keys: + case ev := <-g.ReplayedEvents.Keys: tev = (ev).toTcellEvent() - case ev := <-g.ReplayedEvents.resizes: + case ev := <-g.ReplayedEvents.Resizes: tev = (ev).toTcellEvent() } } else {