]> arthur.barton.de Git - bup.git/commitdiff
Move t/*.py to lib/bup/t/*.py.
authorAvery Pennarun <apenwarr@gmail.com>
Wed, 14 Jul 2010 06:59:03 +0000 (02:59 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Wed, 14 Jul 2010 07:36:21 +0000 (03:36 -0400)
Since the tests in that directory are all tests of lib/bup/*.py anyway,
this is a more consistent location for them.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
16 files changed:
Makefile
lib/__init__.py [new file with mode: 0644]
lib/bup/t/__init__.py [new file with mode: 0644]
lib/bup/t/tclient.py [new file with mode: 0644]
lib/bup/t/tgit.py [new file with mode: 0644]
lib/bup/t/thelpers.py [new file with mode: 0644]
lib/bup/t/tindex.py [new file with mode: 0644]
lib/bup/t/toptions.py [new file with mode: 0644]
lib/bup/t/tshquote.py [new file with mode: 0644]
t/__init__.py [deleted file]
t/tclient.py [deleted file]
t/tgit.py [deleted file]
t/thelpers.py [deleted file]
t/tindex.py [deleted file]
t/toptions.py [deleted file]
t/tshquote.py [deleted file]

index 262873046bda8b62659af3f98ce3a55d7292a6f0..d12fc39b91ea823ff499d62c77e0d3a398160d0a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -70,7 +70,7 @@ lib/bup/_version.py:
 runtests: all runtests-python runtests-cmdline
 
 runtests-python:
-       $(PYTHON) wvtest.py $(wildcard t/t*.py)
+       $(PYTHON) wvtest.py $(wildcard t/t*.py lib/*/t/t*.py)
        
 runtests-cmdline: all
        t/test.sh
