summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-10-05 21:00:31 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-10-10 00:23:01 +1100
commit2724f3888a288aed1d5075465e7905cff1b8923e (patch)
tree987e7572ea4c39f39c6b4d578774b9634b26ff42
parentdc953ea680ce2023459b9f4bf72f5ca423fb9c95 (diff)
fix CI
-rw-r--r--pkg/gui/gui_test.go29
-rw-r--r--test/integration/mergeConflicts/snapshot.txt32
2 files changed, 31 insertions, 30 deletions
diff --git a/pkg/gui/gui_test.go b/pkg/gui/gui_test.go
index b7c652a99..cff8bce66 100644
--- a/pkg/gui/gui_test.go
+++ b/pkg/gui/gui_test.go
@@ -20,8 +20,8 @@ import (
// 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
//
-// To update a snapshot for an integration test, pass UPDATE_SNAPSHOT=true
-// UPDATE_SNAPSHOT=true 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
//
// When RECORD_EVENTS is true, updates will be updated automatically
//
@@ -71,7 +71,7 @@ func tests() []integrationTest {
func generateSnapshot(t *testing.T) string {
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)
assert.NoError(t, err)
@@ -103,12 +103,21 @@ func Test(t *testing.T) {
panic(err)
}
+ record := os.Getenv("RECORD_EVENTS") != ""
+ updateSnapshots := record || os.Getenv("UPDATE_SNAPSHOTS") != ""
+
for _, test := range tests {
test := test
+
t.Run(test.name, func(t *testing.T) {
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 {
- 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)
findOrCreateDir(testPath)
@@ -123,14 +132,11 @@ func Test(t *testing.T) {
err = createFixture(rootDir, test.fixture)
assert.NoError(t, err)
- record := os.Getenv("RECORD_EVENTS") != ""
runLazygit(t, testPath, rootDir, record, speed)
- updateSnapshot := record || os.Getenv("UPDATE_SNAPSHOT") != ""
-
actual := generateSnapshot(t)
- if updateSnapshot {
+ if updateSnapshots {
err := ioutil.WriteFile(snapshotPath, []byte(actual), 0600)
assert.NoError(t, err)
}
@@ -154,7 +160,7 @@ func Test(t *testing.T) {
func createFixture(rootDir string, name string) error {
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 {
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})
assert.NoError(t, err)
- _, err = io.Copy(os.Stdout, f)
+ _, _ = io.Copy(ioutil.Discard, f)
+
assert.NoError(t, err)
+
+ _ = f.Close()
} else {
err := osCommand.RunExecutable(cmd)
assert.NoError(t, err)
diff --git a/test/integration/mergeConflicts/snapshot.txt b/test/integration/mergeConflicts/snapshot.txt
index 3d1d1e31d..64d10d668 100644
--- a/test/integration/mergeConflicts/snapshot.txt
+++ b/test/integration/mergeConflicts/snapshot.txt
@@ -1,9 +1,7 @@
On branch other_branch
nothing to commit, working tree clean
cat: ./directory: Is a directory
-new1
-original2
-original3
+new1\noriginal2\noriginal3
Here is a story that has been told throuhg the ages
once upon a time there was a cat
...
@@ -76,38 +74,32 @@ asd
diff --git a/file b/file
-index 37ec558..51c0b8a 100644
+index 5da4d92..2410ee1 100644
--- a/file
+++ b/file
-@@ -1,3 +1,3 @@
--original1
-+new2
- original2
- original3
+@@ -1 +1 @@
+-original1\noriginal2\noriginal3
++new2\noriginal2\noriginal3
file changed
diff --git a/file b/file
-index 37ec558..fa90625 100644
+index 5da4d92..173a40e 100644
--- a/file
+++ b/file
-@@ -1,3 +1,3 @@
--original1
-+new1
- original2
- original3
+@@ -1 +1 @@
+-original1\noriginal2\noriginal3
++new1\noriginal2\noriginal3
file
diff --git a/file b/file
new file mode 100644
-index 0000000..37ec558
+index 0000000..5da4d92
--- /dev/null
+++ b/file
-@@ -0,0 +1,3 @@
-+original1
-+original2
-+original3
+@@ -0,0 +1 @@
++original1\noriginal2\noriginal3
fourth commit on master