[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

checkout_tests.py 12 (checkout_peg_rev_date) breaks on fast setups

From: Daniel Shahaf <danielsh_at_elego.de>
Date: Fri, 5 Jul 2013 07:05:33 +0300

Philip - would the following work on your machine? I'd be +1 on the
r1496127 nomination in STATUS if the following patch were (commited to
trunk and) added to it.

In case it matters, the Python version I tested it with is 2.6.

Daniel

[[[
Follow-p to r1496127: Have the test try a date which is not only
unambiguous, but also is not exactly the svn:date propval.

* subversion/tests/cmdline/checkout_tests.py
  (datetime): Import.
  (checkout_peg_rev_date): Compute a date different than the svn:date value,
    document the reason, and remove a sleep() call which is now unneeded.
]]]

Index: subversion/tests/cmdline/checkout_tests.py
===================================================================
--- subversion/tests/cmdline/checkout_tests.py (revision 1499907)
+++ subversion/tests/cmdline/checkout_tests.py (working copy)
@@ -27,6 +27,7 @@
 
 # General modules
 import sys, re, os, time, subprocess
+import datetime
 
 # Our testing module
 import svntest
@@ -660,6 +661,7 @@ def checkout_peg_rev_date(sbox):
   sbox.build()
   wc_dir = sbox.wc_dir
 
+ ## Get svn:date.
   exit_code, output, errput = svntest.main.run_svn(None, 'propget', 'svn:date',
                                                    '--revprop', '-r1',
                                                    '--strict',
@@ -666,10 +668,20 @@ def checkout_peg_rev_date(sbox):
                                                    sbox.repo_url)
   if exit_code or errput != [] or len(output) != 1:
     raise svntest.Failure("svn:date propget failed")
- r1_time = output[0]
 
- # sleep till the next second.
- time.sleep(1.1)
+ ## Increment the svn:date date by one microsecond.
+ # TODO: pass tzinfo=UTC to datetime.datetime()
+ date_pattern = re.compile(r'(\d+)-(\d+)-(\d+)T(\d\d):(\d\d):(\d\d)\.(\d+)Z$')
+ r1_time = datetime.datetime(*map(int, date_pattern.match(output[0]).groups()))
+ peg_time = r1_time + datetime.timedelta(microseconds=1)
+ assert r1_time != peg_time
+ # peg_string is, by all likelihood, younger than r1's svn:date and older than
+ # r2's svn:date. It is also not equal to either of them, so we test the
+ # binary search of svn:date values.
+ peg_string = '%04d-%02d-%02dT%02d:%02d:%02d.%06dZ' % \
+ tuple(getattr(peg_time, x)
+ for x in ["year", "month", "day", "hour", "minute",
+ "second", "microsecond"])
 
   # create a new revision
   mu_path = os.path.join(wc_dir, 'A', 'mu')
@@ -691,7 +703,7 @@ def checkout_peg_rev_date(sbox):
 
   # use an old date to checkout, that way we're sure we get the first revision
   svntest.actions.run_and_verify_checkout(sbox.repo_url +
- '@{' + r1_time + '}',
+ '@{' + peg_string + '}',
                                           checkout_target,
                                           expected_output,
                                           expected_wc)
Received on 2013-07-05 06:06:16 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.