96322eeb10108f8c844bd4ad329443faa3041860.svn-base
1.56 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
56
57
#!/usr/bin/env python
import os
import sys
import shutil
from colorama import Fore
import argparse
import zipTest
import unzipTest
parser = argparse.ArgumentParser(description='Process command-line arguments')
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')
parser.add_argument('--test', default='both', nargs='?', help='Which test to run (zip, unzip, both)')
args = parser.parse_args()
allPassed = True
outDir = 'test-outs'
# make the test-outs directory
try:
os.mkdir(outDir)
except:
pass
delete = not getattr(args, 'no_delete')
level = getattr(args, 'level')
inFile = getattr(args, 'file')
test = getattr(args, 'test')
if test == 'zip' or test == 'both':
print Fore.CYAN + 'Running zip tests' + Fore.RESET
# if the user specifies a file, only run that test
if inFile != None:
allPassed = zipTest.runTest(inFile, level)
else:
allPassed = zipTest.runAll(level)
if test == 'unzip' or test == 'both':
print Fore.CYAN + 'Running unzip tests' + Fore.RESET
# if the user specifies a file, only run that test
if inFile != None:
allPassed = unzipTest.runTest(inFile, level)
else:
allPassed = unzipTest.runAll(level)
if delete:
shutil.rmtree(outDir)
if allPassed:
print Fore.GREEN + 'All tests passed!' + Fore.RESET
else:
print Fore.RED + 'Automated test failed' + Fore.RESET
sys.exit(1)