889fc852c265ca11d4b554ba3f021d5bde4a600a.svn-base
1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
import argparse
import deflate
import inflate
from colorama import Fore
testDir = 'test-files'
outDir = 'test-outs'
allPassed = True
parser = argparse.ArgumentParser(description='Process command-line arguments')
parser.add_argument('--test', metavar='path/to/file', type=str, default='both', nargs='?', help='Which test to run: deflate, inflate, or both')
parser.add_argument('--file', '-f', metavar='path/to/file', type=str, nargs='?', help='Path to file to use for test')
parser.add_argument('--level', '-l', metavar='#', type=int, nargs='?', help='Compression level')
parser.add_argument('--no-delete', const=True, default=False, nargs='?', help='Don\'t delete files produced for test')
args = parser.parse_args()
delete = not getattr(args, 'no_delete')
level = getattr(args, 'level')
inFile = getattr(args, 'file')
test = getattr(args, 'test')
if test == 'deflate' or test == 'both':
print Fore.CYAN + 'Running deflate tests' + Fore.RESET
passed = True
if inFile != None:
passed = deflate.runTest(inFile, level, delete, outDir)
else:
passed = deflate.runAll(level, delete, testDir, outDir)
# if we fail one test, we fail the entire test
allPassed = allPassed and passed
if test == 'inflate' or test == 'both':
print Fore.CYAN + 'Running inflate tests' + Fore.RESET
passed = True
if inFile != None:
passed = inflate.runTest(inFile, level, delete, outDir)
else:
passed = inflate.runAll(level, delete, testDir, outDir)
# if we fail one test, we fail the entire test
allPassed = allPassed and passed
if allPassed:
print Fore.GREEN + 'All tests passed!' + Fore.RESET
else:
print Fore.RED + 'Automated test failed' + Fore.RESET