git-test icon indicating copy to clipboard operation
git-test copied to clipboard

Document environment variables exported + add a couple new

Open hlovdal opened this issue 3 years ago • 2 comments

Document the existing GIT_TEST_VERBOSITY and add two new GIT_TEST_NAME plus GIT_TEST_PREVIOUS_CHECKED_OUT_COMMIT.

I think the last one should be able to solve issue #13. Not automatically out of the box like requested, but it provides a framework to handle it (explicitly) in a more intelligent and optimal way than the alternative of just blindly doing it every single time.

On a fundamental level git submodules is a dependency external to the main repository (only a very special kind of dependency that is tightly integrated into git), but it really is not that different from other external dependencies like npm packages, ruby gems, python packages, etc whose used values can change from commit to commit. With GIT_TEST_PREVIOUS_CHECKED_OUT_COMMIT all such externally dependencies can be optimized to just update when needed.

And while the double if test for deciding to run npm install might look a bit gaudy, there is no need to inline it in every test. For all my typescript tests I just add a call to a script ./test-run-npm-install.sh and that's it.

hlovdal avatar Mar 14 '21 17:03 hlovdal

Branch rebased.

hlovdal avatar Aug 01 '21 22:08 hlovdal

@mhagger Are there any outstanding issues that prevents this PR from being merged?

hlovdal avatar Feb 05 '22 10:02 hlovdal

@hlovdal: sorry for my lack of response.

It would be preferable for the environment variables to be set only in the subcommand that is being run rather than in the git-test process itself. I think that this can be done by passing an env= parameter to check_output. If you'd like to make that change, I think that it would be an improvement. Let me know. Either way I'll merge this PR after I hear from you.

mhagger avatar Sep 19 '22 14:09 mhagger

I created a commit on a branch env_kwargs with what I think you ask for, but I am not sure if I think that is an improvement.

hlovdal avatar Sep 26 '22 22:09 hlovdal

Have you had any chance to look at the branch? Was it what you had in mind?

hlovdal avatar Nov 25 '22 14:11 hlovdal

Have you had any chance to look at the branch? Was it what you had in mind?

It's pretty close, but it is not a good idea to expose the full power of **kwargs through Test.run() and Test.run_and_record(). Also, passing env=dict to subprocess.check_call() sets the dictionary as the entire environment for the subcommand, meaning that it wouldn't include any values from the user's environment when they started git-test. Instead, one usually wants to start with os.environ then just tweak a couple of values.

I wrote up what I had in mind and was going to push it to my repo, but I accidentally pushed it to your branch here instead. (I'd forgotten that's even allowed!) Is that version OK with you?

mhagger avatar Nov 28 '22 12:11 mhagger

That looks good, I am satisfied with this. Don't worry about pushing to my branches, in general I am super comfortable in handling git conflicts so I would not have had any problems if it had come as a surprise, and in this case I am happy with the history being cleaner with just a commit directly from you instead of either an intermediate pull request or a cherry-pick by me.

hlovdal avatar Nov 28 '22 18:11 hlovdal

Thanks for the contribution and thanks for your patience!

mhagger avatar Nov 28 '22 19:11 mhagger