Skip to content

Commit fd96bc7

Browse files
iamanawssteadytao
andauthored
testsuite: fix timestamp race in exclude test (#1120)
* testsuite: fix timestamp race in exclude test The same-newness files must have equal modification times, but separate touch calls can straddle a second boundary and make the destination newer. This causes --update to skip it unexpectedly. Copy the source timestamps to the destination explicitly. * testsuite: only copy update-test mtime --------- Co-authored-by: Zen Dodd <mail@steadytao.com>
1 parent 26da01a commit fd96bc7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎testsuite/exclude_test.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,15 @@
137137
up2.mkdir()
138138
(up1 / 'dst-newness').touch()
139139
(up2 / 'src-newness').touch()
140-
(up1 / 'same-newness').touch()
141-
(up2 / 'same-newness').touch()
140+
same_src = up1 / 'same-newness'
141+
same_dst = up2 / 'same-newness'
142+
same_src.touch()
143+
same_dst.touch()
144+
# Give both files the same mtime; otherwise two touch calls could straddle a
145+
# second boundary and --update would see the destination as newer.
146+
src_stat = same_src.stat()
147+
dst_stat = same_dst.stat()
148+
os.utime(same_dst, ns=(dst_stat.st_atime_ns, src_stat.st_mtime_ns))
142149
(up1 / 'extra-src').touch()
143150
(up2 / 'extra-dest').touch()
144151

0 commit comments

Comments
 (0)