git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 27, 2010, 18:23 UTC
Message-ID
<7vsk0vyriw.fsf@alter.siamese.dyndns.org>
In-Reply-To
<66d4603c7e21561557f612690d6196e7ae0b38f9.1285351816.git.kirr@landau.phys.spbu.ru>
Kirill Smelkov <kirr@landau.phys.spbu.ru> writes:
Show 10 quoted lines
> 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.

Previous: Kirill SmelkovNext: Kirill Smelkov
Message 3 of 18 in “Fix {blame,cat-file} --textconv for cases with symlinks”
  1. 0/3 Fix {blame,cat-file} --textconv for cases with symlinksKirill Smelkov, Sep 24, 2010
  2. 1/3 tests: Prepare --textconv tests for correctly-failing conversion programKirill Smelkov, Sep 24, 2010
  3. Junio C HamanoSep 27, 2010
  4. Kirill SmelkovSep 28, 2010
  5. Kirill SmelkovSep 28, 2010
  6. Kirill SmelkovSep 28, 2010
  7. Jeff KingSep 28, 2010
  8. Kirill SmelkovSep 28, 2010
  9. Jeff KingSep 28, 2010
  10. Kirill SmelkovSep 28, 2010
  11. Junio C HamanoSep 28, 2010
  12. Jeff KingSep 28, 2010
  13. Kirill SmelkovSep 28, 2010
  14. Kirill SmelkovSep 29, 2010
  15. 2/3 blame,cat-file: Demonstrate --textconv is wrongly running converter on symlinksKirill Smelkov, Sep 24, 2010
  16. Junio C HamanoSep 27, 2010
  17. Kirill SmelkovSep 28, 2010
  18. 3/3 blame,cat-file --textconv: Don't assume mode is ``S_IFREF | 0664''Kirill Smelkov, Sep 24, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.