trailer tests: make test cases self-contained
commit84e53330f0433b35057ff70dd856494f9970dda9
authorLinus Arver <linusa@google.com>
Thu, 7 Sep 2023 22:19:57 +0000 (7 22:19 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Sep 2023 06:03:57 +0000 (7 23:03 -0700)
treefc22898d092ca95e3586a27096cfd6e8f58ab086
parentac83bc5054c2ac489166072334b4147ce6d0fccb
trailer tests: make test cases self-contained

By using "test_config" instead of "git config", we avoid leaking
configuration state across test cases. This in turn helps to make the
tests more self-contained, by explicitly capturing the configuration
setup. It then makes it easier to add tests anywhere in this 1500+ line
file, without worrying about what implicit state was set in some prior
test case defined earlier up in the script.

This commit was created mechanically as follows: we changed the first
occurrence of a particular "git config trailer.*" option, then ran the
tests repeatedly to see which ones broke, adding in the extra
"test_config" equivalents to make them pass again. In addition, in some
test cases we removed "git config --unset ..." lines because they were
no longer necessary (as the --unset was being used to clean up leaked
configuration state from earlier test cases).

The process described above was done repeatedly until there were no more
unbridled "git config" invocations. Some "git config" invocations still
do exist in the script, but they were already cleaned up properly with

    test_when_finished "git config --remove-section ..."

so they were left alone.

Note that these cleanups result in generally longer test case setups
because the previously hidden state is now being exposed. Although we
could then clean up the test cases' "expected" values to be less
verbose (the verbosity arising from the use of implicit state), we
choose not to do so here, to make sure that this cleanup does not change
any meanings behind the test cases.

Signed-off-by: Linus Arver <linusa@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7513-interpret-trailers.sh