mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-23 21:51:07 +02:00
fix CI
This commit is contained in:
parent
dc953ea680
commit
2724f3888a
@ -20,8 +20,8 @@ import (
|
|||||||
// To record keypresses for an integration test, pass RECORD_EVENTS=true like so:
|
// To record keypresses for an integration test, pass RECORD_EVENTS=true like so:
|
||||||
// RECORD_EVENTS=true go test pkg/gui/gui_test.go -run /commit
|
// RECORD_EVENTS=true go test pkg/gui/gui_test.go -run /commit
|
||||||
//
|
//
|
||||||
// To update a snapshot for an integration test, pass UPDATE_SNAPSHOT=true
|
// To update a snapshot for an integration test, pass UPDATE_SNAPSHOTS=true
|
||||||
// UPDATE_SNAPSHOT=true go test pkg/gui/gui_test.go -run /commit
|
// UPDATE_SNAPSHOTS=true go test pkg/gui/gui_test.go -run /commit
|
||||||
//
|
//
|
||||||
// When RECORD_EVENTS is true, updates will be updated automatically
|
// When RECORD_EVENTS is true, updates will be updated automatically
|
||||||
//
|
//
|
||||||
@ -71,7 +71,7 @@ func tests() []integrationTest {
|
|||||||
|
|
||||||
func generateSnapshot(t *testing.T) string {
|
func generateSnapshot(t *testing.T) string {
|
||||||
osCommand := oscommands.NewDummyOSCommand()
|
osCommand := oscommands.NewDummyOSCommand()
|
||||||
cmd := `sh -c "git status; cat ./*; git log --pretty=%B -p"`
|
cmd := `bash -c "git status; cat ./*; git log --pretty=%B -p"`
|
||||||
|
|
||||||
snapshot, err := osCommand.RunCommandWithOutput(cmd)
|
snapshot, err := osCommand.RunCommandWithOutput(cmd)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -103,12 +103,21 @@ func Test(t *testing.T) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
record := os.Getenv("RECORD_EVENTS") != ""
|
||||||
|
updateSnapshots := record || os.Getenv("UPDATE_SNAPSHOTS") != ""
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
test := test
|
test := test
|
||||||
|
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
speeds := []int{10, 5, 1}
|
speeds := []int{10, 5, 1}
|
||||||
|
if updateSnapshots {
|
||||||
|
// have to go at original speed if updating snapshots in case we go to fast and create a junk snapshot
|
||||||
|
speeds = []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
for i, speed := range speeds {
|
for i, speed := range speeds {
|
||||||
fmt.Printf("%s: trying again at speed %d\n", test.name, speed)
|
t.Logf("%s: attempting test at speed %d\n", test.name, speed)
|
||||||
|
|
||||||
testPath := filepath.Join(rootDir, "test", "integration", test.name)
|
testPath := filepath.Join(rootDir, "test", "integration", test.name)
|
||||||
findOrCreateDir(testPath)
|
findOrCreateDir(testPath)
|
||||||
@ -123,14 +132,11 @@ func Test(t *testing.T) {
|
|||||||
err = createFixture(rootDir, test.fixture)
|
err = createFixture(rootDir, test.fixture)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
record := os.Getenv("RECORD_EVENTS") != ""
|
|
||||||
runLazygit(t, testPath, rootDir, record, speed)
|
runLazygit(t, testPath, rootDir, record, speed)
|
||||||
|
|
||||||
updateSnapshot := record || os.Getenv("UPDATE_SNAPSHOT") != ""
|
|
||||||
|
|
||||||
actual := generateSnapshot(t)
|
actual := generateSnapshot(t)
|
||||||
|
|
||||||
if updateSnapshot {
|
if updateSnapshots {
|
||||||
err := ioutil.WriteFile(snapshotPath, []byte(actual), 0600)
|
err := ioutil.WriteFile(snapshotPath, []byte(actual), 0600)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
@ -154,7 +160,7 @@ func Test(t *testing.T) {
|
|||||||
|
|
||||||
func createFixture(rootDir string, name string) error {
|
func createFixture(rootDir string, name string) error {
|
||||||
osCommand := oscommands.NewDummyOSCommand()
|
osCommand := oscommands.NewDummyOSCommand()
|
||||||
cmd := exec.Command("sh", filepath.Join(rootDir, "test", "fixtures", fmt.Sprintf("%s.sh", name)))
|
cmd := exec.Command("bash", filepath.Join(rootDir, "test", "fixtures", fmt.Sprintf("%s.sh", name)))
|
||||||
|
|
||||||
if err := osCommand.RunExecutable(cmd); err != nil {
|
if err := osCommand.RunExecutable(cmd); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -226,8 +232,11 @@ func runLazygit(t *testing.T, testPath string, rootDir string, record bool, spee
|
|||||||
f, err := pty.StartWithSize(cmd, &pty.Winsize{Rows: 100, Cols: 100})
|
f, err := pty.StartWithSize(cmd, &pty.Winsize{Rows: 100, Cols: 100})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
_, err = io.Copy(os.Stdout, f)
|
_, _ = io.Copy(ioutil.Discard, f)
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
_ = f.Close()
|
||||||
} else {
|
} else {
|
||||||
err := osCommand.RunExecutable(cmd)
|
err := osCommand.RunExecutable(cmd)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
On branch other_branch
|
On branch other_branch
|
||||||
nothing to commit, working tree clean
|
nothing to commit, working tree clean
|
||||||
cat: ./directory: Is a directory
|
cat: ./directory: Is a directory
|
||||||
new1
|
new1\noriginal2\noriginal3
|
||||||
original2
|
|
||||||
original3
|
|
||||||
Here is a story that has been told throuhg the ages
|
Here is a story that has been told throuhg the ages
|
||||||
once upon a time there was a cat
|
once upon a time there was a cat
|
||||||
...
|
...
|
||||||
@ -76,38 +74,32 @@ asd
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/file b/file
|
diff --git a/file b/file
|
||||||
index 37ec558..51c0b8a 100644
|
index 5da4d92..2410ee1 100644
|
||||||
--- a/file
|
--- a/file
|
||||||
+++ b/file
|
+++ b/file
|
||||||
@@ -1,3 +1,3 @@
|
@@ -1 +1 @@
|
||||||
-original1
|
-original1\noriginal2\noriginal3
|
||||||
+new2
|
+new2\noriginal2\noriginal3
|
||||||
original2
|
|
||||||
original3
|
|
||||||
file changed
|
file changed
|
||||||
|
|
||||||
|
|
||||||
diff --git a/file b/file
|
diff --git a/file b/file
|
||||||
index 37ec558..fa90625 100644
|
index 5da4d92..173a40e 100644
|
||||||
--- a/file
|
--- a/file
|
||||||
+++ b/file
|
+++ b/file
|
||||||
@@ -1,3 +1,3 @@
|
@@ -1 +1 @@
|
||||||
-original1
|
-original1\noriginal2\noriginal3
|
||||||
+new1
|
+new1\noriginal2\noriginal3
|
||||||
original2
|
|
||||||
original3
|
|
||||||
file
|
file
|
||||||
|
|
||||||
|
|
||||||
diff --git a/file b/file
|
diff --git a/file b/file
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..37ec558
|
index 0000000..5da4d92
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/file
|
+++ b/file
|
||||||
@@ -0,0 +1,3 @@
|
@@ -0,0 +1 @@
|
||||||
+original1
|
+original1\noriginal2\noriginal3
|
||||||
+original2
|
|
||||||
+original3
|
|
||||||
fourth commit on master
|
fourth commit on master
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user