1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-25 12:24:47 +02:00
2022-08-13 13:55:08 +10:00

68 lines
1.4 KiB
Go

package main
import (
"log"
"os"
"os/exec"
"github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/lazygit/pkg/integration"
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
)
// see pkg/integration/README.md
// If invoked directly, you can specify tests to run by passing them as positional arguments.
func main() {
mode := integration.GetModeFromEnv()
includeSkipped := os.Getenv("INCLUDE_SKIPPED") == "true"
var testsToRun []*helpers.Test
if len(os.Args) > 1 {
outer:
for _, testName := range os.Args[1:] {
// check if our given test name actually exists
for _, test := range integration.Tests {
if test.Name() == testName {
testsToRun = append(testsToRun, test)
continue outer
}
}
log.Fatalf("test %s not found. Perhaps you forgot to add it to `pkg/integration/integration_tests/tests.go`?", testName)
}
} else {
testsToRun = integration.Tests
}
testNames := slices.Map(testsToRun, func(test *helpers.Test) string {
return test.Name()
})
err := integration.RunTestsNew(
log.Printf,
runCmdInTerminal,
func(test *helpers.Test, f func() error) {
if !slices.Contains(testNames, test.Name()) {
return
}
if err := f(); err != nil {
log.Print(err.Error())
}
},
mode,
includeSkipped,
)
if err != nil {
log.Print(err.Error())
}
}
func runCmdInTerminal(cmd *exec.Cmd) error {
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
return cmd.Run()
}