-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnittestConverter.py
executable file
·89 lines (72 loc) · 2.64 KB
/
UnittestConverter.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/python
"""
SimpleTest to PHPUnit Converter v.0.1 by Sebastian Marek
Copyright (C) 2008 Sebastian Marek
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it
Usage: UnittestConverter -a -h [-d]
OPTIONS:
-h, --help Display this help and exit.
-a, --action convert - Converts SimpleTest tests to PHPUnit tests
create - Creates test suites
-d, --dir Convert unit tests in given directory.
-t, --transformation Use only one type of transformation.
Valid transformation keywords:
- Extends
- AssertEqual
- AssertNotEqual
- AssertReference
- IsA
- Pass
- Identical
- ExpectException
"""
import sys
import getopt
import os
from net.thornet.actionWizard.actionWizard import ActionWizard
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def main(argv=None):
workingDir = '.'
actionCalled = None
transformation = None
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "hd:a:t:", ["help","dir=","action=","transformation="])
except getopt.error, msg:
raise Usage(msg)
# process options
for o, a in opts:
if o in ("-h", "--help"):
print __doc__
sys.exit(0)
if o in ("-a", "--action"):
actionCalled = a
if o in ("-d", "--dir"):
workingDir = a
if o in ("-t", "--transformation"):
transformation = a
if actionCalled is None:
raise Usage('Missing argument - specify valid action to use')
arguments = {'workingDir': workingDir, 'transformation': transformation}
action = ActionWizard(actionCalled)
action.run(arguments)
# run Forest, run!
#testFinder = UnittestFinder(workingDir)
#testFinder.fetchFileList()
#converter = UnittestConverter()
#fileList = testFinder.getFileList()
#for file in fileList:
# print 'Converting ' + file
# converter.convert(file)
except Usage, err:
print >>sys.stderr, err.msg
print >>sys.stderr, "for help use --help"
return 2
##################### Main application start point #####################
if __name__ == "__main__":
sys.exit(main())