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

Re: [PATCH] t4005: modernize style and drop hard coded sha1

From
BWBrandon Williams <bmwill@google.com>
Date
Jun 7, 2017, 17:39 UTC
Message-ID
<20170607173959.GA110638@google.com>
In-Reply-To
<20170607021805.11849-1-sbeller@google.com>
On 06/06, Stefan Beller wrote:
Show 67 quoted lines
> Use modern style in the test t4005. Remove hard coded sha1 values.
> Combine test prep work and the actual test. Rename the first
> test to contain the word "setup".
> 
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
> 
> Junio wrote:
> > If it helps, I _can_ make any set of declarations to make it sound
> > more official, e.g. (the remainder of) June is the "make sure our
> > tests are ready" 
> 
> If it helps, I can write code for that. :)
> 
> Do get a good grasp on which tests need to be fixed, I changed the seed
> value for the sha1 computation and then run the test suite. There are a lot
> of tests passing for this, but also quite a few failing. Then I picked t4005
> randomly to start with. This patch works even with a crippled hash function
> as we use hash-object to get the object id.
> 
> Thanks,
> Stefan
> 
>  t/t4005-diff-rename-2.sh | 95 ++++++++++++++++++++++--------------------------
>  1 file changed, 43 insertions(+), 52 deletions(-)
> 
> diff --git a/t/t4005-diff-rename-2.sh b/t/t4005-diff-rename-2.sh
> index 135addbfbd..f542d2929d 100755
> --- a/t/t4005-diff-rename-2.sh
> +++ b/t/t4005-diff-rename-2.sh
> @@ -3,84 +3,75 @@
>  # Copyright (c) 2005 Junio C Hamano
>  #
>  
> -test_description='Same rename detection as t4003 but testing diff-raw.
> +test_description='Same rename detection as t4003 but testing diff-raw.'
>  
> -'
>  . ./test-lib.sh
>  . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
>  
> -test_expect_success \
> -    'prepare reference tree' \
> -    'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
> -     echo frotz >rezrov &&
> -    git update-index --add COPYING rezrov &&
> -    tree=$(git write-tree) &&
> -    echo $tree'
> -
> -test_expect_success \
> -    'prepare work tree' \
> -    'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
> -    sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
> -    rm -f COPYING &&
> -    git update-index --add --remove COPYING COPYING.?'
> +test_expect_success 'setup reference tree' '
> +	cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
> +	echo frotz >rezrov &&
> +	git update-index --add COPYING rezrov &&
> +	tree=$(git write-tree) &&
> +	echo $tree &&
> +	sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
> +	sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
> +	origoid=$(git hash-object COPYING) &&
> +	oid1=$(git hash-object COPYING.1) &&
> +	oid2=$(git hash-object COPYING.2)
> +'

This conversation looks good to me. The only thing that made me scratch my head a bit were the shell variables origoid, oid1, and oid2. It was just slightly confusing figuring out where they came from in the tests below before I noticed they were initialized up here.

