summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-08-11 21:28:55 +1000
committerJesse Duffield <jessedduffield@gmail.com>2022-08-13 13:55:09 +1000
commit610eddfe05cf68861bcfa1566d0d2d43aacab3fc (patch)
tree5bf0bfa66a92161f2a22f2fa952530ce3ab8a79e
parent1ef6f4c0e1f71d1285b9892b94c6e519d2739521 (diff)
fix CI
-rw-r--r--.github/workflows/ci.yml30
-rw-r--r--pkg/integration/deprecated/integration.go10
-rw-r--r--pkg/integration/deprecated/integration_test.go6
-rw-r--r--pkg/integration/deprecated/runner/main.go2
-rw-r--r--pkg/integration/deprecated/tui/main.go4
-rw-r--r--pkg/integration/helpers/test.go24
-rw-r--r--pkg/integration/integration.go6
-rw-r--r--pkg/integration/integration_test.go2
-rw-r--r--pkg/integration/runner/main.go6
-rw-r--r--pkg/integration/tests/branch/suggestions.go2
-rw-r--r--pkg/integration/tests/commit/commit.go2
-rw-r--r--pkg/integration/tests/commit/new_branch.go2
-rw-r--r--pkg/integration/tests/interactive_rebase/one.go2
-rw-r--r--pkg/integration/tests/tests.go2
-rw-r--r--pkg/integration/tui/main.go4
15 files changed, 64 insertions, 40 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5bf5ecfdf..c0b695e5b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -46,14 +46,38 @@ jobs:
# we're passing -short so that we skip the integration tests, which will be run in parallel below
run: |
go test ./... -short
- integration-tests:
+ integration-tests-old:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
parallelism: [5]
index: [0,1,2,3,4]
- name: "Integration Tests (${{ matrix.index }}/${{ matrix.parallelism }})"
+ name: "Integration Tests (Old pattern) (${{ matrix.index }}/${{ matrix.parallelism }})"
+ env:
+ GOFLAGS: -mod=vendor
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Setup Go
+ uses: actions/setup-go@v1
+ with:
+ go-version: 1.18.x
+ - name: Cache build
+ uses: actions/cache@v1
+ with:
+ path: |
+ ~/.cache/go-build
+ ~/go/pkg/mod
+ key: ${{runner.os}}-go-${{hashFiles('**/go.sum')}}-test
+ restore-keys: |
+ ${{runner.os}}-go-
+ - name: Test code
+ run: |
+ PARALLEL_TOTAL=${{ matrix.parallelism }} PARALLEL_INDEX=${{ matrix.index }} go test pkg/integration/deprecated/*.go
+ integration-tests:
+ runs-on: ubuntu-latest
+ name: "Integration Tests"
env:
GOFLAGS: -mod=vendor
steps:
@@ -74,7 +98,7 @@ jobs:
${{runner.os}}-go-
- name: Test code
run: |
- PARALLEL_TOTAL=${{ matrix.parallelism }} PARALLEL_INDEX=${{ matrix.index }} go test pkg/gui/gui_test.go
+ go test pkg/integration/*.go
build:
runs-on: ubuntu-latest
env:
diff --git a/pkg/integration/deprecated/integration.go b/pkg/integration/deprecated/integration.go
index 5f597fc81..92528b8ad 100644
--- a/pkg/integration/deprecated/integration.go
+++ b/pkg/integration/deprecated/integration.go
@@ -22,7 +22,7 @@ import (
// This package is for running our integration test suite. See https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.mdfor more info.
-type Test struct {
+type IntegrationTest struct {
Name string `json:"name"`
Speed float64 `json:"speed"`
Description string `json:"description"`
@@ -66,7 +66,7 @@ func GetModeFromEnv() Mode {
func RunTests(
logf func(format string, formatArgs ...interface{}),
runCmd func(cmd *exec.Cmd) error,
- fnWrapper func(test *Test, f func(*testing.T) error),
+ fnWrapper func(test *IntegrationTest, f func(*testing.T) error),
mode Mode,
speedEnv string,
onFail func(t *testing.T, expected string, actual string, prefix string),
@@ -315,13 +315,13 @@ func getTestSpeeds(testStartSpeed float64, mode Mode, speedStr string) []float64
return speeds
}
-func LoadTests(testDir string) ([]*Test, error) {
+func LoadTests(testDir string) ([]*IntegrationTest, error) {
paths, err := filepath.Glob(filepath.Join(testDir, "/*/test.json"))
if err != nil {
return nil, err
}
- tests := make([]*Test, len(paths))
+ tests := make([]*IntegrationTest, len(paths))
for i, path := range paths {
data, err := ioutil.ReadFile(path)
@@ -329,7 +329,7 @@ func LoadTests(testDir string) ([]*Test, error) {
return nil, err
}
- test := &Test{}
+ test := &IntegrationTest{}
err = json.Unmarshal(data, test)
if err != nil {
diff --git a/pkg/integration/deprecated/integration_test.go b/pkg/integration/deprecated/integration_test.go
index e66cc861a..fbec34bd9 100644
--- a/pkg/integration/deprecated/integration_test.go
+++ b/pkg/integration/deprecated/integration_test.go
@@ -16,7 +16,7 @@ import (
"github.com/stretchr/testify/assert"
)
-// Deprecated: this is the old way of running tests. See pkg/gui/gui_test.go for the new way.
+// Deprecated.
// 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
@@ -40,7 +40,7 @@ import (
// 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) {
+func Test(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration tests in short mode")
}
@@ -56,7 +56,7 @@ func TestOld(t *testing.T) {
err := RunTests(
t.Logf,
runCmdHeadless,
- func(test *Test, f func(*testing.T) error) {
+ func(test *IntegrationTest, f func(*testing.T) error) {
defer func() { testNumber += 1 }()
if testNumber%parallelTotal != parallelIndex {
return
diff --git a/pkg/integration/deprecated/runner/main.go b/pkg/integration/deprecated/runner/main.go
index 904cdbeab..82e4bb0a9 100644
--- a/pkg/integration/deprecated/runner/main.go
+++ b/pkg/integration/deprecated/runner/main.go
@@ -30,7 +30,7 @@ func main() {
err := deprecated.RunTests(
log.Printf,
runCmdInTerminal,
- func(test *deprecated.Test, f func(*testing.T) error) {
+ func(test *deprecated.IntegrationTest, f func(*testing.T) error) {
if selectedTestName != "" && test.Name != selectedTestName {
return
}
diff --git a/pkg/integration/deprecated/tui/main.go b/pkg/integration/deprecated/tui/main.go
index 9830f4229..80580ccff 100644
--- a/pkg/integration/deprecated/tui/main.go
+++ b/pkg/integration/deprecated/tui/main.go
@@ -19,14 +19,14 @@ import (
// this program lets you manage integration tests in a TUI. See https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md for more info.
type App struct {
- tests []*deprecated.Test
+ tests []*deprecated.IntegrationTest
itemIdx int
testDir string
editing bool
g *gocui.Gui
}
-func (app *App) getCurrentTest() *deprecated.Test {
+func (app *App) getCurrentTest() *deprecated.IntegrationTest {
if len(app.tests) > 0 {
return app.tests[app.itemIdx]
}
diff --git a/pkg/integration/helpers/test.go b/pkg/integration/helpers/test.go
index 972bb1d5b..fb876be7f 100644
--- a/pkg/integration/helpers/test.go
+++ b/pkg/integration/helpers/test.go
@@ -12,7 +12,7 @@ import (
// Test describes an integration tests that will be run against the lazygit gui.
-type Test struct {
+type IntegrationTest struct {
name string
description string
extraCmdArgs string
@@ -27,9 +27,9 @@ type Test struct {
)
}
-var _ integrationTypes.IntegrationTest = &Test{}
+var _ integrationTypes.IntegrationTest = &IntegrationTest{}
-type NewTestArgs struct {
+type NewIntegrationTestArgs struct {
// Briefly describes what happens in the test and what it's testing for
Description string
// prepares a repo for testing
@@ -44,8 +44,8 @@ type NewTestArgs struct {
Skip bool
}
-func NewTest(args NewTestArgs) *Test {
- return &Test{
+func NewIntegrationTest(args NewIntegrationTestArgs) *IntegrationTest {
+ return &IntegrationTest{
name: testNameFromFilePath(),
description: args.Description,
extraCmdArgs: args.ExtraCmdArgs,
@@ -56,32 +56,32 @@ func NewTest(args NewTestArgs) *Test {
}
}
-func (self *Test) Name() string {
+func (self *IntegrationTest) Name() string {
return self.name
}
-func (self *Test) Description() string {
+func (self *IntegrationTest) Description() string {
return self.description
}
-func (self *Test) ExtraCmdArgs() string {
+func (self *IntegrationTest) ExtraCmdArgs() string {
return self.extraCmdArgs
}
-func (self *Test) Skip() bool {
+func (self *IntegrationTest) Skip() bool {
return self.skip
}
-func (self *Test) SetupConfig(config *config.AppConfig) {
+func (self *IntegrationTest) SetupConfig(config *config.AppConfig) {
self.setupConfig(config)
}
-func (self *Test) SetupRepo(shell *Shell) {
+func (self *IntegrationTest) SetupRepo(shell *Shell) {
self.setupRepo(shell)
}
// I want access to all contexts, the model, the ability to press a key, the ability to log,
-func (self *Test) Run(gui integrationTypes.GuiAdapter) {
+func (self *IntegrationTest) Run(gui integrationTypes.GuiAdapter) {
shell := NewShell()
assert := NewAssert(gui)
keys := gui.Keys()
diff --git a/pkg/integration/integration.go b/pkg/integration/integration.go
index b479614c9..6227649e6 100644
--- a/pkg/integration/integration.go
+++ b/pkg/integration/integration.go
@@ -45,7 +45,7 @@ type (
func RunTests(
logf logf,
runCmd func(cmd *exec.Cmd) error,
- fnWrapper func(test *helpers.Test, f func() error),
+ fnWrapper func(test *helpers.IntegrationTest, f func() error),
mode Mode,
includeSkipped bool,
) error {
@@ -229,7 +229,7 @@ func compareSnapshots(logf logf, configDir string, actualDir string, expectedDir
return nil
}
-func createFixture(test *helpers.Test, actualDir string, rootDir string) error {
+func createFixture(test *helpers.IntegrationTest, actualDir string, rootDir string) error {
if err := os.Chdir(actualDir); err != nil {
panic(err)
}
@@ -249,7 +249,7 @@ func createFixture(test *helpers.Test, actualDir string, rootDir string) error {
return nil
}
-func getLazygitCommand(test *helpers.Test, testPath string, rootDir string) (*exec.Cmd, error) {
+func getLazygitCommand(test *helpers.IntegrationTest, testPath string, rootDir string) (*exec.Cmd, error) {
osCommand := oscommands.NewDummyOSCommand()
templateConfigDir := filepath.Join(rootDir, "test", "default_test_config")
diff --git a/pkg/integration/integration_test.go b/pkg/integration/integration_test.go
index 98001ac55..2c59b94df 100644
--- a/pkg/integration/integration_test.go
+++ b/pkg/integration/integration_test.go
@@ -34,7 +34,7 @@ func TestIntegration(t *testing.T) {
err := RunTests(
t.Logf,
runCmdHeadless,
- func(test *helpers.Test, f func() error) {
+ func(test *helpers.IntegrationTest, f func() error) {
defer func() { testNumber += 1 }()
if testNumber%parallelTotal != parallelIndex {
return
diff --git a/pkg/integration/runner/main.go b/pkg/integration/runner/main.go
index 739474f96..820df712a 100644
--- a/pkg/integration/runner/main.go
+++ b/pkg/integration/runner/main.go
@@ -17,7 +17,7 @@ import (
func main() {
mode := integration.GetModeFromEnv()
includeSkipped := os.Getenv("INCLUDE_SKIPPED") == "true"
- var testsToRun []*helpers.Test
+ var testsToRun []*helpers.IntegrationTest
if len(os.Args) > 1 {
outer:
@@ -35,14 +35,14 @@ func main() {
testsToRun = integration.Tests
}
- testNames := slices.Map(testsToRun, func(test *helpers.Test) string {
+ testNames := slices.Map(testsToRun, func(test *helpers.IntegrationTest) string {
return test.Name()
})
err := integration.RunTests(
log.Printf,
runCmdInTerminal,
- func(test *helpers.Test, f func() error) {
+ func(test *helpers.IntegrationTest, f func() error) {
if !slices.Contains(testNames, test.Name()) {
return
}
diff --git a/pkg/integration/tests/branch/suggestions.go b/pkg/integration/tests/branch/suggestions.go
index f4253cf82..33d0cf316 100644
--- a/pkg/integration/tests/branch/suggestions.go
+++ b/pkg/integration/tests/branch/suggestions.go
@@ -5,7 +5,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
)
-var Suggestions = helpers.NewTest(helpers.NewTestArgs{
+var Suggestions = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
Description: "Checking out a branch with name suggestions",
ExtraCmdArgs: "",
Skip: false,
diff --git a/pkg/integration/tests/commit/commit.go b/pkg/integration/tests/commit/commit.go
index 8aa0501e5..bbdcf5278 100644
--- a/pkg/integration/tests/commit/commit.go
+++ b/pkg/integration/tests/commit/commit.go
@@ -5,7 +5,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
)
-var Commit = helpers.NewTest(helpers.NewTestArgs{
+var Commit = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
Description: "Staging a couple files and committing",
ExtraCmdArgs: "",
Skip: false,
diff --git a/pkg/integration/tests/commit/new_branch.go b/pkg/integration/tests/commit/new_branch.go
index f3ba36e2d..419da6890 100644
--- a/pkg/integration/tests/commit/new_branch.go
+++ b/pkg/integration/tests/commit/new_branch.go
@@ -5,7 +5,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
)
-var NewBranch = helpers.NewTest(helpers.NewTestArgs{
+var NewBranch = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
Description: "Creating a new branch from a commit",
ExtraCmdArgs: "",
Skip: false,
diff --git a/pkg/integration/tests/interactive_rebase/one.go b/pkg/integration/tests/interactive_rebase/one.go
index 2b2acce37..69332c7de 100644
--- a/pkg/integration/tests/interactive_rebase/one.go
+++ b/pkg/integration/tests/interactive_rebase/one.go
@@ -5,7 +5,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
)
-var One = helpers.NewTest(helpers.NewTestArgs{
+var One = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
Description: "Begins an interactive rebase, then fixups, drops, and squashes some commits",
ExtraCmdArgs: "",
Skip: false,
diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go
index c2e360e43..dbd44470d 100644
--- a/pkg/integration/tests/tests.go
+++ b/pkg/integration/tests/tests.go
@@ -10,7 +10,7 @@ import (
// 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 = []*helpers.Test{
+var Tests = []*helpers.IntegrationTest{
commit.Commit,
commit.NewBranch,
branch.Suggestions,
diff --git a/pkg/integration/tui/main.go b/pkg/integration/tui/main.go
index af118918b..8b00c4951 100644
--- a/pkg/integration/tui/main.go
+++ b/pkg/integration/tui/main.go
@@ -18,14 +18,14 @@ import (
// this program lets you manage integration tests in a TUI. See pkg/integration/README.md for more info.
type App struct {
- tests []*helpers.Test
+ tests []*helpers.IntegrationTest
itemIdx int
testDir string
filtering bool
g *gocui.Gui
}
-func (app *App) getCurrentTest() *helpers.Test {
+func (app *App) getCurrentTest() *helpers.IntegrationTest {
if len(app.tests) > 0 {
return app.tests[app.itemIdx]
}