Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / node_modules / grunt / node_modules / gzip-js / test / runner.py
1 #!/usr/bin/env python
2
3 import os
4 import sys
5 import shutil
6 from colorama import Fore
7 import argparse
8 import zipTest
9 import unzipTest
10
11 parser = argparse.ArgumentParser(description='Process command-line arguments')
12 parser.add_argument('--file', '-f', metavar='path/to/file', type=str, nargs='?', help='Path to file to use for test')
13 parser.add_argument('--level', '-l', metavar='#', type=int, nargs='?', help='Compression level')
14 parser.add_argument('--no-delete', const=True, default=False, nargs='?', help='Don\'t delete files produced for test')
15 parser.add_argument('--test', default='both', nargs='?', help='Which test to run (zip, unzip, both)')
16
17 args = parser.parse_args()
18
19 allPassed = True
20
21 outDir = 'test-outs'
22
23 # make the test-outs directory
24 try:
25         os.mkdir(outDir)
26 except:
27         pass
28
29 delete = not getattr(args, 'no_delete')
30 level = getattr(args, 'level')
31 inFile = getattr(args, 'file')
32 test = getattr(args, 'test')
33
34 if test == 'zip' or test == 'both':
35         print Fore.CYAN + 'Running zip tests' + Fore.RESET
36         # if the user specifies a file, only run that test
37         if inFile != None:
38                 allPassed = zipTest.runTest(inFile, level)
39         else:
40                 allPassed = zipTest.runAll(level)
41
42 if test == 'unzip' or test == 'both':
43         print Fore.CYAN + 'Running unzip tests' + Fore.RESET
44         # if the user specifies a file, only run that test
45         if inFile != None:
46                 allPassed = unzipTest.runTest(inFile, level)
47         else:
48                 allPassed = unzipTest.runAll(level)
49
50 if delete:
51         shutil.rmtree(outDir)
52
53 if allPassed:
54         print Fore.GREEN + 'All tests passed!' + Fore.RESET
55 else:
56         print Fore.RED + 'Automated test failed' + Fore.RESET
57         sys.exit(1)