{"thread":{"id":"24344","subject":"[PATCH] test-lib: simplify GIT_SKIP_TESTS loop","startedAt":"2010-07-09T10:01:28Z","lastAt":"2010-07-12T10:32:18Z","messageCount":3,"participants":["Michael J Gruber","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"145200","messageId":"0f97dc0377b97675f45b568254dabefb5b1e0146.1278669505.git.git@drmicha.warpmail.net","threadId":"24344","inReplyTo":null,"subject":"[PATCH] test-lib: simplify GIT_SKIP_TESTS loop","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-07-09T10:01:28Z","receivedAt":"2010-07-09T10:01:28Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"04ece59 (GIT_SKIP_TESTS: allow users to omit tests that are known to break, 2006-12-28)\nintroduced GIT_SKIP_TESTS, and since then we have had two nested loops\niterating over GIT_SKIP_TESTS with the same loop variable.\n\nReduce this to one loop.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nI am probably making a complete shell fool out of myself by overlooking\nsomething completely trivial.\n\nBut just in case I am not, this reduces the loop from O(N^2) to O(N), although\nI do admit that N is typically not that large...\n(Note that the inner $skp does not overwrite the outer one, at least not with bash.)\n\n t/test-lib.sh |   23 ++++++++++-------------\n 1 files changed, 10 insertions(+), 13 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex ac496aa..8e3de53 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -827,23 +827,20 @@ cd -P \"$test\" || exit 1\n \n this_test=${0##*/}\n this_test=${this_test%%-*}\n+to_skip=\n for skp in $GIT_SKIP_TESTS\n do\n-\tto_skip=\n-\tfor skp in $GIT_SKIP_TESTS\n-\tdo\n-\t\tcase \"$this_test\" in\n-\t\t$skp)\n-\t\t\tto_skip=t\n-\t\tesac\n-\tdone\n-\tcase \"$to_skip\" in\n-\tt)\n-\t\tsay_color skip >&3 \"skipping test $this_test altogether\"\n-\t\tsay_color skip \"skip all tests in $this_test\"\n-\t\ttest_done\n+\tcase \"$this_test\" in\n+\t$skp)\n+\t\tto_skip=t\n \tesac\n done\n+case \"$to_skip\" in\n+t)\n+\tsay_color skip >&3 \"skipping test $this_test altogether\"\n+\tsay_color skip \"skip all tests in $this_test\"\n+\ttest_done\n+esac\n \n # Provide an implementation of the 'yes' utility\n yes () {\n-- \n1.7.2.rc1.212.g850a\n"},{"id":"145248","messageId":"7v7hl4l0du.fsf@alter.siamese.dyndns.org","threadId":"24344","inReplyTo":"0f97dc0377b97675f45b568254dabefb5b1e0146.1278669505.git.git@drmicha.warpmail.net","subject":"Re: [PATCH] test-lib: simplify GIT_SKIP_TESTS loop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-09T23:07:57Z","receivedAt":"2010-07-09T23:07:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> I am probably making a complete shell fool out of myself by overlooking\n> something completely trivial.\n\nI don't think so.  I don't know what the double-loop is trying to achieve\nmyself.\n\nWe could even lose to_skip variable and the call to test_done inside the\ncase statement, perhaps like this.\n\nThanks.\n\n t/test-lib.sh |   13 +++----------\n 1 files changed, 3 insertions(+), 10 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex ac496aa..bc06564 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -385,6 +385,7 @@ test_skip () {\n \t\tcase $this_test.$test_count in\n \t\t$skp)\n \t\t\tto_skip=t\n+\t\t\tbreak\n \t\tesac\n \tdone\n \tif test -z \"$to_skip\" && test -n \"$prereq\" &&\n@@ -829,16 +830,8 @@ this_test=${0##*/}\n this_test=${this_test%%-*}\n for skp in $GIT_SKIP_TESTS\n do\n-\tto_skip=\n-\tfor skp in $GIT_SKIP_TESTS\n-\tdo\n-\t\tcase \"$this_test\" in\n-\t\t$skp)\n-\t\t\tto_skip=t\n-\t\tesac\n-\tdone\n-\tcase \"$to_skip\" in\n-\tt)\n+\tcase \"$this_test\" in\n+\t$skp)\n \t\tsay_color skip >&3 \"skipping test $this_test altogether\"\n \t\tsay_color skip \"skip all tests in $this_test\"\n \t\ttest_done\n"},{"id":"145358","messageId":"89ce8052aa4bd464b7f7edcd3e6e9d0c9edc9862.1278930328.git.git@drmicha.warpmail.net","threadId":"24344","inReplyTo":"7v7hl4l0du.fsf@alter.siamese.dyndns.org","subject":"[PATCHv2] test-lib: simplify GIT_SKIP_TESTS loop","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-07-12T10:32:18Z","receivedAt":"2010-07-12T10:32:18Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"04ece59 (GIT_SKIP_TESTS: allow users to omit tests that are known to break, 2006-12-28)\nintroduced GIT_SKIP_TESTS, and since then we have had two nested loops\niterating over GIT_SKIP_TESTS with the same loop variable.\n\nReduce this to one loop.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nv2 is simplified even more and is really Junio's patch.\n\n t/test-lib.sh |   13 +++----------\n 1 files changed, 3 insertions(+), 10 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex ac496aa..bc06564 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -385,6 +385,7 @@ test_skip () {\n \t\tcase $this_test.$test_count in\n \t\t$skp)\n \t\t\tto_skip=t\n+\t\t\tbreak\n \t\tesac\n \tdone\n \tif test -z \"$to_skip\" && test -n \"$prereq\" &&\n@@ -829,16 +830,8 @@ this_test=${0##*/}\n this_test=${this_test%%-*}\n for skp in $GIT_SKIP_TESTS\n do\n-\tto_skip=\n-\tfor skp in $GIT_SKIP_TESTS\n-\tdo\n-\t\tcase \"$this_test\" in\n-\t\t$skp)\n-\t\t\tto_skip=t\n-\t\tesac\n-\tdone\n-\tcase \"$to_skip\" in\n-\tt)\n+\tcase \"$this_test\" in\n+\t$skp)\n \t\tsay_color skip >&3 \"skipping test $this_test altogether\"\n \t\tsay_color skip \"skip all tests in $this_test\"\n \t\ttest_done\n-- \n1.7.2.rc1.212.g850a\n"}]}