1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00
This commit is contained in:
Jesse Duffield
2022-08-11 21:28:55 +10:00
parent 1ef6f4c0e1
commit 610eddfe05
15 changed files with 64 additions and 40 deletions

View File

@@ -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 {

View File

@@ -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

View File

@@ -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
}

View File

@@ -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]
}