Re: [PATCH 1/2] t7900: adapt some tests to use a throwaway repository
Karthik Nayak <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <CAOLa=ZTVZh0_S+J57GVx-KHUr4hMyNFHQMrtjyNF5Q+Og7BiZA@mail.gmail.com> |
Patrick Steinhardt <[email protected]> writes: > Many of the tests in t7900 operate inside the main trash repository > that's set up by default by our test suite. This is overall quite > fragile as we're exercising repository maintenance in those tests, and > maintenance is of course intricately tied towards the on-disk state of a > repository. Consequently, the tests can easily impact one another. > > Furthermore, in the next commit we'll have to modify the environment in > a handful of those tests. As tests don't run in a subshell, doing so > would impact all subsequent tests by default, as well. > > Adapt exactly those tests to use a throwaway repository. This makes the > tests more neatly self-contained and allows us to trivially modify the > environment in the next commit. > > Signed-off-by: Patrick Steinhardt <[email protected]> > --- > t/t7900-maintenance.sh | 70 +++++++++++++++++++++++++++++++------------------- > 1 file changed, 43 insertions(+), 27 deletions(-) > > diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh > index 4238569b68..6735a9e082 100755 > --- a/t/t7900-maintenance.sh > +++ b/t/t7900-maintenance.sh > @@ -67,41 +67,57 @@ test_expect_success 'run [--auto|--quiet] with gc strategy' ' > ' > > test_expect_success 'maintenance.auto config option' ' > - GIT_TRACE2_EVENT="$(pwd)/default" git commit --quiet --allow-empty -m 1 && > - test_subcommand git maintenance run --auto --quiet --detach <default && > - GIT_TRACE2_EVENT="$(pwd)/true" \ > - git -c maintenance.auto=true \ > - commit --quiet --allow-empty -m 2 && > - test_subcommand git maintenance run --auto --quiet --detach <true && > - GIT_TRACE2_EVENT="$(pwd)/false" \ > - git -c maintenance.auto=false \ > - commit --quiet --allow-empty -m 3 && > - test_subcommand ! git maintenance run --auto --quiet --detach <false > + test_when_finished "rm -rf repo" && > + git init repo && > + ( > + cd repo && > + > + GIT_TRACE2_EVENT="$(pwd)/default" git commit --quiet --allow-empty -m 1 && > + test_subcommand git maintenance run --auto --quiet --detach <default && > + GIT_TRACE2_EVENT="$(pwd)/true" \ > + git -c maintenance.auto=true \ > + commit --quiet --allow-empty -m 2 && > + test_subcommand git maintenance run --auto --quiet --detach <true && > + GIT_TRACE2_EVENT="$(pwd)/false" \ > + git -c maintenance.auto=false \ > + commit --quiet --allow-empty -m 3 && > + test_subcommand ! git maintenance run --auto --quiet --detach <false > + ) > ' > > test_expect_success 'gc.auto config option' ' > - GIT_TRACE2_EVENT="$(pwd)/default" git commit --quiet --allow-empty -m 1 && > - test_subcommand git maintenance run --auto --quiet --detach <default && > - GIT_TRACE2_EVENT="$(pwd)/true" \ > - git -c gc.auto=1 commit --quiet --allow-empty -m 2 && > - test_subcommand git maintenance run --auto --quiet --detach <true && > - GIT_TRACE2_EVENT="$(pwd)/false" \ > - git -c gc.auto=0 commit --quiet --allow-empty -m 3 && > - test_subcommand ! git maintenance run --auto --quiet --detach <false > + test_when_finished "rm -rf repo" && > + git init repo && > + ( > + cd repo && > + > + GIT_TRACE2_EVENT="$(pwd)/default" git commit --quiet --allow-empty -m 1 && > + test_subcommand git maintenance run --auto --quiet --detach <default && > + GIT_TRACE2_EVENT="$(pwd)/true" \ > + git -c gc.auto=1 commit --quiet --allow-empty -m 2 && > + test_subcommand git maintenance run --auto --quiet --detach <true && > + GIT_TRACE2_EVENT="$(pwd)/false" \ > + git -c gc.auto=0 commit --quiet --allow-empty -m 3 && > + test_subcommand ! git maintenance run --auto --quiet --detach <false > + ) > ' > > test_expect_success 'maintenance.auto overrides gc.auto' ' > - test_when_finished "rm -f trace" && > + test_when_finished "rm -rf repo" && > + git init repo && > + ( > + cd repo && > > - test_config maintenance.auto false && > - test_config gc.auto 1 && > - GIT_TRACE2_EVENT="$(pwd)/trace" git commit --quiet --allow-empty -m 1 && > - test_subcommand ! git maintenance run --auto --quiet --detach <trace && > + git config set maintenance.auto false && > + git config set gc.auto 1 && So we change from using `test_config` to `git config`, I assume this is because earlier since we used a shared folder, we had to undo any config changes made. Now that's no longer needed. Nit: This is okay, but would've been nicer to call out. > + GIT_TRACE2_EVENT="$(pwd)/trace" git commit --quiet --allow-empty -m 1 && > + test_subcommand ! git maintenance run --auto --quiet --detach <trace && > > - test_config maintenance.auto true && > - test_config gc.auto 0 && > - GIT_TRACE2_EVENT="$(pwd)/trace" git commit --quiet --allow-empty -m 1 && > - test_subcommand git maintenance run --auto --quiet --detach <trace > + git config set maintenance.auto true && > + git config set gc.auto 0 && > + GIT_TRACE2_EVENT="$(pwd)/trace" git commit --quiet --allow-empty -m 1 && > + test_subcommand git maintenance run --auto --quiet --detach <trace > + ) > ' > > for cfg in maintenance.autoDetach gc.autoDetach > > -- > 2.55.0.679.g6767b8d81c.dirty The rest looks as expected.
signature.asc
(application/pgp-signature, 690 B)
-----BEGIN PGP SIGNATURE----- iQHKBAEBCgA0FiEEV85Mf2N1cQ/LZcYGPtWfJI5GjH8FAmp8LIQWHGthcnRoaWsu MTg4QGdtYWlsLmNvbQAKCRA+1Z8kjkaMfx4dC/43oIW/IFT8ypqg81rZWMvyQJH7 sO/bl9o8CEP3TfDKT0YrJAUvZiQxYXfgEXCh3BwkyVjvmmcalfHVWrY4svPqIKuZ E5SZqh6dOlnfYBy8ZmZ2PbKjjG5Abq3tBMRelum+dM0K+bDLH+4vCnBlCXRWbBAC 0SKlZvIt4rCQxVpZ5wdb89Q6/7pOPZi3uySvzafK2k8k8e58FzAB7vVjxGoLlw/T h55xX9zznmGb+bdihELmxHbMP31D97xRswFJVFqHCXZucsXQoZRtCdZptzad5gYF fRronjycqP0ozsSWeNuw8FhCxUVv++0rptHqWgst8jyebHTQ8u1qbXYsNpSU4FY8 jBAu+qq2KSRc50WqqhRWF9ZC3S1R78A2vw2k6MCPqEBsfUPAY3UtnJwqHKjmtuMS a4T83oRqGKtttcIOGopJq/rrNwLmKUTK/jbpxcJrn9YhnT5dY1i1Rb0LIEgrr7Qz XkCyuA2l3Q/GKbtjTC6GRxVzLjwNRwavm9EymF0= =vKlB -----END PGP SIGNATURE-----