Re: [PATCH v2 08/10] replace: add tests for --edit

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

 



On Sat, May 17, 2014 at 08:41:30AM +0200, Christian Couder wrote:

> Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
> ---
>  t/t6050-replace.sh | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)

Yay, tests.

> +test_expect_success 'setup a fake editor' '
> +	cat >fakeeditor <<-\EOF &&
> +		#!/bin/sh
> +		sed -e "s/A U Thor/A fake Thor/" "$1" >"$1.new"
> +		mv "$1.new" "$1"
> +	EOF
> +	chmod +x fakeeditor
> +'

Please use write_script, like:

  test_expect_success 'setup a fake editor' '
	write_script fakeeditor <<-\EOF
		sed -e "s/A U Thor/A fake Thor/" "$1" >"$1.new"
		mv "$1.new" "$1"
	EOF
  '

which will use the $(SHELL_PATH) shebang. It doesn't matter for such a
simple script here (which even a broken #!/bin/sh could manage), but in
general, I think we're trying to set it consistently.

You could also &&-chain the commands in your fakeeditor script, though I
find it unlikely that sed will fail.

> +test_expect_success '--edit with and without already replaced object' '
> +	GIT_EDITOR=./fakeeditor test_must_fail git replace --edit "$PARA3" &&

Unfortunately it's not portable to do a one-shot environment variable on
a shell function like this; some shells leave the variable set after the
function returns. We've been using:

  test_must_fail env GIT_EDITOR=./fakeeditor git ...

The regular

  GIT_EDITOR=./fakeeditor git ...

ones are OK.

-Peff
--
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]