diff options
Diffstat (limited to 'pkg/integration/components')
-rw-r--r-- | pkg/integration/components/paths.go | 7 | ||||
-rw-r--r-- | pkg/integration/components/runner.go | 19 | ||||
-rw-r--r-- | pkg/integration/components/test.go | 38 |
3 files changed, 37 insertions, 27 deletions
diff --git a/pkg/integration/components/paths.go b/pkg/integration/components/paths.go index bacc96f81..d100e91fe 100644 --- a/pkg/integration/components/paths.go +++ b/pkg/integration/components/paths.go @@ -27,13 +27,6 @@ func (self Paths) ActualRepo() string { return filepath.Join(self.Actual(), "repo") } -// When an integration test first runs, we copy everything in the 'actual' directory, -// and copy it into the 'expected' directory so that future runs can be compared -// against what we expect. -func (self Paths) Expected() string { - return filepath.Join(self.root, "expected") -} - func (self Paths) Config() string { return filepath.Join(self.root, "used_config") } diff --git a/pkg/integration/components/runner.go b/pkg/integration/components/runner.go index 32acdf25f..908d7e1d8 100644 --- a/pkg/integration/components/runner.go +++ b/pkg/integration/components/runner.go @@ -6,9 +6,11 @@ import ( "os/exec" "path/filepath" - "github.com/jesseduffield/lazycore/pkg/utils" + lazycoreUtils "github.com/jesseduffield/lazycore/pkg/utils" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/utils" + "github.com/samber/lo" ) const ( @@ -30,7 +32,7 @@ func RunTests( keyPressDelay int, maxAttempts int, ) error { - projectRootDir := utils.GetLazyRootDirectory() + projectRootDir := lazycoreUtils.GetLazyRootDirectory() err := os.Chdir(projectRootDir) if err != nil { return err @@ -177,8 +179,17 @@ func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandb return nil, err } - cmdArgs := []string{tempLazygitPath(), "-debug", "--use-config-dir=" + paths.Config(), "--path=" + paths.ActualRepo()} - cmdArgs = append(cmdArgs, test.ExtraCmdArgs()...) + cmdArgs := []string{tempLazygitPath(), "-debug", "--use-config-dir=" + paths.Config()} + if !test.useCustomPath { + cmdArgs = append(cmdArgs, "--path="+paths.ActualRepo()) + } + resolvedExtraArgs := lo.Map(test.ExtraCmdArgs(), func(arg string, _ int) string { + return utils.ResolvePlaceholderString(arg, map[string]string{ + "actualPath": paths.Actual(), + "actualRepoPath": paths.ActualRepo(), + }) + }) + cmdArgs = append(cmdArgs, resolvedExtraArgs...) cmdObj := osCommand.Cmd.New(cmdArgs) diff --git a/pkg/integration/components/test.go b/pkg/integration/components/test.go index 130ce8774..af307beeb 100644 --- a/pkg/integration/components/test.go +++ b/pkg/integration/components/test.go @@ -35,10 +35,11 @@ type IntegrationTest struct { testDriver *TestDriver, keys config.KeybindingConfig, ) - gitVersion GitVersionRestriction - width int - height int - isDemo bool + gitVersion GitVersionRestriction + width int + height int + isDemo bool + useCustomPath bool } var _ integrationTypes.IntegrationTest = &IntegrationTest{} @@ -66,6 +67,10 @@ type NewIntegrationTestArgs struct { Height int // If true, this is not a test but a demo to be added to our docs IsDemo bool + // If true, the test won't invoke lazygit with the --path arg. + // Useful for when we're passing --git-dir and --work-tree (because --path is + // incompatible with those args) + UseCustomPath bool } type GitVersionRestriction struct { @@ -125,18 +130,19 @@ func NewIntegrationTest(args NewIntegrationTestArgs) *IntegrationTest { } return &IntegrationTest{ - name: name, - description: args.Description, - extraCmdArgs: args.ExtraCmdArgs, - extraEnvVars: args.ExtraEnvVars, - skip: args.Skip, - setupRepo: args.SetupRepo, - setupConfig: args.SetupConfig, - run: args.Run, - gitVersion: args.GitVersion, - width: args.Width, - height: args.Height, - isDemo: args.IsDemo, + name: name, + description: args.Description, + extraCmdArgs: args.ExtraCmdArgs, + extraEnvVars: args.ExtraEnvVars, + skip: args.Skip, + setupRepo: args.SetupRepo, + setupConfig: args.SetupConfig, + run: args.Run, + gitVersion: args.GitVersion, + width: args.Width, + height: args.Height, + isDemo: args.IsDemo, + useCustomPath: args.UseCustomPath, } } |