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

Re: [GSoC][PATCH v7 20/26] stash: add tests for `git stash push -q`

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Aug 18, 2018, 16:12 UTC
Message-ID
<20180818161257.GD11326@hank.intra.tgummerer.com>
In-Reply-To
<5ec3429340f43caad79e4213a7994738cb5d33c7.1533753605.git.ungureanupaulsebastian@gmail.com>
On 08/08, Paul-Sebastian Ungureanu wrote:
> This commit introduces more tests for the quiet option of
> `git stash push`.

I think this commit should be squashed into the previous one, so we have implementation and tests in one commit. That way it's easier to see during review that there are tests for the change. For more discussion on that also see [1].

[1]: https://public-inbox.org/git/20180806144726.GB97564@aiede.svl.corp.google.com/
Show 15 quoted lines
> ---
>  t/t3903-stash.sh | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
> index 8d002a7f2..b78db74ae 100755
> --- a/t/t3903-stash.sh
> +++ b/t/t3903-stash.sh
> @@ -1064,6 +1064,27 @@ test_expect_success 'push: <pathspec> not in the repository errors out' '
>  	test_path_is_file untracked
>  '
>  
> +test_expect_success 'push: -q is quiet with changes' '
> +	>foo &&
> +	git stash push -q >output 2>&1 &&

We create an untracked file here and then call 'git stash push', which will not create a new stash, as we don't use the --include-untracked option. In fact, right now this test is doing the same thing as the test below. There should be a 'git add foo' above the 'git stash push' call to test what we're claiming to test here.

Show 12 quoted lines
> +	test_must_be_empty output
> +'
> +
> +test_expect_success 'push: -q is quiet with no changes' '
> +	git stash push -q >output 2>&1 &&
> +	test_must_be_empty output
> +'
> +
> +test_expect_success 'push: -q is quiet even if there is no initial commit' '
> +	git init foo_dir &&
> +	cd foo_dir &&
> +	touch bar &&

The typical style in the test suite for creating a new file is to use '>bar', unless you care about the 'mtime' the file has. We don't seem to care about that in this test, so avoiding 'touch' would be better.

> +	test_must_fail git stash push -q >output 2>&1 &&
> +	test_must_be_empty output &&
> +	cd .. &&
The above should be in a subshell, i.e.
    (
        cd foo_dir &&
	touch bar &&
        test_must_fail git stash push -q >output 2>&1 &&
        test_must_be_empty output &&
    )

then you don't have to do the 'cd ..' in the end. With the 'cd ..' in the end, if one of the commands between the 'cd foo_dir' and 'cd ..' fails, all subsequent tests will be run inside of 'foo_dir', which puts them in a different environment than they expect. That can cause all kinds of weirdness.

If inside a subshell, the current working directory of the parent
shell is unaffected, so we don't have to worry about cd'ing back, and
subsequent tests will get the correct cwd even if things go wrong in
this test.
	
> +	rm -rf foo_dir

We'll want to run this cleanup to run even if the test fails. To do so, the 'test_when_finished' helper can be used. Using that, this would go at the top of the test, as 'test_when_finished rm -rf foo_dir'. Otherwise if any of the commands above fail, 'foo_dir' will not be removed, and may interfere with subsequent tests.

