]> arthur.barton.de Git - bup.git/blobdiff - t/ns-timestamp-resolutions
test-restore-map-owner: accommodate python 3 and test there
[bup.git] / t / ns-timestamp-resolutions
index 07631276c1e441e58b28bb2e704ed87073a3d048..e8be1ef9cca727fc464f967a13f45ff7d7e03683 100755 (executable)
@@ -5,21 +5,15 @@ exec "$bup_python" "$0" ${1+"$@"}
 """
 # end of bup preamble
 
+from __future__ import absolute_import
 import os, sys
 
-argv = sys.argv
-exe = os.path.realpath(argv[0])
-exepath = os.path.split(exe)[0] or '.'
-exeprefix = os.path.split(os.path.abspath(exepath))[0]
-
-# fix the PYTHONPATH to include our lib dir
-libpath = os.path.join(exepath, '..', 'lib')
-sys.path[:0] = [libpath]
-os.environ['PYTHONPATH'] = libpath + ':' + os.environ.get('PYTHONPATH', '')
-
-import bup.xstat as xstat
+from bup.compat import argv_bytes
 from bup.helpers import handle_ctrl_c, saved_errors
+from bup.io import byte_stream
 from bup import metadata, options
+import bup.xstat as xstat
+
 
 optspec = """
 ns-timestamp-resolutions TEST_FILE_NAME
@@ -31,10 +25,13 @@ handle_ctrl_c()
 o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
 
+sys.stdout.flush()
+out = byte_stream(sys.stdout)
+
 if len(extra) != 1:
     o.fatal('must specify a test file name')
 
-target = extra[0]
+target = argv_bytes(extra[0])
 
 open(target, 'w').close()
 xstat.utime(target, (123456789, 123456789))
@@ -47,7 +44,8 @@ def ns_resolution(x):
         n *= 10
     return n
 
-print ns_resolution(meta.atime), ns_resolution(meta.mtime)
+out.write(b'%d %d\n' % (ns_resolution(meta.atime),
+                        ns_resolution(meta.mtime)))
 
 if saved_errors:
     log('warning: %d errors encountered\n' % len(saved_errors))