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

[PATCH 2/7] diff-highlight: use test_tick in graph test

From
Jeff King <peff@peff.net>
Date
Mar 21, 2018, 05:48 UTC
Message-ID
<20180321054840.GB14016@sigill.intra.peff.net>
In-Reply-To
<20180321054718.GA13936@sigill.intra.peff.net>

The exact ordering output by Git may depend on the commit timestamps, so let's make sure they're actually monotonically increasing, and not all the same (or worse, subject to how long the test script takes to run).

Let's use test_tick to make sure this is stable. Note that we actually have to rearrange the order of the branches to match the expected graph structure (which means that previously we might racily have been testing a slightly different output, though the test is written in such a way that we'd still pass).

Signed-off-by: Jeff King <peff@peff.net>
---
 .../diff-highlight/t/t9400-diff-highlight.sh   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/contrib/diff-highlight/t/t9400-diff-highlight.sh b/contrib/diff-highlight/t/t9400-diff-highlight.sh
index bf62f036c7..deab90ed91 100755
--- a/contrib/diff-highlight/t/t9400-diff-highlight.sh
+++ b/contrib/diff-highlight/t/t9400-diff-highlight.sh
@@ -52,9 +52,9 @@ test_strip_patch_header () {
 # dh_test_setup_history generates a contrived graph such that we have at least
 # 1 nesting (E) and 2 nestings (F).
 #
-#	  A branch
+#	  A master
 #	 /
-#	D---E---F master
+#	D---E---F branch
 #
 #	git log --all --graph
 #	* commit
@@ -74,18 +74,22 @@ dh_test_setup_history () {
 
 	cat file1 >file &&
 	git add file &&
+	test_tick &&
 	git commit -m "D" &&
 
 	git checkout -b branch &&
 	cat file2 >file &&
-	git commit -a -m "A" &&
-
-	git checkout master &&
-	cat file2 >file &&
+	test_tick &&
 	git commit -a -m "E" &&
 
 	cat file3 >file &&
-	git commit -a -m "F"
+	test_tick &&
+	git commit -a -m "F" &&
+
+	git checkout master &&
+	cat file2 >file &&
+	test_tick &&
+	git commit -a -m "A"
 }
 
 left_trim () {
-- 
2.17.0.rc0.402.ged0b3fd1ee
Previous: Jeff KingNext: Jeff King
Message 7 of 15 in “[BUG] log --graph corrupts patch”
  1. Phillip WoodMar 19, 2018
  2. Jeff KingMar 20, 2018
  3. Phillip WoodMar 20, 2018
  4. Jeff KingMar 20, 2018
  5. Jeff KingMar 21, 2018
  6. 1/7 diff-highlight: correct test graph diagramJeff King, Mar 21, 2018
  7. 2/7 diff-highlight: use test_tick in graph testJeff King, Mar 21, 2018
  8. 3/7 diff-highlight: prefer "echo" to "cat" in testsJeff King, Mar 21, 2018
  9. 4/7 diff-highlight: test interleaved parallel lines of historyJeff King, Mar 21, 2018
  10. 5/7 diff-highlight: test graphs with --colorJeff King, Mar 21, 2018
  11. 6/7 diff-highlight: use flush() helper consistentlyJeff King, Mar 21, 2018
  12. 7/7 diff-highlight: detect --graph by indentJeff King, Mar 21, 2018
  13. Phillip WoodMar 22, 2018
  14. Jeff KingMar 22, 2018
  15. Junio C HamanoMar 21, 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.