Show 8 quoted lines
> +'
> +
>  test_expect_success 'untracked files are left in place when -u is not given' '
>  	>file &&
>  	git add file &&
> -- 
> 2.18.0.573.g56500d98f
> 
Previous: Paul-Sebastian UngureanuNext: Paul-Sebastian Ungureanu
Message 92 of 181 in “Convert some stash functionality to a builtin”
  1. 0/5 Convert some stash functionality to a builtinJoel Teichroeb, Apr 5, 2018
  2. 1/5 stash: improve option parsing test coverageJoel Teichroeb, Apr 5, 2018
  3. Johannes SchindelinApr 6, 2018
  4. Paul-Sebastian UngureanuApr 6, 2018
  5. Johannes SchindelinApr 9, 2018
  6. 3/5 stash: convert drop and clear to builtinJoel Teichroeb, Apr 5, 2018
  7. Johannes SchindelinApr 6, 2018
  8. 4/5 stash: convert branch to builtinJoel Teichroeb, Apr 5, 2018
  9. Johannes SchindelinApr 6, 2018
  10. 5/5 stash: convert pop to builtinJoel Teichroeb, Apr 5, 2018
  11. Johannes SchindelinApr 6, 2018
  12. 2/5 stash: convert apply to builtinJoel Teichroeb, Apr 5, 2018
  13. Christian CouderApr 5, 2018
  14. Christian CouderApr 5, 2018
  15. Christian CouderApr 5, 2018
  16. Johannes SchindelinApr 5, 2018
  17. Johannes SchindelinApr 6, 2018
  18. Johannes SchindelinApr 6, 2018
  19. Johannes SchindelinApr 6, 2018
  20. Paul-Sebastian UngureanuApr 28, 2018
  21. Johannes SchindelinApr 29, 2018
  22. 0/4 stash: add new tests and introduce a new helper functionPaul-Sebastian Ungureanu, Jun 25, 2018
  23. 1/4 sha1-name.c: added 'get_oidf', which acts like 'get_oid'Paul-Sebastian Ungureanu, Jun 25, 2018
  24. Johannes SchindelinJun 26, 2018
  25. 2/4 stash: improve option parsing test coveragePaul-Sebastian Ungureanu, Jun 25, 2018
  26. 3/4 stash: update test cases conform to coding guidelinesPaul-Sebastian Ungureanu, Jun 25, 2018
  27. Johannes SchindelinJun 26, 2018
  28. 4/4 stash: renamed test cases to be more descriptivePaul-Sebastian Ungureanu, Jun 25, 2018
  29. Johannes SchindelinJun 26, 2018
  30. 2/4 stash: convert drop and clear to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  31. Johannes SchindelinJun 26, 2018
  32. Paul-Sebastian UngureanuJun 28, 2018
  33. 1/4 stash: convert apply to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  34. 4/4 stash: convert pop to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  35. Johannes SchindelinJun 26, 2018
  36. 3/4 stash: convert branch to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  37. Johannes SchindelinJun 26, 2018
  38. Junio C HamanoJun 27, 2018
  39. Paul-Sebastian UngureanuJun 28, 2018
  40. 1/6 stash: implement the "list" command in the builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  41. 3/6 stash: change `git stash show` usage text and documentationPaul-Sebastian Ungureanu, Jun 25, 2018
  42. 6/6 stash: convert store to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  43. 2/6 stash: convert show to builtinPaul-Sebastian Ungureanu, Jun 25, 2018
  44. 5/6 stash: update `git stash show` documentationPaul-Sebastian Ungureanu, Jun 25, 2018
  45. 4/6 stash: refactor `show_stash()` to use the diff APIPaul-Sebastian Ungureanu, Jun 25, 2018
  46. Johannes SchindelinJun 26, 2018
  47. Junio C HamanoJun 27, 2018
  48. Paul-Sebastian UngureanuJun 28, 2018
  49. Johannes SchindelinJun 26, 2018
  50. Paul-Sebastian UngureanuJun 28, 2018
  51. [GSoC][PATCH v7 00/26] Convert "git stash" to C builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  52. [GSoC][PATCH v7 01/26] sha1-name.c: added 'get_oidf', which acts like 'get_oid'Paul-Sebastian Ungureanu, Aug 8, 2018
  53. [GSoC][PATCH v7 02/26] stash: improve option parsing test coveragePaul-Sebastian Ungureanu, Aug 8, 2018
  54. [GSoC][PATCH v7 03/26] stash: update test cases conform to coding guidelinesPaul-Sebastian Ungureanu, Aug 8, 2018
  55. [GSoC][PATCH v7 04/26] stash: renamed test cases to be more descriptivePaul-Sebastian Ungureanu, Aug 8, 2018
  56. Thomas GummererAug 15, 2018
  57. [GSoC][PATCH v7 05/26] stash: convert apply to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  58. Junio C HamanoAug 8, 2018
  59. Paul-Sebastian UngureanuAug 9, 2018
  60. Junio C HamanoAug 9, 2018
  61. Paul-Sebastian UngureanuAug 10, 2018
  62. Duy NguyenAug 18, 2018
  63. [GSoC][PATCH v7 07/26] stash: convert branch to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  64. [GSoC][PATCH v7 06/26] stash: convert drop and clear to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  65. [GSoC][PATCH v7 08/26] stash: convert pop to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  66. [GSoC][PATCH v7 10/26] stash: convert show to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  67. Thomas GummererAug 15, 2018
  68. Paul Sebastian UngureanuAug 18, 2018
  69. [GSoC][PATCH v7 11/26] stash: change `git stash show` usage text and documentationPaul-Sebastian Ungureanu, Aug 8, 2018
  70. Thomas GummererAug 15, 2018
  71. [GSoC][PATCH v7 12/26] stash: refactor `show_stash()` to use the diff APIPaul-Sebastian Ungureanu, Aug 8, 2018
  72. Thomas GummererAug 15, 2018
  73. Paul Sebastian UngureanuAug 18, 2018
  74. [GSoC][PATCH v7 13/26] stash: update `git stash show` documentationPaul-Sebastian Ungureanu, Aug 8, 2018
  75. Thomas GummererAug 15, 2018
  76. [GSoC][PATCH v7 09/26] stash: implement the "list" command in the builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  77. Thomas GummererAug 15, 2018
  78. Paul Sebastian UngureanuAug 18, 2018
  79. [GSoC][PATCH v7 16/26] stash: replace spawning a "read-tree" processPaul-Sebastian Ungureanu, Aug 8, 2018
  80. Thomas GummererAug 18, 2018
  81. [GSoC][PATCH v7 14/26] stash: convert store to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  82. Thomas GummererAug 15, 2018
  83. [GSoC][PATCH v7 15/26] stash: convert create to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  84. Thomas GummererAug 15, 2018
  85. Paul Sebastian UngureanuAug 18, 2018
  86. Thomas GummererAug 18, 2018
  87. [GSoC][PATCH v7 17/26] stash: avoid spawning a "diff-index" processPaul-Sebastian Ungureanu, Aug 8, 2018
  88. Thomas GummererAug 18, 2018
  89. [GSoC][PATCH v7 18/26] stash: convert push to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  90. Thomas GummererAug 18, 2018
  91. [GSoC][PATCH v7 20/26] stash: add tests for `git stash push -q`Paul-Sebastian Ungureanu, Aug 8, 2018
  92. Thomas GummererAug 18, 2018
  93. [GSoC][PATCH v7 19/26] stash: make push to be quietPaul-Sebastian Ungureanu, Aug 8, 2018
  94. Thomas GummererAug 18, 2018
  95. [GSoC][PATCH v7 21/26] stash: replace spawning `git ls-files` child processPaul-Sebastian Ungureanu, Aug 8, 2018
  96. Thomas GummererAug 18, 2018
  97. [GSoC][PATCH v7 22/26] stash: convert save to builtinPaul-Sebastian Ungureanu, Aug 8, 2018
  98. Thomas GummererAug 18, 2018
  99. [GSoC][PATCH v7 24/26] stash: optimize `get_untracked_files()` and `check_changes()`Paul-Sebastian Ungureanu, Aug 8, 2018
  100. Thomas GummererAug 18, 2018
  101. [GSoC][PATCH v7 25/26] stash: replace all `write-tree` child processes with API callsPaul-Sebastian Ungureanu, Aug 8, 2018
  102. Thomas GummererAug 19, 2018
  103. [GSoC][PATCH v7 23/26] stash: convert `stash--helper.c` into `stash.c`Paul-Sebastian Ungureanu, Aug 8, 2018
  104. Thomas GummererAug 18, 2018
  105. [GSoC][PATCH v7 26/26] stash: replace all "git apply" child processes with API callsPaul-Sebastian Ungureanu, Aug 8, 2018
  106. Thomas GummererAug 19, 2018
  107. Thomas GummererAug 15, 2018
  108. Paul Sebastian UngureanuAug 16, 2018
  109. [GSoC][PATCH v8 00/20] Convert "git stash" to C builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  110. [GSoC][PATCH v8 01/20] sha1-name.c: add `get_oidf()` which acts like `get_oid()`Paul-Sebastian Ungureanu, Aug 30, 2018
  111. [GSoC][PATCH v8 02/20] stash: improve option parsing test coveragePaul-Sebastian Ungureanu, Aug 30, 2018
  112. [GSoC][PATCH v8 03/20] stash: update test cases conform to coding guidelinesPaul-Sebastian Ungureanu, Aug 30, 2018
  113. Junio C HamanoAug 30, 2018
  114. [GSoC][PATCH v8 04/20] stash: rename test cases to be more descriptivePaul-Sebastian Ungureanu, Aug 30, 2018
  115. [GSoC][PATCH v8 05/20] stash: add tests for `git stash show` configPaul-Sebastian Ungureanu, Aug 30, 2018
  116. Junio C HamanoAug 30, 2018
  117. Johannes SchindelinSep 3, 2018
  118. [GSoC][PATCH v8 06/20] stash: convert apply to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  119. [GSoC][PATCH v8 07/20] stash: convert drop and clear to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  120. [GSoC][PATCH v8 09/20] stash: convert pop to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  121. [GSoC][PATCH v8 08/20] stash: convert branch to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  122. Johannes SchindelinSep 3, 2018
  123. [GSoC][PATCH v8 11/20] stash: convert show to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  124. [GSoC][PATCH v8 13/20] stash: convert store to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  125. Johannes SchindelinSep 3, 2018
  126. [GSoC][PATCH v8 14/20] stash: convert create to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  127. Johannes SchindelinSep 3, 2018
  128. Paul-Sebastian UngureanuSep 25, 2018
  129. Johannes SchindelinNov 9, 2018
  130. [GSoC][PATCH v8 12/20] stash: mention options in `show` synopsis.Paul-Sebastian Ungureanu, Aug 30, 2018
  131. [GSoC][PATCH v8 10/20] stash: convert list to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  132. [GSoC][PATCH v8 16/20] stash: make push -q quietPaul-Sebastian Ungureanu, Aug 30, 2018
  133. [GSoC][PATCH v8 17/20] stash: convert save to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  134. Johannes SchindelinSep 3, 2018
  135. Eric SunshineSep 3, 2018
  136. Johannes SchindelinSep 3, 2018
  137. [GSoC][PATCH v8 19/20] stash: optimize `get_untracked_files()` and `check_changes()`Paul-Sebastian Ungureanu, Aug 30, 2018
  138. Johannes SchindelinSep 3, 2018
  139. [GSoC][PATCH v8 18/20] stash: convert `stash--helper.c` into `stash.c`Paul-Sebastian Ungureanu, Aug 30, 2018
  140. Johannes SchindelinSep 3, 2018
  141. Paul-Sebastian UngureanuSep 25, 2018
  142. Johannes SchindelinNov 9, 2018
  143. [GSoC][PATCH v8 20/20] stash: replace all `write-tree` child processes with API callsPaul-Sebastian Ungureanu, Aug 30, 2018
  144. Johannes SchindelinSep 3, 2018
  145. [GSoC][PATCH v8 15/20] stash: convert push to builtinPaul-Sebastian Ungureanu, Aug 30, 2018
  146. Johannes SchindelinSep 3, 2018
  147. Ævar Arnfjörð BjarmasonAug 30, 2018
  148. Junio C HamanoAug 31, 2018
  149. Johannes SchindelinSep 3, 2018
  150. 00/21 Convert "git stash" to C builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  151. 01/21 sha1-name.c: add `get_oidf()` which acts like `get_oid()`Paul-Sebastian Ungureanu, Sep 25, 2018
  152. 02/21 strbuf.c: add `strbuf_join_argv()`Paul-Sebastian Ungureanu, Sep 25, 2018
  153. Thomas GummererSep 30, 2018
  154. 03/21 stash: improve option parsing test coveragePaul-Sebastian Ungureanu, Sep 25, 2018
  155. 04/21 stash: update test cases conform to coding guidelinesPaul-Sebastian Ungureanu, Sep 25, 2018
  156. Thomas GummererSep 30, 2018
  157. 05/21 stash: rename test cases to be more descriptivePaul-Sebastian Ungureanu, Sep 25, 2018
  158. 06/21 stash: add tests for `git stash show` configPaul-Sebastian Ungureanu, Sep 25, 2018
  159. 07/21 stash: convert apply to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  160. Thomas GummererSep 30, 2018
  161. 08/21 stash: convert drop and clear to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  162. 10/21 stash: convert pop to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  163. 11/21 stash: convert list to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  164. 13/21 stash: mention options in `show` synopsis.Paul-Sebastian Ungureanu, Sep 25, 2018
  165. Thomas GummererOct 2, 2018
  166. 14/21 stash: convert store to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  167. 15/21 stash: convert create to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  168. Thomas GummererOct 2, 2018
  169. 16/21 stash: convert push to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  170. Thomas GummererOct 2, 2018
  171. 17/21 stash: make push -q quietPaul-Sebastian Ungureanu, Sep 25, 2018
  172. 18/21 stash: convert save to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  173. 19/21 stash: convert `stash--helper.c` into `stash.c`Paul-Sebastian Ungureanu, Sep 25, 2018
  174. Thomas GummererOct 2, 2018
  175. 12/21 stash: convert show to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  176. 21/21 stash: replace all `write-tree` child processes with API callsPaul-Sebastian Ungureanu, Sep 25, 2018
  177. 20/21 stash: optimize `get_untracked_files()` and `check_changes()`Paul-Sebastian Ungureanu, Sep 25, 2018
  178. 09/21 stash: convert branch to builtinPaul-Sebastian Ungureanu, Sep 25, 2018
  179. Thomas GummererSep 30, 2018
  180. Junio C HamanoSep 26, 2018
  181. Joel TeichroebApr 30, 2018

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.