mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Set working directory in lazygit test command
We need to fetch our list of tests both outside of our test binary and within. We need to get the list from within so that we can run the code that drives the test and runs assertions. To get the list of tests we need to know where the root of the lazygit repo is, given that the tests live in files under that root. So far, we've used this GetLazyRootDirectory() function for that, but it assumes that we're not in a test directory (it just looks for the first .git dir it can find). Because we didn't want to properly fix this before, we've been setting the working directory of the test command to the lazygit root, and using the --path CLI arg to override it when the test itself ran. This was a terrible hack. Now, we're passing the lazygit root directory as an env var to the integration test, so that we can set the working directory to the actual path of the test repo; removing the need to use the --path arg.
This commit is contained in:
@ -35,11 +35,10 @@ type IntegrationTest struct {
|
||||
testDriver *TestDriver,
|
||||
keys config.KeybindingConfig,
|
||||
)
|
||||
gitVersion GitVersionRestriction
|
||||
width int
|
||||
height int
|
||||
isDemo bool
|
||||
useCustomPath bool
|
||||
gitVersion GitVersionRestriction
|
||||
width int
|
||||
height int
|
||||
isDemo bool
|
||||
}
|
||||
|
||||
var _ integrationTypes.IntegrationTest = &IntegrationTest{}
|
||||
@ -55,9 +54,9 @@ type NewIntegrationTestArgs struct {
|
||||
Run func(t *TestDriver, keys config.KeybindingConfig)
|
||||
// additional args passed to lazygit
|
||||
ExtraCmdArgs []string
|
||||
// for when a test is flakey
|
||||
ExtraEnvVars map[string]string
|
||||
Skip bool
|
||||
// for when a test is flakey
|
||||
Skip bool
|
||||
// to run a test only on certain git versions
|
||||
GitVersion GitVersionRestriction
|
||||
// width and height when running in headless mode, for testing
|
||||
@ -67,10 +66,6 @@ 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 {
|
||||
@ -130,19 +125,18 @@ 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,
|
||||
useCustomPath: args.UseCustomPath,
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user