Re: [PATCH v3 1/2] t1300: extract and use test_cmp_config()
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Oct 3, 2018, 07:46 UTC
- Message-ID
- <CAPig+cRTty2BBs_udpYxHESBMx_y0NTM0gdkgX=z3EbEhvJDdg@mail.gmail.com>
- In-Reply-To
- <20181002160658.15891-2-pclouds@gmail.com>
On Tue, Oct 2, 2018 at 12:07 PM Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 11 quoted lines
> In many config-related tests it's common to check if a config variable
> has expected value and we want to print the differences when the test
> fails. Doing it the normal way is three lines of shell code. Let's add
> a function do to all this (and a little more).
> [...]
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> @@ -747,6 +747,29 @@ test_cmp() {
> +test_cmp_config() {
> + local GDIf you re-roll, maybe make this part of the &&-chain to protect against someone coming along and inserting code above this line without realizing that the &&-chain is broken.
Show 11 quoted lines
> + if test "$1" = "-C" > + then > + shift && > + GD="-C $1" && > + shift > + fi && > + printf "%s\n" "$1" >expect.config && > + shift && > + git $GD config "$@" >actual.config && > + test_cmp expect.config actual.config > +}