-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set working directory in lazygit test command #3215
Set working directory in lazygit test command #3215
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesYou may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation |
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.
5c6d22f
to
8c71618
Compare
14b8f98
to
6c4ca54
Compare
For some bizarre reason `pkg/integration/tests/filter_by_path/cli_arg.go` is failing as of 8c71618 like so: ``` test_lazygit Usage: test_lazygit [git-arg] Positional Variables: git-arg Panel to focus upon opening lazygit. Accepted values (based on git terminology): status, branch, log, stash. Ignored if --filter arg is passed. Flags: -h --help Displays help with available flag, subcommand, and positional value parameters. -p --path Path of git repo. (equivalent to --work-tree=<path> --git-dir=<path>/.git/) -f --filter Path to filter on in `git log -- <path>`. When in filter mode, the commits, reflog, and stash are filtered based on the given path, and some operations are restricted -v --version Print the current version -d --debug Run in debug mode with logging (see --logs flag below). Use the LOG_LEVEL env var to set the log level (debug/info/warn/error) (default: false) -l --logs Tail lazygit logs (intended to be used when `lazygit --debug` is called in a separate terminal tab) -c --config Print the default config -cd --print-config-dir Print the config directory -ucd --use-config-dir override default config directory with provided directory -w --work-tree equivalent of the --work-tree git argument -g --git-dir equivalent of the --git-dir git argument -ucf --use-config-file Comma separated list to custom config file(s) Unknown arguments supplied: filterFile ``` where the CLI args are: ``` ([]string) (len=5 cap=5) { (string) (len=25) "/tmp/lazygit/test_lazygit", (string) (len=6) "-debug", (string) (len=108) "--use-config-dir=/Users/jesseduffieldduffield/repos/lazygit/test/_results/filter_by_path/cli_arg/used_config", (string) (len=2) "-f", (string) (len=10) "filterFile" } ``` This appears to be a bug in flaggy itself. I've updated to the latest version but it still breaks. Bizarrely it works fine on CI and only fails locally. Running lazygit locally with `lg -f pkg/gui/controllers/helpers/refresh_helper.go` it works fine. So I don't know what's going on there. At any rate, I'm just going to get the test passing by passing `-f=filterFile` as a single argument.
6c4ca54
to
a1ce602
Compare
I'm just gonna merge this because it's low stakes if it has issues |
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.
PR Description
Please check if the PR fulfills these requirements
go generate ./...
)docs/Config.md
) have been updated if necessary