Show 94 quoted lines
>  
> +################################################################
>  # tree has COPYING and rezrov.  work tree has COPYING.1 and COPYING.2,
>  # both are slightly edited, and unchanged rezrov.  We say COPYING.1
>  # and COPYING.2 are based on COPYING, and do not say anything about
>  # rezrov.
>  
> -git diff-index -C $tree >current
> -
> -cat >expected <<\EOF
> -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234	COPYING	COPYING.1
> -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234	COPYING	COPYING.2
> -EOF
> +test_expect_success 'validate output from rename/copy detection (#1)' '
> +	rm -f COPYING &&
> +	git update-index --add --remove COPYING COPYING.? &&
>  
> -test_expect_success \
> -    'validate output from rename/copy detection (#1)' \
> -    'compare_diff_raw current expected'
> +	cat <<-EOF >expected &&
> +	:100644 100644 $origoid $oid1 C1234	COPYING	COPYING.1
> +	:100644 100644 $origoid $oid2 R1234	COPYING	COPYING.2
> +	EOF
> +	git diff-index -C $tree >current &&
> +	compare_diff_raw expected current
> +'
>  
>  ################################################################
> -
> -test_expect_success \
> -    'prepare work tree again' \
> -    'mv COPYING.2 COPYING &&
> -     git update-index --add --remove COPYING COPYING.1 COPYING.2'
> -
>  # tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
>  # both are slightly edited, and unchanged rezrov.  We say COPYING.1
>  # is based on COPYING and COPYING is still there, and do not say anything
>  # about rezrov.
>  
> -git diff-index -C $tree >current
> -cat >expected <<\EOF
> -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M	COPYING
> -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234	COPYING	COPYING.1
> -EOF
> +test_expect_success 'validate output from rename/copy detection (#2)' '
> +	mv COPYING.2 COPYING &&
> +	git update-index --add --remove COPYING COPYING.1 COPYING.2 &&
>  
> -test_expect_success \
> -    'validate output from rename/copy detection (#2)' \
> -    'compare_diff_raw current expected'
> +	cat <<-EOF >expected &&
> +	:100644 100644 $origoid $oid2 M	COPYING
> +	:100644 100644 $origoid $oid1 C1234	COPYING	COPYING.1
> +	EOF
> +	git diff-index -C $tree >current &&
> +	compare_diff_raw current expected
> +'
>  
>  ################################################################
> -
>  # tree has COPYING and rezrov.  work tree has the same COPYING and
>  # copy-edited COPYING.1, and unchanged rezrov.  We should not say
>  # anything about rezrov or COPYING, since the revised again diff-raw
>  # nows how to say Copy.
>  
> -test_expect_success \
> -    'prepare work tree once again' \
> -    'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
> -     git update-index --add --remove COPYING COPYING.1'
> -
> -git diff-index -C --find-copies-harder $tree >current
> -cat >expected <<\EOF
> -:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234	COPYING	COPYING.1
> -EOF
> +test_expect_success 'validate output from rename/copy detection (#3)' '
> +	cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
> +	git update-index --add --remove COPYING COPYING.1 &&
>  
> -test_expect_success \
> -    'validate output from rename/copy detection (#3)' \
> -    'compare_diff_raw current expected'
> +	cat <<-EOF >expected &&
> +	:100644 100644 $origoid $oid1 C1234	COPYING	COPYING.1
> +	EOF
> +	git diff-index -C --find-copies-harder $tree >current &&
> +	compare_diff_raw current expected
> +'
>  
>  test_done
> -- 
> 2.13.0.17.gf3d7728391
> 
-- 
Brandon Williams
Previous: Stefan BellerNext: Stefan Beller
Message 21 of 59 in “Add regression tests for recent rebase -i fixes”
  1. 0/3 Add regression tests for recent rebase -i fixesPhillip Wood, May 31, 2017
  2. 3/3 rebase: Add tests for console output with conflicting stashPhillip Wood, May 31, 2017
  3. 1/3 rebase -i: Add test for reflog messagePhillip Wood, May 31, 2017
  4. Junio C HamanoJun 1, 2017
  5. 2/3 rebase: Add tests for console outputPhillip Wood, May 31, 2017
  6. Phillip WoodMay 31, 2017
  7. Junio C HamanoJun 1, 2017
  8. Johannes SchindelinJun 1, 2017
  9. Junio C HamanoJun 1, 2017
  10. Stefan BellerJun 1, 2017
  11. pushing for a new hash, was Re: [PATCH 2/3] rebase: Add tests for console outputJohannes Schindelin, Jun 2, 2017
  12. Jonathan NiederJun 2, 2017
  13. Jonathan NiederJun 2, 2017
  14. Ævar Arnfjörð BjarmasonJun 2, 2017
  15. Johannes SchindelinJun 15, 2017
  16. Junio C HamanoJun 3, 2017
  17. Johannes SchindelinJun 6, 2017
  18. Jonathan NiederJun 6, 2017
  19. Junio C HamanoJun 7, 2017
  20. t4005: modernize style and drop hard coded sha1Stefan Beller, Jun 7, 2017
  21. Brandon WilliamsJun 7, 2017
  22. Stefan BellerJun 6, 2017
  23. Jonathan NiederJun 6, 2017
  24. Samuel LijinJun 7, 2017
  25. Johannes SchindelinJun 7, 2017
  26. Stefan BellerJun 7, 2017
  27. Phillip WoodJun 7, 2017
  28. Junio C HamanoJun 9, 2017
  29. Phillip WoodJun 14, 2017
  30. Johannes SchindelinJun 14, 2017
  31. 0/3 Add regression tests for rectent rebase -i fixesPhillip Wood, Jun 14, 2017
  32. 1/3 rebase -i: Add test for reflog messagePhillip Wood, Jun 14, 2017
  33. 2/3 rebase: Add regression tests for console outputPhillip Wood, Jun 14, 2017
  34. 3/3 rebase: Add more regression tests for console outputPhillip Wood, Jun 14, 2017
  35. Johannes SchindelinJun 14, 2017
  36. Junio C HamanoJun 15, 2017
  37. Junio C HamanoJun 15, 2017
  38. Junio C HamanoJun 15, 2017
  39. Johannes SchindelinJun 16, 2017
  40. Johannes SixtJun 16, 2017
  41. Junio C HamanoJun 16, 2017
  42. Johannes SixtJun 19, 2017
  43. Junio C HamanoJun 19, 2017
  44. Phillip WoodJun 19, 2017
  45. Junio C HamanoJun 19, 2017
  46. Phillip WoodJun 19, 2017
  47. 0/4 Add regression tests for recent rebase -i fixesPhillip Wood, Jun 19, 2017
  48. 1/4 sequencer: print autostash messages to stderrPhillip Wood, Jun 19, 2017
  49. 2/4 rebase -i: Add test for reflog messagePhillip Wood, Jun 19, 2017
  50. 3/4 rebase: Add regression tests for console outputPhillip Wood, Jun 19, 2017
  51. 4/4 rebase: Add more regression tests for console outputPhillip Wood, Jun 19, 2017
  52. Junio C HamanoJun 23, 2017
  53. Junio C HamanoJun 23, 2017
  54. Phillip WoodJun 23, 2017
  55. Junio C HamanoJun 23, 2017
  56. Junio C HamanoJun 23, 2017
  57. Phillip WoodJun 26, 2017
  58. Junio C HamanoJun 23, 2017
  59. Phillip WoodJun 26, 2017

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.