submodule test invocation: only pass additional arguments

In a later patch we want to introduce a config option to trigger the submodule recursing by default. As this option should be available and uniform across all commands that deal with submodules we'd want to test for this option in the submodule update library. So instead of calling the whole test set again for "git -c submodule.recurse foo" instead of "git foo --recurse-submodules", we'd only want to introduce one basic test that tests if the option is recognized and respected to not overload the test suite. Change the test functions by taking only the argument and assemble the command inside the test function by embedding the arguments into the command that is "git $arguments --recurse-submodules". It would be nice to do this for all functions in lib-submodule-update, but we cannot do that for the non-recursing tests, as there we do not just pass in a git command but whole functions. (See t3426 for example) Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed May 26, 2017 at 12:10 UTC 17f38cb704623561fb4efd143429d63149f585d8
4 files changed +12 -10
t/lib-submodule-update.sh
+6 -4
@@ -781,8 +781,9 @@ test_submodule_forced_switch () {
781 # - Removing a submodule with a git directory absorbs the submodules
782 # git directory first into the superproject.
783
784 -test_submodule_switch_recursing () {
785 - command="$1"
784 +test_submodule_switch_recursing_with_args () {
785 + cmd_args="$1"
786 + command="git $cmd_args --recurse-submodules"
787 RESULTDS=success
788 if test "$KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS" = 1
789 then
@@ -1021,8 +1022,9 @@ test_submodule_switch_recursing () {
1022 # Test that submodule contents are updated when switching between commits
1023 # that change a submodule, but throwing away local changes in
1024 # the superproject as well as the submodule is allowed.
1024 -test_submodule_forced_switch_recursing () {
1025 - command="$1"
1025 +test_submodule_forced_switch_recursing_with_args () {
1026 + cmd_args="$1"
1027 + command="git $cmd_args --recurse-submodules"
1028 RESULT=success
1029 if test "$KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS" = 1
1030 then
t/t1013-read-tree-submodule.sh
+2 -2
@@ -9,9 +9,9 @@ KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
9 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
10 KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED=1
11
12 -test_submodule_switch_recursing "git read-tree --recurse-submodules -u -m"
12 +test_submodule_switch_recursing_with_args "read-tree -u -m"
13
14 -test_submodule_forced_switch_recursing "git read-tree --recurse-submodules -u --reset"
14 +test_submodule_forced_switch_recursing_with_args "read-tree -u --reset"
15
16 test_submodule_switch "git read-tree -u -m"
17
t/t2013-checkout-submodule.sh
+2 -2
@@ -65,9 +65,9 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/
65
66 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
67 KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
68 -test_submodule_switch_recursing "git checkout --recurse-submodules"
68 +test_submodule_switch_recursing_with_args "checkout"
69
70 -test_submodule_forced_switch_recursing "git checkout -f --recurse-submodules"
70 +test_submodule_forced_switch_recursing_with_args "checkout -f"
71
72 test_submodule_switch "git checkout"
73
t/t7112-reset-submodule.sh
+2 -2
@@ -9,9 +9,9 @@ KNOWN_FAILURE_SUBMODULE_RECURSIVE_NESTED=1
9 KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
10 KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED=1
11
12 -test_submodule_switch_recursing "git reset --recurse-submodules --keep"
12 +test_submodule_switch_recursing_with_args "reset --keep"
13
14 -test_submodule_forced_switch_recursing "git reset --hard --recurse-submodules"
14 +test_submodule_forced_switch_recursing_with_args "reset --hard"
15
16 test_submodule_switch "git reset --keep"
17