The tests for stdin -z fails for update/delete/verify are of the form
update refs/heads/a $m $m $m
and rely on the fact that when parsed we will first parse everything except
the trailing $m. And once that command has completed it will start parsing
the next command, find the trailing $m from before and fail because this
would not look like a proper command. I.e. we do not detect that there are
too many arguments so much as detect that the next command looks like
garbage.

But since the ref refs/heads/a does not exist at this point in the test we
actually have two failures that trigger. We have one error that is due to
update refs/heads/a $m $m would be invalid because the ref does not exist
and we have a second error that is due to the trailing $m causing a "too
many arguments". The current test depends on the order of check for these two
which makes the test fragile (and would break after the next patch).

Move these tests further down in the test to occur after we have created
refs/heads/a so that there is only one error condition in the test and that
we no longer depend on in which order the checks for error occur.

Signed-off-by: Ronnie Sahlberg <sahlb...@google.com>
---
 t/t1400-update-ref.sh | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 4e2459a..f9b7bef 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -756,12 +756,6 @@ test_expect_success 'stdin -z fails update with no old 
value' '
        grep "fatal: update $a: unexpected end of input when reading 
<oldvalue>" err
 '
 
-test_expect_success 'stdin -z fails update with too many arguments' '
-       printf $F "update $a" "$m" "$m" "$m" >stdin &&
-       test_must_fail git update-ref -z --stdin <stdin 2>err &&
-       grep "fatal: unknown command: $m" err
-'
-
 test_expect_success 'stdin -z fails delete with no ref' '
        printf $F "delete " >stdin &&
        test_must_fail git update-ref -z --stdin <stdin 2>err &&
@@ -780,18 +774,6 @@ test_expect_success 'stdin -z fails delete with no old 
value' '
        grep "fatal: delete $a: unexpected end of input when reading 
<oldvalue>" err
 '
 
-test_expect_success 'stdin -z fails delete with too many arguments' '
-       printf $F "delete $a" "$m" "$m" >stdin &&
-       test_must_fail git update-ref -z --stdin <stdin 2>err &&
-       grep "fatal: unknown command: $m" err
-'
-
-test_expect_success 'stdin -z fails verify with too many arguments' '
-       printf $F "verify $a" "$m" "$m" >stdin &&
-       test_must_fail git update-ref -z --stdin <stdin 2>err &&
-       grep "fatal: unknown command: $m" err
-'
-
 test_expect_success 'stdin -z fails verify with no old value' '
        printf $F "verify $a" >stdin &&
        test_must_fail git update-ref -z --stdin <stdin 2>err &&
@@ -818,6 +800,24 @@ test_expect_success 'stdin -z create ref works' '
        test_cmp expect actual
 '
 
+test_expect_success 'stdin -z fails update with too many arguments' '
+       printf $F "update $a" "$m" "$m" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: unknown command: $m" err
+'
+
+test_expect_success 'stdin -z fails delete with too many arguments' '
+       printf $F "delete $a" "$m" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: unknown command: $m" err
+'
+
+test_expect_success 'stdin -z fails verify with too many arguments' '
+       printf $F "verify $a" "$m" "$m" >stdin &&
+       test_must_fail git update-ref -z --stdin <stdin 2>err &&
+       grep "fatal: unknown command: $m" err
+'
+
 test_expect_success 'stdin -z update ref creates with zero old value' '
        printf $F "update $b" "$m" "$Z" >stdin &&
        git update-ref -z --stdin <stdin &&
-- 
2.0.0.rc3.506.g3739a35

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to