]> arthur.barton.de Git - bup.git/blobdiff - t/test-prune-older
tclient: invoke bup via absolute path
[bup.git] / t / test-prune-older
index 9e9d359b7568b707b5c9de366da2c56d3a4ec8da..95a26700434784755f638668c613c987e8eb1bdf 100755 (executable)
@@ -5,7 +5,7 @@ exec "$bup_python" "$0" ${1+"$@"}
 """
 # end of bup preamble
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 from collections import defaultdict
 from difflib import unified_diff
 from itertools import chain, dropwhile, groupby, takewhile
@@ -13,6 +13,7 @@ from os import environ, chdir
 from os.path import abspath, dirname
 from random import choice, randint
 from shutil import copytree, rmtree
+from subprocess import PIPE
 from sys import stderr
 from time import localtime, strftime, time
 import os, random, sys
@@ -25,11 +26,12 @@ bup_cmd = top + '/bup'
 from buptest import exc, exo, test_tempdir
 from wvtest import wvfail, wvpass, wvpasseq, wvpassne, wvstart
 
+from bup import compat
 from bup.helpers import partition, period_as_secs, readpipe
 
 
 def bup(*args):
-    return exo((bup_cmd,) + args)[0]
+    return exo((bup_cmd,) + args).out
 
 def bupc(*args):
     return exc((bup_cmd,) + args)
@@ -68,7 +70,7 @@ def expected_retentions(utcs, utc_start, spec):
         return utcs
     utcs = sorted(utcs, reverse=True)
     period_start = dict(spec)
-    for kind, duration in period_start.iteritems():
+    for kind, duration in compat.items(period_start):
         period_start[kind] = utc_start - period_as_secs(duration)
     period_start = defaultdict(lambda: float('inf'), period_start)
 
@@ -127,7 +129,7 @@ def result_diffline(x):
 def check_prune_result(expected):
     actual = sorted([int(x)
                      for x in exo(['git', 'log',
-                                   '--pretty=format:%at'])[0].splitlines()])
+                                   '--pretty=format:%at']).out.splitlines()])
     if expected != actual:
         for x in expected:
             print('ex:', x, strftime('%Y-%m-%d-%H%M%S', localtime(x)),
@@ -164,19 +166,19 @@ with test_tempdir('prune-older-') as tmpdir:
     chdir(tmpdir + '/work')
     save_utcs = create_older_random_saves(save_population, three_years_ago, now)
     chdir(tmpdir)
-    test_set_hash = exo(['git', 'show-ref', '-s', 'master'])[0].rstrip()
+    test_set_hash = exo(['git', 'show-ref', '-s', 'master']).out.rstrip()
     ls_saves = bup('ls', 'master').splitlines()
     wvpasseq(save_population + 1, len(ls_saves))
 
     wvstart('ensure everything kept, if no keep arguments')
     exc(['git', 'reset', '--hard', test_set_hash])
-    _, errmsg, proc = exo((bup_cmd,
-                           'prune-older', '-v', '--unsafe', '--no-gc',
-                           '--wrt', str(now)) \
-                          + ('master',),
-                          stdout=False, stderr=True, check=False)
-    wvpassne(proc.returncode, 0)
-    wvpass('at least one keep argument is required' in errmsg)
+    proc = exo((bup_cmd,
+                'prune-older', '-v', '--unsafe', '--no-gc',
+                '--wrt', str(now)) \
+               + ('master',),
+               stdout=None, stderr=PIPE, check=False)
+    wvpassne(proc.rc, 0)
+    wvpass('at least one keep argument is required' in proc.err)
     check_prune_result(save_utcs)