On Wed, Jul 11, 2018 at 02:56:47PM +0200, SZEDER Gábor wrote:
> +# Requires one argument: the name of a file containing the expected stripped
> +# access log entries.
> +check_access_log() {
> + sort "$1" >"$1".sorted &&
> + strip_access_log >access.log.stripped &&
> + sort access.log.stripped >access.log.sorted &&
> + if ! test_cmp "$1".sorted access.log.sorted
> + then
> + test_cmp "$1" access.log.stripped
> + fi
> +}
This will generate output showing both the unsorted and sorted
differences. Do we want to suppress the sorted ones (e.g., by just using
"cmp" directly)? I guess it doesn't matter unless there is an actual
test failure, but I just wonder if it would be confusing to see both.
> diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh
> index 6cd986797d..a481e3989a 100755
> --- a/t/t5541-http-push-smart.sh
> +++ b/t/t5541-http-push-smart.sh
> @@ -43,15 +43,13 @@ test_expect_success 'no empty path components' '
> cd "$ROOT_PATH" &&
> git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&
>
> - strip_access_log >act &&
> + check_access_log exp
> +'
>
> +test_expect_success 'clear access log' '
> # Clear the log, so that it does not affect the "used receive-pack
> # service" test which reads the log too.
> - #
> - # We do this before the actual comparison to ensure the log is cleared.
> - >"$HTTPD_ROOT_PATH"/access.log &&
> -
> - test_cmp exp act
> + >"$HTTPD_ROOT_PATH"/access.log
> '
This took some head-scratching, mostly because of the original comment.
I thought the "before" here was referring to a timing issue (maybe
because we're talking about timing ;) ).
But it is really "make sure that a failed test here does not prevent us
from doing this cleanup". So the original really should have just
dropped that comment and added a test_when_finished. Bumping it into a
separate test as you have here accomplishes the same thing.
-Peff