{"thread":{"id":"59746","subject":"[PATCH 1/3] tests: do not negate test_path_exists","startedAt":"2023-05-16T02:28:55Z","lastAt":"2023-05-16T16:11:44Z","messageCount":6,"participants":["Junio C Hamano","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"477334","messageId":"20230516022646.648123-2-gitster@pobox.com","threadId":"59746","inReplyTo":"20230516022646.648123-1-gitster@pobox.com","subject":"[PATCH 1/3] tests: do not negate test_path_exists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-05-16T02:26:44Z","receivedAt":"2023-05-16T02:28:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"As a way to assert the path 'foo' is missing, \"! test_path_exists foo\" a\npoor way to do so, as the helper is designed to complain when 'foo' is\nmissing, but the intention of the author who used negated form was to\nmake sure it does not exist.  This does not help debugging the tests.\n\nUse test_path_is_missing instead, which is a more appropriate helper.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t4067-diff-partial-clone.sh | 4 ++--\n t/t4115-apply-symlink.sh      | 2 +-\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t4067-diff-partial-clone.sh b/t/t4067-diff-partial-clone.sh\nindex f60f5cbd65..7af3a08862 100755\n--- a/t/t4067-diff-partial-clone.sh\n+++ b/t/t4067-diff-partial-clone.sh\n@@ -151,7 +151,7 @@ test_expect_success 'diff does not fetch anything if inexact rename detection is\n \n \t# Ensure no fetches.\n \tGIT_TRACE_PACKET=\"$(pwd)/trace\" git -C client diff --raw -M HEAD^ HEAD &&\n-\t! test_path_exists trace\n+\ttest_path_is_missing trace\n '\n \n test_expect_success 'diff --break-rewrites fetches only if necessary, and batches blobs if it does' '\n@@ -171,7 +171,7 @@ test_expect_success 'diff --break-rewrites fetches only if necessary, and batche\n \n \t# Ensure no fetches.\n \tGIT_TRACE_PACKET=\"$(pwd)/trace\" git -C client diff --raw -M HEAD^ HEAD &&\n-\t! test_path_exists trace &&\n+\ttest_path_is_missing trace &&\n \n \t# But with --break-rewrites, ensure that there is exactly 1 negotiation\n \t# by checking that there is only 1 \"done\" line sent. (\"done\" marks the\ndiff --git a/t/t4115-apply-symlink.sh b/t/t4115-apply-symlink.sh\nindex e95e6d4e7d..a22a90d552 100755\n--- a/t/t4115-apply-symlink.sh\n+++ b/t/t4115-apply-symlink.sh\n@@ -74,7 +74,7 @@ test_expect_success SYMLINKS 'symlink escape when creating new files' '\n \terror: affected file ${SQ}renamed-symlink/create-me${SQ} is beyond a symbolic link\n \tEOF\n \ttest_cmp expected_stderr stderr &&\n-\t! test_path_exists .git/create-me\n+\ttest_path_is_missing .git/create-me\n '\n \n test_expect_success SYMLINKS 'symlink escape when modifying file' '\n-- \n2.41.0-rc0\n\n"},{"id":"477335","messageId":"20230516022646.648123-1-gitster@pobox.com","threadId":"59746","inReplyTo":null,"subject":"[PATCH 0/3] fix use of \"! test_path_is_foo\" in tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-05-16T02:26:43Z","receivedAt":"2023-05-16T02:28:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"During recent review of a topic, I noticed that there are a handful\nof places where we misuse test_path_is_{file,directory} test helper\nfunctions.  They are designed to be silent when the given path is\nof the expected type, so\n\n\t! test_path_is_file foo\n\nwhen you do not want 'foo' to be a file, while making the test pass,\ndoes not help debugging when things go wrong.\n\nThese small patches touch the places where\n\n\t$ git grep -e '! test_path_' t/\n\nshows hits, except for test_path_is_hidden that shares the same name\npattern but is not designed to help debugging like others.\n\nJunio C Hamano (3):\n  tests: do not negate test_path_exists\n  t2021: do not negate test_path_is_dir\n  test: do not negate test_path_is_* to assert absense\n\n t/lib-submodule-update.sh     | 2 +-\n t/t2021-checkout-overwrite.sh | 2 +-\n t/t4067-diff-partial-clone.sh | 4 ++--\n t/t4115-apply-symlink.sh      | 2 +-\n t/t5572-pull-submodule.sh     | 4 ++--\n 5 files changed, 7 insertions(+), 7 deletions(-)\n\n-- \n2.41.0-rc0\n\n"},{"id":"477336","messageId":"20230516022646.648123-4-gitster@pobox.com","threadId":"59746","inReplyTo":"20230516022646.648123-1-gitster@pobox.com","subject":"[PATCH 3/3] test: do not negate test_path_is_* to assert absense","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-05-16T02:26:46Z","receivedAt":"2023-05-16T02:31:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"These tests use \"! test_path_is_dir\" or \"! test_path_is_file\" to\nensure that the path is not recursively checked out or \"submodule\nupdate\" did not touch the working tree.\n\nUse \"test_path_is_missing\" to assert that the path does not exist,\ninstead of negating test_path_is_* helpers; they are designed to be\nloud in wrong occasions.  Besides, negating \"test_path_is_dir\" would\nmean we would be happy if a file exists there, which is not the case\nfor these tests.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/lib-submodule-update.sh | 2 +-\n t/t5572-pull-submodule.sh | 4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh\nindex dee14992c5..9acb0d5d19 100644\n--- a/t/lib-submodule-update.sh\n+++ b/t/lib-submodule-update.sh\n@@ -802,7 +802,7 @@ test_submodule_recursing_with_args_common () {\n \t\t\tgit branch -t no_submodule origin/no_submodule &&\n \t\t\t$command no_submodule &&\n \t\t\ttest_superproject_content origin/no_submodule &&\n-\t\t\t! test_path_is_dir sub1 &&\n+\t\t\ttest_path_is_missing sub1 &&\n \t\t\ttest_must_fail git config -f .git/modules/sub1/config core.worktree &&\n \t\t\ttest_must_fail git config -f .git/modules/sub1/modules/sub2/config core.worktree\n \t\t)\ndiff --git a/t/t5572-pull-submodule.sh b/t/t5572-pull-submodule.sh\nindex 09097eff3f..4e917bf87d 100755\n--- a/t/t5572-pull-submodule.sh\n+++ b/t/t5572-pull-submodule.sh\n@@ -121,7 +121,7 @@ test_expect_success \"fetch.recurseSubmodules option triggers recursive fetch (bu\n \tsub_oid=$(git -C child rev-parse HEAD) &&\n \tgit -C super/sub cat-file -e $sub_oid &&\n \t# Check that the submodule worktree did not update\n-\t! test_path_is_file super/sub/merge_strategy_5.t\n+\ttest_path_is_missing super/sub/merge_strategy_5.t\n '\n \n test_expect_success \"fetch.recurseSubmodules takes precedence over submodule.recurse\" '\n@@ -134,7 +134,7 @@ test_expect_success \"fetch.recurseSubmodules takes precedence over submodule.rec\n \tsub_oid=$(git -C child rev-parse HEAD) &&\n \tgit -C super/sub cat-file -e $sub_oid &&\n \t# Check that the submodule worktree did not update\n-\t! test_path_is_file super/sub/merge_strategy_6.t\n+\ttest_path_is_missing super/sub/merge_strategy_6.t\n '\n \n test_expect_success 'pull --rebase --recurse-submodules (remote superproject submodule changes, local submodule changes)' '\n-- \n2.41.0-rc0\n\n"},{"id":"477337","messageId":"20230516022646.648123-3-gitster@pobox.com","threadId":"59746","inReplyTo":"20230516022646.648123-1-gitster@pobox.com","subject":"[PATCH 2/3] t2021: do not negate test_path_is_dir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-05-16T02:26:45Z","receivedAt":"2023-05-16T02:32:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"In this test, a path (some_dir) that is originally a directory is to\nbe removed and then to be replaced with a file of the same name.\nThe expectation is that the path becomes a file at the end.\nHowever, \"!  test_path_is_dir some_dir\" is used to catch a breakage\nthat leaves the path as a directory.\n\nBut as with all the \"test_path_is...\" helpers, this use of the\nhelper makes it loud when the expectation (i.e. it is a directory)\nis met, and otherwise is silent when it is not---this does not help\ndebugging.\n\nBe more explicit and state that we expect the path to become a file.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t2021-checkout-overwrite.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t2021-checkout-overwrite.sh b/t/t2021-checkout-overwrite.sh\nindex 034f62c13c..ecfacf0f7f 100755\n--- a/t/t2021-checkout-overwrite.sh\n+++ b/t/t2021-checkout-overwrite.sh\n@@ -77,7 +77,7 @@ test_expect_success 'checkout --overwrite-ignore should succeed if only ignored\n \techo autogenerated information >some_dir/ignore &&\n \techo ignore >.git/info/exclude &&\n \tgit checkout --overwrite-ignore df_conflict &&\n-\t! test_path_is_dir some_dir\n+\ttest_path_is_file some_dir\n '\n \n test_done\n-- \n2.41.0-rc0\n\n"},{"id":"477338","messageId":"CAPig+cRwPUJZdov7eAZbZ1qji9qj_Oh5RQ8bpLWsXW9J+QnvPA@mail.gmail.com","threadId":"59746","inReplyTo":"20230516022646.648123-2-gitster@pobox.com","subject":"Re: [PATCH 1/3] tests: do not negate test_path_exists","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2023-05-16T02:53:31Z","receivedAt":"2023-05-16T02:53:47Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, May 15, 2023 at 10:37 PM Junio C Hamano <gitster@pobox.com> wrote:\n> As a way to assert the path 'foo' is missing, \"! test_path_exists foo\" a\n> poor way to do so, as the helper is designed to complain when 'foo' is\n> missing, but the intention of the author who used negated form was to\n> make sure it does not exist.  This does not help debugging the tests.\n\ns/a poor/is &/\n\n> Use test_path_is_missing instead, which is a more appropriate helper.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n"},{"id":"477383","messageId":"xmqqzg64uuid.fsf@gitster.g","threadId":"59746","inReplyTo":"CAPig+cRwPUJZdov7eAZbZ1qji9qj_Oh5RQ8bpLWsXW9J+QnvPA@mail.gmail.com","subject":"Re: [PATCH 1/3] tests: do not negate test_path_exists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-05-16T16:10:50Z","receivedAt":"2023-05-16T16:11:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Mon, May 15, 2023 at 10:37 PM Junio C Hamano <gitster@pobox.com> wrote:\n>> As a way to assert the path 'foo' is missing, \"! test_path_exists foo\" a\n>> poor way to do so, as the helper is designed to complain when 'foo' is\n>> missing, but the intention of the author who used negated form was to\n>> make sure it does not exist.  This does not help debugging the tests.\n>\n> s/a poor/is &/\n\nThanks.\n\n>\n>> Use test_path_is_missing instead, which is a more appropriate helper.\n>>\n>> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n"}]}