1
import sys, unittest, os
2
sys.path.insert(0, "../src")
5
class RdiffdirTest(unittest.TestCase):
6
"""Test rdiffdir command line program"""
7
def run(self, command): assert not os.system(command)
9
"""Make new testfiles/output dir"""
10
self.run("rm -rf testfiles/output")
11
os.mkdir("testfiles/output")
13
def run_rdiffdir(self, argstring):
14
"""Run rdiffdir with given arguments"""
15
self.run("../rdiffdir " + argstring)
17
def run_cycle(self, dirname_list):
18
"""Run diff/patch cycle on directories in dirname_list"""
19
assert len(dirname_list) >= 2
22
seq_path = path.Path("testfiles/output/sequence")
23
new_path = path.Path(dirname_list[0])
24
delta_path = path.Path("testfiles/output/delta.tar")
25
sig_path = path.Path("testfiles/output/sig.tar")
27
self.run("cp -a %s %s" % (new_path.name, seq_path.name))
29
self.run_rdiffdir("sig %s %s" % (seq_path.name, sig_path.name))
31
assert sig_path.exists()
32
assert new_path.compare_recursive(seq_path, verbose = 1)
34
for dirname in dirname_list[1:]:
35
new_path = path.Path(dirname)
38
if delta_path.exists(): delta_path.delete()
39
assert not delta_path.exists()
40
self.run_rdiffdir("delta %s %s %s" %
41
(sig_path.name, new_path.name, delta_path.name))
43
assert delta_path.exists()
46
self.run_rdiffdir("patch %s %s" % (seq_path.name, delta_path.name))
49
assert new_path.compare_recursive(seq_path, verbose = 1)
53
assert not sig_path.exists()
54
self.run_rdiffdir("sig %s %s" % (seq_path.name, sig_path.name))
56
assert sig_path.isreg()
59
"""Test cycle on testfiles/dirx"""
60
self.run_cycle(['testfiles/empty_dir',
64
'testfiles/empty_dir'])
67
if __name__ == "__main__": unittest.main()