author | Mario Ferraro <fadinlight@gmail.com> |
Sun, 15 Nov 2009 22:12:20 +0100 | |
changeset 3093 | d1be59b6b627 |
parent 1278 | a7766286a7be |
permissions | -rwxr-xr-x |
828
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
1 |
# bootstrapping setuptools |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
2 |
import ez_setup |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
3 |
ez_setup.use_setuptools() |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
4 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
5 |
import os |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
6 |
import sys |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
7 |
import textwrap |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
8 |
from distutils.errors import * |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
9 |
from distutils.command.clean import clean as _clean |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
10 |
from distutils.cmd import Command |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
11 |
from setuptools import setup |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
12 |
from distutils import log |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
13 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
14 |
from distutils.core import setup |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
15 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
16 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
17 |
class clean(_clean): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
18 |
"""Also cleanup local temp files.""" |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
19 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
20 |
def run(self): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
21 |
_clean.run(self) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
22 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
23 |
import fnmatch |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
24 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
25 |
# kill temporary files |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
26 |
patterns = [ |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
27 |
# generic tempfiles |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
28 |
'*~', '*.bak', '*.pyc', |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
29 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
30 |
# tempfiles generated by ANTLR runs |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
31 |
't[0-9]*Lexer.py', 't[0-9]*Parser.py', |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
32 |
'*.tokens', '*__.g', |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
33 |
] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
34 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
35 |
for path in ('antlr3', 'unittests', 'tests'): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
36 |
path = os.path.join(os.path.dirname(__file__), path) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
37 |
if os.path.isdir(path): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
38 |
for root, dirs, files in os.walk(path, topdown=True): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
39 |
graveyard = [] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
40 |
for pat in patterns: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
41 |
graveyard.extend(fnmatch.filter(files, pat)) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
42 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
43 |
for name in graveyard: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
44 |
filePath = os.path.join(root, name) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
45 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
46 |
try: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
47 |
log.info("removing '%s'", filePath) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
48 |
os.unlink(filePath) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
49 |
except OSError, exc: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
50 |
log.warn( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
51 |
"Failed to delete '%s': %s", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
52 |
filePath, exc |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
53 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
54 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
55 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
56 |
class TestError(DistutilsError): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
57 |
pass |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
58 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
59 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
60 |
# grml.. the class name appears in the --help output: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
61 |
# ... |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
62 |
# Options for 'CmdUnitTest' command |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
63 |
# ... |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
64 |
# so I have to use a rather ugly name... |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
65 |
class unittest(Command): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
66 |
"""Run unit tests for package""" |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
67 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
68 |
description = "run unit tests for package" |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
69 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
70 |
user_options = [ |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
71 |
] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
72 |
boolean_options = [] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
73 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
74 |
def initialize_options(self): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
75 |
pass |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
76 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
77 |
def finalize_options(self): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
78 |
pass |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
79 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
80 |
def run(self): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
81 |
testDir = os.path.join(os.path.dirname(__file__), 'unittests') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
82 |
if not os.path.isdir(testDir): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
83 |
raise DistutilsFileError( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
84 |
"There is not 'unittests' directory. Did you fetch the " |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
85 |
"development version?", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
86 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
87 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
88 |
import glob |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
89 |
import imp |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
90 |
import unittest |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
91 |
import traceback |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
92 |
import StringIO |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
93 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
94 |
suite = unittest.TestSuite() |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
95 |
loadFailures = [] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
96 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
97 |
# collect tests from all unittests/test*.py files |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
98 |
testFiles = [] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
99 |
for testPath in glob.glob(os.path.join(testDir, 'test*.py')): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
100 |
testFiles.append(testPath) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
101 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
102 |
testFiles.sort() |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
103 |
for testPath in testFiles: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
104 |
testID = os.path.basename(testPath)[:-3] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
105 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
106 |
try: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
107 |
modFile, modPathname, modDescription \ |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
108 |
= imp.find_module(testID, [testDir]) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
109 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
110 |
testMod = imp.load_module( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
111 |
testID, modFile, modPathname, modDescription |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
112 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
113 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
114 |
suite.addTests( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
115 |
unittest.defaultTestLoader.loadTestsFromModule(testMod) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
116 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
117 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
118 |
except Exception: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
119 |
buf = StringIO.StringIO() |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
120 |
traceback.print_exc(file=buf) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
121 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
122 |
loadFailures.append( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
123 |
(os.path.basename(testPath), buf.getvalue()) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
124 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
125 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
126 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
127 |
runner = unittest.TextTestRunner(verbosity=2) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
128 |
result = runner.run(suite) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
129 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
130 |
for testName, error in loadFailures: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
131 |
sys.stderr.write('\n' + '='*70 + '\n') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
132 |
sys.stderr.write( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
133 |
"Failed to load test module %s\n" % testName |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
134 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
135 |
sys.stderr.write(error) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
136 |
sys.stderr.write('\n') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
137 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
138 |
if not result.wasSuccessful() or loadFailures: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
139 |
raise TestError( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
140 |
"Unit test suite failed!", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
141 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
142 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
143 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
144 |
class functest(Command): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
145 |
"""Run functional tests for package""" |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
146 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
147 |
description = "run functional tests for package" |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
148 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
149 |
user_options = [ |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
150 |
('testcase=', None, |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
151 |
"testcase to run [default: run all]"), |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
152 |
('antlr-version=', None, |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
153 |
"ANTLR version to use [default: HEAD (in ../../build)]"), |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
154 |
] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
155 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
156 |
boolean_options = [] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
157 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
158 |
def initialize_options(self): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
159 |
self.testcase = None |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
160 |
self.antlr_version = 'HEAD' |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
161 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
162 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
163 |
def finalize_options(self): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
164 |
pass |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
165 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
166 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
167 |
def run(self): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
168 |
import glob |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
169 |
import imp |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
170 |
import unittest |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
171 |
import traceback |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
172 |
import StringIO |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
173 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
174 |
testDir = os.path.join(os.path.dirname(__file__), 'tests') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
175 |
if not os.path.isdir(testDir): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
176 |
raise DistutilsFileError( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
177 |
"There is not 'tests' directory. Did you fetch the " |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
178 |
"development version?", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
179 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
180 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
181 |
# make sure, relative imports from testcases work |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
182 |
sys.path.insert(0, testDir) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
183 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
184 |
rootDir = os.path.abspath( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
185 |
os.path.join(os.path.dirname(__file__), '..', '..')) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
186 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
187 |
if self.antlr_version == 'HEAD': |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
188 |
classpath = [ |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
189 |
os.path.join(rootDir, 'build', 'classes'), |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
190 |
os.path.join(rootDir, 'build', 'rtclasses') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
191 |
] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
192 |
else: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
193 |
classpath = [ |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
194 |
os.path.join(rootDir, 'archive', |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
195 |
'antlr-%s.jar' % self.antlr_version) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
196 |
] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
197 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
198 |
classpath.extend([ |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
199 |
os.path.join(rootDir, 'lib', 'antlr-2.7.7.jar'), |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
200 |
os.path.join(rootDir, 'lib', 'stringtemplate-3.2.jar'), |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
201 |
os.path.join(rootDir, 'lib', 'junit-4.2.jar') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
202 |
]) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
203 |
os.environ['CLASSPATH'] = ':'.join(classpath) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
204 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
205 |
os.environ['ANTLRVERSION'] = self.antlr_version |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
206 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
207 |
suite = unittest.TestSuite() |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
208 |
loadFailures = [] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
209 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
210 |
# collect tests from all tests/t*.py files |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
211 |
testFiles = [] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
212 |
for testPath in glob.glob(os.path.join(testDir, 't*.py')): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
213 |
if (testPath.endswith('Lexer.py') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
214 |
or testPath.endswith('Parser.py') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
215 |
): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
216 |
continue |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
217 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
218 |
# if a single testcase has been selected, filter out all other |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
219 |
# tests |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
220 |
if (self.testcase is not None |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
221 |
and os.path.basename(testPath)[:-3] != self.testcase |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
222 |
): |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
223 |
continue |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
224 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
225 |
testFiles.append(testPath) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
226 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
227 |
testFiles.sort() |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
228 |
for testPath in testFiles: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
229 |
testID = os.path.basename(testPath)[:-3] |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
230 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
231 |
try: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
232 |
modFile, modPathname, modDescription \ |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
233 |
= imp.find_module(testID, [testDir]) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
234 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
235 |
testMod = imp.load_module( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
236 |
testID, modFile, modPathname, modDescription |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
237 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
238 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
239 |
suite.addTests( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
240 |
unittest.defaultTestLoader.loadTestsFromModule(testMod) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
241 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
242 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
243 |
except Exception: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
244 |
buf = StringIO.StringIO() |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
245 |
traceback.print_exc(file=buf) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
246 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
247 |
loadFailures.append( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
248 |
(os.path.basename(testPath), buf.getvalue()) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
249 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
250 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
251 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
252 |
runner = unittest.TextTestRunner(verbosity=2) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
253 |
result = runner.run(suite) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
254 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
255 |
for testName, error in loadFailures: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
256 |
sys.stderr.write('\n' + '='*70 + '\n') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
257 |
sys.stderr.write( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
258 |
"Failed to load test module %s\n" % testName |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
259 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
260 |
sys.stderr.write(error) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
261 |
sys.stderr.write('\n') |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
262 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
263 |
if not result.wasSuccessful() or loadFailures: |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
264 |
raise TestError( |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
265 |
"Functional test suite failed!", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
266 |
) |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
267 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
268 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
269 |
setup(name='antlr_python_runtime', |
1278
a7766286a7be
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
828
diff
changeset
|
270 |
version='3.1.1', |
828
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
271 |
packages=['antlr3'], |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
272 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
273 |
author="Benjamin Niemann", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
274 |
author_email="pink@odahoda.de", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
275 |
url="http://www.antlr.org/", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
276 |
download_url="http://www.antlr.org/download.html", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
277 |
license="BSD", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
278 |
description="Runtime package for ANTLR3", |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
279 |
long_description=textwrap.dedent('''\ |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
280 |
This is the runtime package for ANTLR3, which is required to use parsers |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
281 |
generated by ANTLR3. |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
282 |
'''), |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
283 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
284 |
|
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
285 |
cmdclass={'unittest': unittest, |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
286 |
'functest': functest, |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
287 |
'clean': clean |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
288 |
}, |
f5fd65cc3bf3
Load /Users/solydzajs/Downloads/google_appengine into
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
289 |
) |