{"thread":{"id":"60374","subject":"[PATCH] t/t7601: Modernize test scripts using functions","startedAt":"2023-10-16T15:21:41Z","lastAt":"2023-10-16T16:53:58Z","messageCount":2,"participants":["Dorcas AnonoLitunya","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"483308","messageId":"20231016152113.135970-1-anonolitunya@gmail.com","threadId":"60374","inReplyTo":null,"subject":"[PATCH] t/t7601: Modernize test scripts using functions","fromName":"Dorcas AnonoLitunya","fromEmail":"anonolitunya@gmail.com","sentAt":"2023-10-16T15:21:00Z","receivedAt":"2023-10-16T15:21:41Z","isPatch":true,"sender":{"key":"anonolitunya@gmail.com","avatar":"https://avatars.githubusercontent.com/u/36160963?v=4"},"body":"The test script is currently using the command format 'test -f' to\ncheck for existence or absence of files.\n\nReplace it with new helper functions following the format\n'test_path_is_file'.\n\nConsequently, the patch also replaces the inverse command '! test -f' or\n'test ! -f' with new helper function following the format\n'test_path_is_missing'\n\nThis adjustment using helper functions makes the code more readable and\neasier to understand.\n\nSigned-off-by: Dorcas AnonoLitunya <anonolitunya@gmail.com>\n---\n t/t7601-merge-pull-config.sh | 24 ++++++++++++------------\n 1 file changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh\nindex bd238d89b0..e08767df66 100755\n--- a/t/t7601-merge-pull-config.sh\n+++ b/t/t7601-merge-pull-config.sh\n@@ -349,13 +349,13 @@ test_expect_success 'Cannot rebase with multiple heads' '\n \n test_expect_success 'merge c1 with c2' '\n \tgit reset --hard c1 &&\n-\ttest -f c0.c &&\n-\ttest -f c1.c &&\n-\ttest ! -f c2.c &&\n-\ttest ! -f c3.c &&\n+\ttest_path_is_file c0.c &&\n+\ttest_path_is_file c1.c &&\n+\ttest_path_is_missing c2.c &&\n+\ttest_path_is_missing c3.c &&\n \tgit merge c2 &&\n-\ttest -f c1.c &&\n-\ttest -f c2.c\n+\ttest_path_is_file c1.c &&\n+\ttest_path_is_file c2.c\n '\n \n test_expect_success 'fast-forward pull succeeds with \"true\" in pull.ff' '\n@@ -411,8 +411,8 @@ test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '\n \tgit reset --hard c1 &&\n \tgit config pull.twohead ours &&\n \tgit merge c2 &&\n-\ttest -f c1.c &&\n-\t! test -f c2.c\n+\ttest_path_is_file c1.c &&\n+\ttest_path_is_missing c2.c\n '\n \n test_expect_success 'merge c1 with c2 and c3 (recursive in pull.octopus)' '\n@@ -431,10 +431,10 @@ test_expect_success 'merge c1 with c2 and c3 (recursive and octopus in pull.octo\n \ttest \"$(git rev-parse c2)\" = \"$(git rev-parse HEAD^2)\" &&\n \ttest \"$(git rev-parse c3)\" = \"$(git rev-parse HEAD^3)\" &&\n \tgit diff --exit-code &&\n-\ttest -f c0.c &&\n-\ttest -f c1.c &&\n-\ttest -f c2.c &&\n-\ttest -f c3.c\n+\ttest_path_is_file c0.c &&\n+\ttest_path_is_file c1.c &&\n+\ttest_path_is_file c2.c &&\n+\ttest_path_is_file c3.c\n '\n \n conflict_count()\n-- \n2.42.0.345.gaab89be2eb\n\n"},{"id":"483313","messageId":"xmqq1qdumrto.fsf@gitster.g","threadId":"60374","inReplyTo":"20231016152113.135970-1-anonolitunya@gmail.com","subject":"Re: [PATCH] t/t7601: Modernize test scripts using functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-10-16T16:53:55Z","receivedAt":"2023-10-16T16:53:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dorcas AnonoLitunya <anonolitunya@gmail.com> writes:\n\n> Subject: Re: [PATCH] t/t7601: Modernize test scripts using functions\n\nLet's try if we can pack a bit more information.  For example\n\nSubject: [PATCH] t7601: use \"test_path_is_file\" etc. instead of \"test -f\"\n\nwould clarify what kind of modernization is done by this patch.\n\n> The test script is currently using the command format 'test -f' to\n> check for existence or absence of files.\n\n\"is currently using\" -> \"uses\".\n\n> Replace it with new helper functions following the format\n> 'test_path_is_file'.\n\nI am not sure what role \"the format\" plays in this picture.\ntest_path_is_file is not new---it has been around for quite a while.\n\n> Consequently, the patch also replaces the inverse command '! test -f' or\n> 'test ! -f' with new helper function following the format\n> 'test_path_is_missing'\n\nA bit more on this later.\n\n> This adjustment using helper functions makes the code more readable and\n> easier to understand.\n\nLooking good.  If I were writing this, I'll make the whole thing\nmore like this, though:\n\n    t7601: use \"test_path_is_file\" etc. instead of \"test -f\"\n\n    Some tests in t7601 use \"test -f\" and \"test ! -f\" to see if a\n    path exists or is missing.  Use test_path_is_file and\n    test_path_is_missing helper functions to clarify these tests a\n    bit better.  This especially matters for the \"missing\" case,\n    because \"test ! -f F\" will be happy if \"F\" exists as a\n    directory, but the intent of the test is that \"F\" should not\n    exist, even as a directory.\n\n\n> diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh\n> index bd238d89b0..e08767df66 100755\n> --- a/t/t7601-merge-pull-config.sh\n> +++ b/t/t7601-merge-pull-config.sh\n> @@ -349,13 +349,13 @@ test_expect_success 'Cannot rebase with multiple heads' '\n>  \n>  test_expect_success 'merge c1 with c2' '\n>  \tgit reset --hard c1 &&\n> -\ttest -f c0.c &&\n> -\ttest -f c1.c &&\n> -\ttest ! -f c2.c &&\n> -\ttest ! -f c3.c &&\n> +\ttest_path_is_file c0.c &&\n> +\ttest_path_is_file c1.c &&\n> +\ttest_path_is_missing c2.c &&\n> +\ttest_path_is_missing c3.c &&\n\nThe original says \"We are happy if c2.c is not a file\", so it would\nhave been happy if by some mistake \"git reset\" created a directory\nthere.  But the _intent_ of the test is that we do not have anything\nat c2.c, and the updated code expresses it better.\n"}]}