{"thread":{"id":"52351","subject":"[PATCH] test: use test_must_be_empty F instead of test -z $(cat F)","startedAt":"2019-11-26T19:46:15Z","lastAt":"2019-11-26T19:46:15Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"387102","messageId":"a374807f-0fcf-4ee5-f086-9d0ef6ca5865@web.de","threadId":"52351","inReplyTo":null,"subject":"[PATCH] test: use test_must_be_empty F instead of test -z $(cat F)","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-11-26T19:46:07Z","receivedAt":"2019-11-26T19:46:15Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Use test_must_be_empty instead of reading the file and comparing its\ncontents to an empty string.  That's more efficient, as the function\nonly needs built-in meta-data only check in the usual case, and provides\nnicer debug output otherwise.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n t/t1309-early-config.sh           | 2 +-\n t/t1506-rev-parse-diagnosis.sh    | 8 ++++----\n t/t6019-rev-list-ancestry-path.sh | 4 ++--\n 3 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/t/t1309-early-config.sh b/t/t1309-early-config.sh\nindex 3a0de0ddaa..ebb8e1aecb 100755\n--- a/t/t1309-early-config.sh\n+++ b/t/t1309-early-config.sh\n@@ -29,7 +29,7 @@ test_expect_success 'ceiling' '\n \t\tcd sub &&\n \t\ttest-tool config read_early_config early.config\n \t) >output &&\n-\ttest -z \"$(cat output)\"\n+\ttest_must_be_empty output\n '\n\n test_expect_success 'ceiling #2' '\ndiff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh\nindex 624d0a588f..6d951ca015 100755\n--- a/t/t1506-rev-parse-diagnosis.sh\n+++ b/t/t1506-rev-parse-diagnosis.sh\n@@ -138,10 +138,10 @@ test_expect_success 'incorrect file in :path and :N:path' '\n\n test_expect_success 'invalid @{n} reference' '\n \ttest_must_fail git rev-parse master@{99999} >output 2>error &&\n-\ttest -z \"$(cat output)\" &&\n+\ttest_must_be_empty output &&\n \tgrep \"fatal: Log for [^ ]* only has [0-9][0-9]* entries.\" error  &&\n \ttest_must_fail git rev-parse --verify master@{99999} >output 2>error &&\n-\ttest -z \"$(cat output)\" &&\n+\ttest_must_be_empty output &&\n \tgrep \"fatal: Log for [^ ]* only has [0-9][0-9]* entries.\" error\n '\n\n@@ -155,13 +155,13 @@ test_expect_success 'relative path not found' '\n\n test_expect_success 'relative path outside worktree' '\n \ttest_must_fail git rev-parse HEAD:../file.txt >output 2>error &&\n-\ttest -z \"$(cat output)\" &&\n+\ttest_must_be_empty output &&\n \ttest_i18ngrep \"outside repository\" error\n '\n\n test_expect_success 'relative path when cwd is outside worktree' '\n \ttest_must_fail git --git-dir=.git --work-tree=subdir rev-parse HEAD:./file.txt >output 2>error &&\n-\ttest -z \"$(cat output)\" &&\n+\ttest_must_be_empty output &&\n \tgrep \"relative path syntax can.t be used outside working tree.\" error\n '\n\ndiff --git a/t/t6019-rev-list-ancestry-path.sh b/t/t6019-rev-list-ancestry-path.sh\nindex beadaf6cca..353f84313f 100755\n--- a/t/t6019-rev-list-ancestry-path.sh\n+++ b/t/t6019-rev-list-ancestry-path.sh\n@@ -143,14 +143,14 @@ test_expect_success 'setup criss-cross' '\n test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '\n \t(cd criss-cross &&\n \t git rev-list --ancestry-path xcb..xbc > actual &&\n-\t test -z \"$(cat actual)\")\n+\t test_must_be_empty actual)\n '\n\n # no commits in repository descend from cb\n test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '\n \t(cd criss-cross &&\n \t git rev-list --ancestry-path --all ^xcb > actual &&\n-\t test -z \"$(cat actual)\")\n+\t test_must_be_empty actual)\n '\n\n test_done\n--\n2.24.0\n"}]}