Re: [PATCH 2/2] t7063: mtime-mangling instead of delays in untracked cache testing

From
Junio C Hamano <hidden>
Date
2022-02-28 22:19:49
"Tao Klerks via GitGitGadget" [off-list ref] writes:
From: Tao Klerks <redacted>

The untracked cache test uses an avoid_racy function to deal with
an mtime-resolution challenge in testing: If an untracked cache
entry's mtime falls in the same second as the mtime of the index
the untracked cache was stored in, then it cannot be trusted.

Explicitly delaying tests is a simple effective strategy to
avoid these issues, but should be avoided where possible.

Switch from a delay-based strategy to instead backdating
all file changes using test-tool chmtime, where that is an
option, to shave 9 seconds off the test run time.
OK.
Don't update test cases that delay for other reasons, for now at
least (4 seconds).
Sad but one step at a time.
+chmmtime_worktree_root () {
Not "chmtime_worktree_root"?  Is doubled-m intended?
quoted hunk
+	# chmtime doesnt handle relative paths on windows, so need
+	# to "hardcode" a reference to the worktree folder name.
+	cd .. &&
+	test-tool chmtime $1 worktree &&
+	cd worktree
An unsuspecting caller will be left in a directory it didn't expect
to when "test-tool chmtime" fails, which is not nice.

	(
		cd .. &&
		test-tool chmtime "$1" worktree
	)

at least until the tool learns to do

	test-tool chmtime "$1" ../worktree

or

	test-tool -C.. chmtime "$1" worktree

Oh, isn't the last one already available?
quoted hunk
+}
+
 avoid_racy() {
 	sleep 1
 }
@@ -90,6 +98,9 @@ test_expect_success 'setup' '
 	cd worktree &&
 	mkdir done dtwo dthree &&
 	touch one two three done/one dtwo/two dthree/three &&
+	test-tool chmtime =-300 one two three done/one dtwo/two dthree/three &&
+	test-tool chmtime =-300 done dtwo dthree &&
Not a huge deal, but it would have been very nice if "test-tool chmtime"
had a "-R" option to recurse into directories.
Thread (2 messages) 2 messages, 2 authors, last reply 2022-03-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help