Re: [PATCHv3 3/5] t7406: prefer test_* helper functions to test -[feds]
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 7, 2018, 17:34 UTC
- Message-ID
- <xmqqk1p2krlz.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180807164905.3859-4-newren@gmail.com>
Elijah Newren <newren@gmail.com> writes:
> test -e, test -s, etc. do not provide nice error messages when we hit > test failures, so use the test_* helper functions from > test-lib-functions.sh.
Good explanation.
Show 7 quoted lines
> Note: The use of 'test_path_is_file submodule/.git' may look odd, but > it is a file which is populated with a > gitdir: ../.git/modules/submodule > directive. If, in the future, handling of the submodule is changed and > submodule/.git becomes a directory we can change this to > test_path_is_dir (or perhaps write a test_path_exists helper function > that doesn't care whether the path is a file or a directory).
Yup, path_exists would be a good direction going forward. If we already have "missing" and use it in this rewrite, it may make sense to introduce "exists" and use it at the same time here.
Show 29 quoted lines
> > Signed-off-by: Elijah Newren <newren@gmail.com> > --- > t/t7406-submodule-update.sh | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh > index c6b7b59350..ab67e373c5 100755 > --- a/t/t7406-submodule-update.sh > +++ b/t/t7406-submodule-update.sh > @@ -174,7 +174,7 @@ test_expect_success 'submodule update does not fetch already present commits' ' > git submodule update > ../actual 2> ../actual.err > ) && > test_i18ncmp expected actual && > - ! test -s actual.err > + test_must_be_empty actual.err > ' > > test_expect_success 'submodule update should fail due to local changes' ' > @@ -619,8 +619,8 @@ test_expect_success 'submodule update --init skips submodule with update=none' ' > git clone super cloned && > (cd cloned && > git submodule update --init && > - test -e submodule/.git && > - test_must_fail test -e none/.git > + test_path_is_file submodule/.git && > + test_path_is_missing none/.git > ) > '