diff --git a/lib/__init__.py b/lib/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lib/bup/t/__init__.py b/lib/bup/t/__init__.py
new file mode 100644 (file)
index 0000000..172f040
--- /dev/null
@@ -0,0 +1,2 @@
+import sys
+sys.path[:0] = ['../..']
diff --git a/lib/bup/t/tclient.py b/lib/bup/t/tclient.py
new file mode 100644 (file)
index 0000000..4a409a0
--- /dev/null
@@ -0,0 +1,53 @@
+import sys, os, time, random, subprocess
+from bup import client, git, hashsplit
+from wvtest import *
+
+def randbytes(sz):
+    s = ''
+    for i in xrange(sz):
+        s += chr(random.randrange(0,256))
+    return s
+
+s1 = randbytes(10000)
+s2 = randbytes(10000)
+    
+@wvtest
+def test_server_split_with_indexes():
+    os.environ['BUP_MAIN_EXE'] = '../../../bup'
+    os.environ['BUP_DIR'] = bupdir = 'buptest_tclient.tmp'
+    subprocess.call(['rm', '-rf', bupdir])
+    git.init_repo(bupdir)
+    lw = git.PackWriter()
+    c = client.Client(bupdir, create=True)
+    rw = c.new_packwriter()
+
+    lw.new_blob(s1)
+    lw.close()
+
+    rw.new_blob(s2)
+    rw.breakpoint()
+    rw.new_blob(s1)
+    
+
+@wvtest
+def test_midx_refreshing():
+    os.environ['BUP_MAIN_EXE'] = bupmain = '../../../bup'
+    os.environ['BUP_DIR'] = bupdir = 'buptest_tmidx.tmp'
+    subprocess.call(['rm', '-rf', bupdir])
+    git.init_repo(bupdir)
+    lw = git.PackWriter()
+    lw.new_blob(s1)
+    lw.breakpoint()
+    lw.new_blob(s2)
+    del lw
+    pi = git.PackIdxList(bupdir + '/objects/pack')
+    WVPASSEQ(len(pi.packs), 2)
+    pi.refresh()
+    WVPASSEQ(len(pi.packs), 2)
+    subprocess.call([bupmain, 'midx', '-f'])
+    pi.refresh()
+    WVPASSEQ(len(pi.packs), 1)
+    pi.refresh(skip_midx=True)
+    WVPASSEQ(len(pi.packs), 2)
+    pi.refresh(skip_midx=False)
+    WVPASSEQ(len(pi.packs), 1)
diff --git a/lib/bup/t/tgit.py b/lib/bup/t/tgit.py
new file mode 100644 (file)
index 0000000..83faadc
--- /dev/null
@@ -0,0 +1,90 @@
+import time
+from bup import git
+from bup.helpers import *
+from wvtest import *
+
+
+@wvtest
+def testmangle():
+    afile  = 0100644
+    afile2 = 0100770
+    alink  = 0120000
+    adir   = 0040000
+    adir2  = 0040777
+    WVPASSEQ(git.mangle_name("a", adir2, adir), "a")
+    WVPASSEQ(git.mangle_name(".bup", adir2, adir), ".bup.bupl")
+    WVPASSEQ(git.mangle_name("a.bupa", adir2, adir), "a.bupa.bupl")
+    WVPASSEQ(git.mangle_name("b.bup", alink, alink), "b.bup.bupl")
+    WVPASSEQ(git.mangle_name("b.bu", alink, alink), "b.bu")
+    WVPASSEQ(git.mangle_name("f", afile, afile2), "f")
+    WVPASSEQ(git.mangle_name("f.bup", afile, afile2), "f.bup.bupl")
+    WVPASSEQ(git.mangle_name("f.bup", afile, adir), "f.bup.bup")
+    WVPASSEQ(git.mangle_name("f", afile, adir), "f.bup")
+
+    WVPASSEQ(git.demangle_name("f.bup"), ("f", git.BUP_CHUNKED))
+    WVPASSEQ(git.demangle_name("f.bupl"), ("f", git.BUP_NORMAL))
+    WVPASSEQ(git.demangle_name("f.bup.bupl"), ("f.bup", git.BUP_NORMAL))
+
+    # for safety, we ignore .bup? suffixes we don't recognize.  Future
+    # versions might implement a .bup[a-z] extension as something other
+    # than BUP_NORMAL.
+    WVPASSEQ(git.demangle_name("f.bupa"), ("f.bupa", git.BUP_NORMAL))
+
+
+@wvtest
+def testencode():
+    s = 'hello world'
+    looseb = ''.join(git._encode_looseobj('blob', s))
+    looset = ''.join(git._encode_looseobj('tree', s))
+    loosec = ''.join(git._encode_looseobj('commit', s))
+    packb = ''.join(git._encode_packobj('blob', s))
+    packt = ''.join(git._encode_packobj('tree', s))
+    packc = ''.join(git._encode_packobj('commit', s))
+    WVPASSEQ(git._decode_looseobj(looseb), ('blob', s))
+    WVPASSEQ(git._decode_looseobj(looset), ('tree', s))
+    WVPASSEQ(git._decode_looseobj(loosec), ('commit', s))
+    WVPASSEQ(git._decode_packobj(packb), ('blob', s))
+    WVPASSEQ(git._decode_packobj(packt), ('tree', s))
+    WVPASSEQ(git._decode_packobj(packc), ('commit', s))
+
+
+@wvtest
+def testpacks():
+    git.init_repo('pybuptest.tmp')
+    git.verbose = 1
+
+    now = str(time.time())  # hopefully not in any packs yet
+    w = git.PackWriter()
+    w.write('blob', now)
+    w.write('blob', now)
+    w.abort()
+    
+    w = git.PackWriter()
+    hashes = []
+    nobj = 1000
+    for i in range(nobj):
+        hashes.append(w.write('blob', str(i)))
+    log('\n')
+    nameprefix = w.close()
+    print repr(nameprefix)
+    WVPASS(os.path.exists(nameprefix + '.pack'))
+    WVPASS(os.path.exists(nameprefix + '.idx'))
+
+    r = git.PackIdx(nameprefix + '.idx')
+    print repr(r.fanout)
+
+    for i in range(nobj):
+        WVPASS(r.find_offset(hashes[i]) > 0)
+    WVPASS(r.exists(hashes[99]))
+    WVFAIL(r.exists('\0'*20))
+
+    pi = iter(r)
+    for h in sorted(hashes):
+        WVPASSEQ(str(pi.next()).encode('hex'), h.encode('hex'))
+
+    WVFAIL(r.find_offset('\0'*20))
+
+    r = git.PackIdxList('pybuptest.tmp/objects/pack')
+    WVPASS(r.exists(hashes[5]))
+    WVPASS(r.exists(hashes[6]))
+    WVFAIL(r.exists('\0'*20))
diff --git a/lib/bup/t/thelpers.py b/lib/bup/t/thelpers.py
new file mode 100644 (file)
index 0000000..9f24962
--- /dev/null
@@ -0,0 +1,12 @@
+from bup.helpers import *
+from wvtest import *
+
+@wvtest
+def test_parse_num():
+    pn = parse_num
+    WVPASSEQ(pn('1'), 1)
+    WVPASSEQ(pn('0'), 0)
+    WVPASSEQ(pn('1.5k'), 1536)
+    WVPASSEQ(pn('2 gb'), 2*1024*1024*1024)
+    WVPASSEQ(pn('1e+9 k'), 1000000000 * 1024)
+    WVPASSEQ(pn('-3e-3mb'), int(-0.003 * 1024 * 1024))
diff --git a/lib/bup/t/tindex.py b/lib/bup/t/tindex.py
new file mode 100644 (file)
index 0000000..1fee408
--- /dev/null
@@ -0,0 +1,122 @@
+import os
+from bup import index
+from bup.helpers import *
+from wvtest import *
+
+@wvtest
+def index_basic():
+    cd = os.path.realpath('../../../t')
+    WVPASS(cd)
+    sd = os.path.realpath(cd + '/sampledata')
+    WVPASSEQ(index.realpath(cd + '/sampledata'), cd + '/sampledata')
+    WVPASSEQ(os.path.realpath(cd + '/sampledata/x'), sd + '/x')
+    WVPASSEQ(os.path.realpath(cd + '/sampledata/etc'), os.path.realpath('/etc'))
+    WVPASSEQ(index.realpath(cd + '/sampledata/etc'), sd + '/etc')
+
+
+@wvtest
+def index_writer():
+    unlink('index.tmp')
+    ds = os.stat('.')
+    fs = os.stat('tindex.py')
+    w = index.Writer('index.tmp')
+    w.add('/var/tmp/sporky', fs)
+    w.add('/etc/passwd', fs)
+    w.add('/etc/', ds)
+    w.add('/', ds)
+    w.close()
+
+
+def dump(m):
+    for e in list(m):
+        print '%s%s %s' % (e.is_valid() and ' ' or 'M',
+                           e.is_fake() and 'F' or ' ',
+                           e.name)
+
+def fake_validate(*l):
+    for i in l:
+        for e in i:
+            e.validate(0100644, index.FAKE_SHA)
+            e.repack()
+
+def eget(l, ename):
+    for e in l:
+        if e.name == ename:
+            return e
+
+
+@wvtest
+def index_dirty():
+    unlink('index.tmp')
+    unlink('index2.tmp')
+    ds = os.stat('.')
+    fs = os.stat('tindex.py')
+    
+    w1 = index.Writer('index.tmp')
+    w1.add('/a/b/x', fs)
+    w1.add('/a/b/c', fs)
+    w1.add('/a/b/', ds)
+    w1.add('/a/', ds)
+    #w1.close()
+    WVPASS()
+
+    w2 = index.Writer('index2.tmp')
+    w2.add('/a/b/n/2', fs)
+    #w2.close()
+    WVPASS()
+
+    w3 = index.Writer('index3.tmp')
+    w3.add('/a/c/n/3', fs)
+    #w3.close()
+    WVPASS()
+
+    r1 = w1.new_reader()
+    r2 = w2.new_reader()
+    r3 = w3.new_reader()
+    WVPASS()
+
+    r1all = [e.name for e in r1]
+    WVPASSEQ(r1all,
+             ['/a/b/x', '/a/b/c', '/a/b/', '/a/', '/'])
+    r2all = [e.name for e in r2]
+    WVPASSEQ(r2all,
+             ['/a/b/n/2', '/a/b/n/', '/a/b/', '/a/', '/'])
+    r3all = [e.name for e in r3]
+    WVPASSEQ(r3all,
+             ['/a/c/n/3', '/a/c/n/', '/a/c/', '/a/', '/'])
+    m = index.MergeIter([r2,r1,r3])
+    all = [e.name for e in m]
+    WVPASSEQ(all,
+             ['/a/c/n/3', '/a/c/n/', '/a/c/',
+              '/a/b/x', '/a/b/n/2', '/a/b/n/', '/a/b/c',
+              '/a/b/', '/a/', '/'])
+    fake_validate(r1)
+    dump(r1)
+
+    print [hex(e.flags) for e in r1]
+    WVPASSEQ([e.name for e in r1 if e.is_valid()], r1all)
+    WVPASSEQ([e.name for e in r1 if not e.is_valid()], [])
+    WVPASSEQ([e.name for e in m if not e.is_valid()],
+             ['/a/c/n/3', '/a/c/n/', '/a/c/',
+              '/a/b/n/2', '/a/b/n/', '/a/b/', '/a/', '/'])
+
+    expect_invalid = ['/'] + r2all + r3all
+    expect_real = (set(r1all) - set(r2all) - set(r3all)) \
+                    | set(['/a/b/n/2', '/a/c/n/3'])
+    dump(m)
+    for e in m:
+        print e.name, hex(e.flags), e.ctime
+        eiv = e.name in expect_invalid
+        er  = e.name in expect_real
+        WVPASSEQ(eiv, not e.is_valid())
+        WVPASSEQ(er, e.is_real())
+    fake_validate(r2, r3)
+    dump(m)
+    WVPASSEQ([e.name for e in m if not e.is_valid()], [])
+    
+    e = eget(m, '/a/b/c')
+    e.invalidate()
+    e.repack()
+    dump(m)
+    WVPASSEQ([e.name for e in m if not e.is_valid()],
+             ['/a/b/c', '/a/b/', '/a/', '/'])
diff --git a/lib/bup/t/toptions.py b/lib/bup/t/toptions.py
new file mode 100644 (file)
index 0000000..da78995
--- /dev/null
@@ -0,0 +1,49 @@
+from bup import options
+from wvtest import *
+
+@wvtest
+def test_optdict():
+    d = options.OptDict()
+    WVPASS('foo')
+    d['x'] = 5
+    d['y'] = 4
+    d['z'] = 99
+    WVPASSEQ(d.x, 5)
+    WVPASSEQ(d.y, 4)
+    WVPASSEQ(d.z, 99)
+    try:
+        print d.p
+    except:
+        WVPASS("invalid args don't match")
+    else:
+        WVFAIL("exception expected")
+
+
+optspec = """
+prog <optionset> [stuff...]
+prog [-t] <boggle>
+--
+t       test
+q,quiet   quiet
+l,longoption=   long option with parameters and a really really long description that will require wrapping
+p= short option with parameters
+onlylong  long option with no short
+neveropt never called options
+"""
+
+@wvtest
+def test_options():
+    o = options.Options('exename', optspec)
+    (opt,flags,extra) = o.parse(['-tttqp', 7, '--longoption', '19',
+                                 'hanky', '--onlylong'])
+    WVPASSEQ(flags[0], ('-t', ''))
+    WVPASSEQ(flags[1], ('-t', ''))
+    WVPASSEQ(flags[2], ('-t', ''))
+    WVPASSEQ(flags[3], ('-q', ''))
+    WVPASSEQ(flags[4], ('-p', 7))
+    WVPASSEQ(flags[5], ('--longoption', '19'))
+    WVPASSEQ(extra, ['hanky'])
+    WVPASSEQ((opt.t, opt.q, opt.p, opt.l, opt.onlylong,
+              opt.neveropt), (3,1,7,19,1,None))
+    (opt,flags,extra) = o.parse(['--onlylong', '-t', '--no-onlylong'])
+    WVPASSEQ((opt.t, opt.q, opt.onlylong), (1, None, 0))
diff --git a/lib/bup/t/tshquote.py b/lib/bup/t/tshquote.py
new file mode 100644 (file)
index 0000000..15b06ec
--- /dev/null
@@ -0,0 +1,44 @@
+from bup import shquote
+from wvtest import *
+
+def qst(line):
+    return [s[1] for s in shquote.quotesplit(line)]
+
+@wvtest
+def test_shquote():
+    WVPASSEQ(qst("""  this is    basic \t\n\r text  """),
+             ['this', 'is', 'basic', 'text'])
+    WVPASSEQ(qst(r""" \"x\" "help" 'yelp' """), ['"x"', 'help', 'yelp'])
+    WVPASSEQ(qst(r""" "'\"\"'" '\"\'' """), ["'\"\"'", '\\"\''])
+
+    WVPASSEQ(shquote.quotesplit('  this is "unfinished'),
+             [(2,'this'), (7,'is'), (10,'unfinished')])
+
+    WVPASSEQ(shquote.quotesplit('"silly"\'will'),
+             [(0,'silly'), (7,'will')])
+
+    WVPASSEQ(shquote.unfinished_word('this is a "billy" "goat'),
+             ('"', 'goat'))
+    WVPASSEQ(shquote.unfinished_word("'x"),
+             ("'", 'x'))
+    WVPASSEQ(shquote.unfinished_word("abra cadabra "),
+             (None, ''))
+    WVPASSEQ(shquote.unfinished_word("abra cadabra"),
+             (None, 'cadabra'))
+
+    (qtype, word) = shquote.unfinished_word("this is /usr/loc")
+    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
+             "al")
+    (qtype, word) = shquote.unfinished_word("this is '/usr/loc")
+    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
+             "al'")
+    (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
+    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
+             "al\"")
+    (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
+    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", False),
+             "al")
+    (qtype, word) = shquote.unfinished_word("this is \\ hammer\\ \"")
+    WVPASSEQ(word, ' hammer "')
+    WVPASSEQ(shquote.what_to_add(qtype, word, " hammer \"time\"", True),
+             "time\\\"")
diff --git a/t/__init__.py b/t/__init__.py
deleted file mode 100644 (file)
index cb95e53..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-import sys
-sys.path[:0] = ['lib']
diff --git a/t/tclient.py b/t/tclient.py
deleted file mode 100644 (file)
index d6f236a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-import sys, os, time, random, subprocess
-sys.path.append('../lib')
-from bup import client, git, hashsplit
-from wvtest import *
-
-def randbytes(sz):
-    s = ''
-    for i in xrange(sz):
-        s += chr(random.randrange(0,256))
-    return s
-
-s1 = randbytes(10000)
-s2 = randbytes(10000)
-    
-@wvtest
-def test_server_split_with_indexes():
-    os.environ['BUP_MAIN_EXE'] = '../bup'
-    os.environ['BUP_DIR'] = bupdir = 'buptest_tclient.tmp'
-    subprocess.call(['rm', '-rf', bupdir])
-    git.init_repo(bupdir)
-    lw = git.PackWriter()
-    c = client.Client(bupdir, create=True)
-    rw = c.new_packwriter()
-
-    lw.new_blob(s1)
-    lw.close()
-
-    rw.new_blob(s2)
-    rw.breakpoint()
-    rw.new_blob(s1)
-    
-
-@wvtest
-def test_midx_refreshing():
-    os.environ['BUP_MAIN_EXE'] = bupmain = '../bup'
-    os.environ['BUP_DIR'] = bupdir = 'buptest_tmidx.tmp'
-    subprocess.call(['rm', '-rf', bupdir])
-    git.init_repo(bupdir)
-    lw = git.PackWriter()
-    lw.new_blob(s1)
-    lw.breakpoint()
-    lw.new_blob(s2)
-    del lw
-    pi = git.PackIdxList(bupdir + '/objects/pack')
-    WVPASSEQ(len(pi.packs), 2)
-    pi.refresh()
-    WVPASSEQ(len(pi.packs), 2)
-    subprocess.call([bupmain, 'midx', '-f'])
-    pi.refresh()
-    WVPASSEQ(len(pi.packs), 1)
-    pi.refresh(skip_midx=True)
-    WVPASSEQ(len(pi.packs), 2)
-    pi.refresh(skip_midx=False)
-    WVPASSEQ(len(pi.packs), 1)
diff --git a/t/tgit.py b/t/tgit.py
deleted file mode 100644 (file)
index 83faadc..0000000
--- a/t/tgit.py
+++ /dev/null
@@ -1,90 +0,0 @@
-import time
-from bup import git
-from bup.helpers import *
-from wvtest import *
-
-
-@wvtest
-def testmangle():
-    afile  = 0100644
-    afile2 = 0100770
-    alink  = 0120000
-    adir   = 0040000
-    adir2  = 0040777
-    WVPASSEQ(git.mangle_name("a", adir2, adir), "a")
-    WVPASSEQ(git.mangle_name(".bup", adir2, adir), ".bup.bupl")
-    WVPASSEQ(git.mangle_name("a.bupa", adir2, adir), "a.bupa.bupl")
-    WVPASSEQ(git.mangle_name("b.bup", alink, alink), "b.bup.bupl")
-    WVPASSEQ(git.mangle_name("b.bu", alink, alink), "b.bu")
-    WVPASSEQ(git.mangle_name("f", afile, afile2), "f")
-    WVPASSEQ(git.mangle_name("f.bup", afile, afile2), "f.bup.bupl")
-    WVPASSEQ(git.mangle_name("f.bup", afile, adir), "f.bup.bup")
-    WVPASSEQ(git.mangle_name("f", afile, adir), "f.bup")
-
-    WVPASSEQ(git.demangle_name("f.bup"), ("f", git.BUP_CHUNKED))
-    WVPASSEQ(git.demangle_name("f.bupl"), ("f", git.BUP_NORMAL))
-    WVPASSEQ(git.demangle_name("f.bup.bupl"), ("f.bup", git.BUP_NORMAL))
-
-    # for safety, we ignore .bup? suffixes we don't recognize.  Future
-    # versions might implement a .bup[a-z] extension as something other
-    # than BUP_NORMAL.
-    WVPASSEQ(git.demangle_name("f.bupa"), ("f.bupa", git.BUP_NORMAL))
-
-
-@wvtest
-def testencode():
-    s = 'hello world'
-    looseb = ''.join(git._encode_looseobj('blob', s))
-    looset = ''.join(git._encode_looseobj('tree', s))
-    loosec = ''.join(git._encode_looseobj('commit', s))
-    packb = ''.join(git._encode_packobj('blob', s))
-    packt = ''.join(git._encode_packobj('tree', s))
-    packc = ''.join(git._encode_packobj('commit', s))
-    WVPASSEQ(git._decode_looseobj(looseb), ('blob', s))
-    WVPASSEQ(git._decode_looseobj(looset), ('tree', s))
-    WVPASSEQ(git._decode_looseobj(loosec), ('commit', s))
-    WVPASSEQ(git._decode_packobj(packb), ('blob', s))
-    WVPASSEQ(git._decode_packobj(packt), ('tree', s))
-    WVPASSEQ(git._decode_packobj(packc), ('commit', s))
-
-
-@wvtest
-def testpacks():
-    git.init_repo('pybuptest.tmp')
-    git.verbose = 1
-
-    now = str(time.time())  # hopefully not in any packs yet
-    w = git.PackWriter()
-    w.write('blob', now)
-    w.write('blob', now)
-    w.abort()
-    
-    w = git.PackWriter()
-    hashes = []
-    nobj = 1000
-    for i in range(nobj):
-        hashes.append(w.write('blob', str(i)))
-    log('\n')
-    nameprefix = w.close()
-    print repr(nameprefix)
-    WVPASS(os.path.exists(nameprefix + '.pack'))
-    WVPASS(os.path.exists(nameprefix + '.idx'))
-
-    r = git.PackIdx(nameprefix + '.idx')
-    print repr(r.fanout)
-
-    for i in range(nobj):
-        WVPASS(r.find_offset(hashes[i]) > 0)
-    WVPASS(r.exists(hashes[99]))
-    WVFAIL(r.exists('\0'*20))
-
-    pi = iter(r)
-    for h in sorted(hashes):
-        WVPASSEQ(str(pi.next()).encode('hex'), h.encode('hex'))
-
-    WVFAIL(r.find_offset('\0'*20))
-
-    r = git.PackIdxList('pybuptest.tmp/objects/pack')
-    WVPASS(r.exists(hashes[5]))
-    WVPASS(r.exists(hashes[6]))
-    WVFAIL(r.exists('\0'*20))
diff --git a/t/thelpers.py b/t/thelpers.py
deleted file mode 100644 (file)
index 9f24962..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-from bup.helpers import *
-from wvtest import *
-
-@wvtest
-def test_parse_num():
-    pn = parse_num
-    WVPASSEQ(pn('1'), 1)
-    WVPASSEQ(pn('0'), 0)
-    WVPASSEQ(pn('1.5k'), 1536)
-    WVPASSEQ(pn('2 gb'), 2*1024*1024*1024)
-    WVPASSEQ(pn('1e+9 k'), 1000000000 * 1024)
-    WVPASSEQ(pn('-3e-3mb'), int(-0.003 * 1024 * 1024))
diff --git a/t/tindex.py b/t/tindex.py
deleted file mode 100644 (file)
index d237757..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-import os
-from bup import index
-from bup.helpers import *
-from wvtest import *
-
-@wvtest
-def index_basic():
-    cd = os.path.realpath('')
-    WVPASS(cd)
-    sd = os.path.realpath('sampledata')
-    WVPASSEQ(index.realpath('sampledata'), cd + '/sampledata')
-    WVPASSEQ(os.path.realpath('sampledata/x'), sd + '/x')
-    WVPASSEQ(os.path.realpath('sampledata/etc'), os.path.realpath('/etc'))
-    WVPASSEQ(index.realpath('sampledata/etc'), sd + '/etc')
-
-
-@wvtest
-def index_writer():
-    unlink('index.tmp')
-    ds = os.stat('.')
-    fs = os.stat('tindex.py')
-    w = index.Writer('index.tmp')
-    w.add('/var/tmp/sporky', fs)
-    w.add('/etc/passwd', fs)
-    w.add('/etc/', ds)
-    w.add('/', ds)
-    w.close()
-
-
-def dump(m):
-    for e in list(m):
-        print '%s%s %s' % (e.is_valid() and ' ' or 'M',
-                           e.is_fake() and 'F' or ' ',
-                           e.name)
-
-def fake_validate(*l):
-    for i in l:
-        for e in i:
-            e.validate(0100644, index.FAKE_SHA)
-            e.repack()
-
-def eget(l, ename):
-    for e in l:
-        if e.name == ename:
-            return e
-
-
-@wvtest
-def index_dirty():
-    unlink('index.tmp')
-    unlink('index2.tmp')
-    ds = os.stat('.')
-    fs = os.stat('tindex.py')
-    
-    w1 = index.Writer('index.tmp')
-    w1.add('/a/b/x', fs)
-    w1.add('/a/b/c', fs)
-    w1.add('/a/b/', ds)
-    w1.add('/a/', ds)
-    #w1.close()
-    WVPASS()
-
-    w2 = index.Writer('index2.tmp')
-    w2.add('/a/b/n/2', fs)
-    #w2.close()
-    WVPASS()
-
-    w3 = index.Writer('index3.tmp')
-    w3.add('/a/c/n/3', fs)
-    #w3.close()
-    WVPASS()
-
-    r1 = w1.new_reader()
-    r2 = w2.new_reader()
-    r3 = w3.new_reader()
-    WVPASS()
-
-    r1all = [e.name for e in r1]
-    WVPASSEQ(r1all,
-             ['/a/b/x', '/a/b/c', '/a/b/', '/a/', '/'])
-    r2all = [e.name for e in r2]
-    WVPASSEQ(r2all,
-             ['/a/b/n/2', '/a/b/n/', '/a/b/', '/a/', '/'])
-    r3all = [e.name for e in r3]
-    WVPASSEQ(r3all,
-             ['/a/c/n/3', '/a/c/n/', '/a/c/', '/a/', '/'])
-    m = index.MergeIter([r2,r1,r3])
-    all = [e.name for e in m]
-    WVPASSEQ(all,
-             ['/a/c/n/3', '/a/c/n/', '/a/c/',
-              '/a/b/x', '/a/b/n/2', '/a/b/n/', '/a/b/c',
-              '/a/b/', '/a/', '/'])
-    fake_validate(r1)
-    dump(r1)
-
-    print [hex(e.flags) for e in r1]
-    WVPASSEQ([e.name for e in r1 if e.is_valid()], r1all)
-    WVPASSEQ([e.name for e in r1 if not e.is_valid()], [])
-    WVPASSEQ([e.name for e in m if not e.is_valid()],
-             ['/a/c/n/3', '/a/c/n/', '/a/c/',
-              '/a/b/n/2', '/a/b/n/', '/a/b/', '/a/', '/'])
-
-    expect_invalid = ['/'] + r2all + r3all
-    expect_real = (set(r1all) - set(r2all) - set(r3all)) \
-                    | set(['/a/b/n/2', '/a/c/n/3'])
-    dump(m)
-    for e in m:
-        print e.name, hex(e.flags), e.ctime
-        eiv = e.name in expect_invalid
-        er  = e.name in expect_real
-        WVPASSEQ(eiv, not e.is_valid())
-        WVPASSEQ(er, e.is_real())
-    fake_validate(r2, r3)
-    dump(m)
-    WVPASSEQ([e.name for e in m if not e.is_valid()], [])
-    
-    e = eget(m, '/a/b/c')
-    e.invalidate()
-    e.repack()
-    dump(m)
-    WVPASSEQ([e.name for e in m if not e.is_valid()],
-             ['/a/b/c', '/a/b/', '/a/', '/'])
diff --git a/t/toptions.py b/t/toptions.py
deleted file mode 100644 (file)
index da78995..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-from bup import options
-from wvtest import *
-
-@wvtest
-def test_optdict():
-    d = options.OptDict()
-    WVPASS('foo')
-    d['x'] = 5
-    d['y'] = 4
-    d['z'] = 99
-    WVPASSEQ(d.x, 5)
-    WVPASSEQ(d.y, 4)
-    WVPASSEQ(d.z, 99)
-    try:
-        print d.p
-    except:
-        WVPASS("invalid args don't match")
-    else:
-        WVFAIL("exception expected")
-
-
-optspec = """
-prog <optionset> [stuff...]
-prog [-t] <boggle>
---
-t       test
-q,quiet   quiet
-l,longoption=   long option with parameters and a really really long description that will require wrapping
-p= short option with parameters
-onlylong  long option with no short
-neveropt never called options
-"""
-
-@wvtest
-def test_options():
-    o = options.Options('exename', optspec)
-    (opt,flags,extra) = o.parse(['-tttqp', 7, '--longoption', '19',
-                                 'hanky', '--onlylong'])
-    WVPASSEQ(flags[0], ('-t', ''))
-    WVPASSEQ(flags[1], ('-t', ''))
-    WVPASSEQ(flags[2], ('-t', ''))
-    WVPASSEQ(flags[3], ('-q', ''))
-    WVPASSEQ(flags[4], ('-p', 7))
-    WVPASSEQ(flags[5], ('--longoption', '19'))
-    WVPASSEQ(extra, ['hanky'])
-    WVPASSEQ((opt.t, opt.q, opt.p, opt.l, opt.onlylong,
-              opt.neveropt), (3,1,7,19,1,None))
-    (opt,flags,extra) = o.parse(['--onlylong', '-t', '--no-onlylong'])
-    WVPASSEQ((opt.t, opt.q, opt.onlylong), (1, None, 0))
diff --git a/t/tshquote.py b/t/tshquote.py
deleted file mode 100644 (file)
index 15b06ec..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-from bup import shquote
-from wvtest import *
-
-def qst(line):
-    return [s[1] for s in shquote.quotesplit(line)]
-
-@wvtest
-def test_shquote():
-    WVPASSEQ(qst("""  this is    basic \t\n\r text  """),
-             ['this', 'is', 'basic', 'text'])
-    WVPASSEQ(qst(r""" \"x\" "help" 'yelp' """), ['"x"', 'help', 'yelp'])
-    WVPASSEQ(qst(r""" "'\"\"'" '\"\'' """), ["'\"\"'", '\\"\''])
-
-    WVPASSEQ(shquote.quotesplit('  this is "unfinished'),
-             [(2,'this'), (7,'is'), (10,'unfinished')])
-
-    WVPASSEQ(shquote.quotesplit('"silly"\'will'),
-             [(0,'silly'), (7,'will')])
-
-    WVPASSEQ(shquote.unfinished_word('this is a "billy" "goat'),
-             ('"', 'goat'))
-    WVPASSEQ(shquote.unfinished_word("'x"),
-             ("'", 'x'))
-    WVPASSEQ(shquote.unfinished_word("abra cadabra "),
-             (None, ''))
-    WVPASSEQ(shquote.unfinished_word("abra cadabra"),
-             (None, 'cadabra'))
-
-    (qtype, word) = shquote.unfinished_word("this is /usr/loc")
-    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
-             "al")
-    (qtype, word) = shquote.unfinished_word("this is '/usr/loc")
-    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
-             "al'")
-    (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
-    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
-             "al\"")
-    (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
-    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", False),
-             "al")
-    (qtype, word) = shquote.unfinished_word("this is \\ hammer\\ \"")
-    WVPASSEQ(word, ' hammer "')
-    WVPASSEQ(shquote.what_to_add(qtype, word, " hammer \"time\"", True),
-             "time\\\"")