Message ID | 20230312201520.370234-5-rybak.a.v@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v1,1/7] t1005: assert output of ls-files | expand |
Andrei Rybak <rybak.a.v@gmail.com> writes: > test_expect_success 'mktree refuses to read ls-tree -r output (1)' ' > - test_must_fail git mktree <all >actual > + test_must_fail git mktree <all >actual && > + test_must_be_empty actual > ' > > test_expect_success 'mktree refuses to read ls-tree -r output (2)' ' > - test_must_fail git mktree <all.withsub >actual > + test_must_fail git mktree <all.withsub >actual && > + test_must_be_empty actual > ' I am ambivalent. As long as a failing command signals its failure with its non-zero exit status value, the consumer of the output should not blindly use the output from such a failing command. Is there a strong reason why we want users rely on the command to be silent when it fails? An obvious alternative is to stop producing "actual" file, and it might be a better idea; unless there is a good reason why we should expect the command to be silent, that is. Thanks.
diff --git a/t/t1010-mktree.sh b/t/t1010-mktree.sh index 3c08194526..31ea2ec0bb 100755 --- a/t/t1010-mktree.sh +++ b/t/t1010-mktree.sh @@ -60,11 +60,13 @@ test_expect_success 'allow missing object with --missing' ' ' test_expect_success 'mktree refuses to read ls-tree -r output (1)' ' - test_must_fail git mktree <all >actual + test_must_fail git mktree <all >actual && + test_must_be_empty actual ' test_expect_success 'mktree refuses to read ls-tree -r output (2)' ' - test_must_fail git mktree <all.withsub >actual + test_must_fail git mktree <all.withsub >actual && + test_must_be_empty actual ' test_done
Builtin "git mktree" writes the the object name of the tree object built to the standard output. Tests 'mktree refuses to read ls-tree -r output (1)' and 'mktree refuses to read ls-tree -r output (2)' in "t1010-mktree.sh" redirect output of "git mktree" to a file, but don't use its contents in assertions. Assert that the output of "git mktree" is empty when it refuses to build a tree object. Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com> --- t/t1010-mktree.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)