Re: [PATCH v3 1/3] tests: Prepare --textconv tests for correctly-failing conversion program

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kirill Smelkov <kirr@xxxxxxxxxxxxxxxxxxx> writes:

> diff --git a/t/t4042-diff-textconv-caching.sh b/t/t4042-diff-textconv-caching.sh
> index 91f8198..7668099 100755
> --- a/t/t4042-diff-textconv-caching.sh
> +++ b/t/t4042-diff-textconv-caching.sh
> @@ -5,18 +5,19 @@ test_description='test textconv caching'
>  
>  cat >helper <<'EOF'
>  #!/bin/sh
> -sed 's/^/converted: /' "$@" >helper.out
> +grep -q '^bin: ' "$@" || { echo "E: $@ is not \"binary\" file" 1>&2; exit 1; }

You are not feeding arguments you think you are to the above "echo":

        $ cat >/var/tmp/j.sh <<\EOF
        #!/bin/sh
        e () {
                i=0
                for s
                do
                        i=$(( $i + 1 ))
                        echo "$i: $s"
                done
        }
        f () {
                e "E: $@ is not binary"
        }
        f 1 "2 3" 4
        EOF
        $ sh /var/tmp/j.sh
        1: E: 1
        2: 2 3
        3: 4 is not binary

Granted, echo is forgiving and will concatenate the arguments it gets with
a space in between, but you would either want to either:

 (1) make it more explicit that helper gets only one argument, by saying
     "$1" instead of "$@", in all places in the helper script; or

 (2) if you are planning to make 'helper' capable of handling multiple
     input files, show the error message for the ones that are not binary
     (you would probably need a loop for that).

I think (1) would be sufficient in this case.

> +sed 's/^bin:/converted:/' "$@" >helper.out

Minor nit: this is inconsistent with the check done with grep above that
insists that the colon is followed by a SP.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]