]> arthur.barton.de Git - bup.git/commitdiff
test-prune-older: avoid duplicate save times
authorRob Browning <rlb@defaultvalue.org>
Thu, 15 Dec 2016 18:45:19 +0000 (12:45 -0600)
committerRob Browning <rlb@defaultvalue.org>
Thu, 15 Dec 2016 18:45:23 +0000 (12:45 -0600)
When creating the list of random save times make sure to avoid any
duplicates since the timestamp is also the trivial commit content.
Otherwise the git commit for the second save dies with "nothing to
commit, working tree clean".

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
t/test-prune-older

index 11aa861b580a5b5f6a29b013a6a1fbac54de400e..b53eb4518b5b5f7ef0aebd8aba2842a5b08bc52e 100755 (executable)
@@ -63,7 +63,10 @@ def create_older_random_saves(n, start_utc, end_utc):
     with open('foo', 'w') as f:
         pass
     exc(['git', 'add', 'foo'])
-    utcs = sorted(randint(start_utc, end_utc) for x in xrange(n))
+    utcs = set()
+    while len(utcs) != n:
+        utcs.add(randint(start_utc, end_utc))
+    utcs = sorted(utcs)
     for utc in utcs:
         with open('foo', 'w') as f:
             f.write(str(utc) + '\n')