kumar303 / nosejs (http://pypi.python.org/pypi/NoseJS)
NoseJS is a Nose plugin for integrating JavaScript tests into a Python test suite.
Clone this repository (size: 149.7 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/kumar303/nosejs/
| commit 50: | 50f96115556f |
| parent 49: | d6eab3155312 |
| branch: | default |
tweaked a few values in lint TestCase to try and get error reporting working
13 months ago
Changed (Δ266 bytes):
raw changeset »
nosejs/lint.py (38 lines added, 27 lines removed)
Up to file-list nosejs/lint.py:
| … | … | @@ -20,9 +20,8 @@ class JsLintTestCase(unittest.TestCase): |
20 |
20 |
self.jsl_bin = jsl_bin |
21 |
21 |
self.jsl_options = jsl_options or [] |
22 |
22 |
self.filename = filename |
23 |
# self.shortDescription = self.__repr__ |
|
24 |
23 |
self.stop_on_error = stop_on_error |
25 |
super(JsLintTestCase, self).__init__( |
|
24 |
super(JsLintTestCase, self).__init__() |
|
26 |
25 |
|
27 |
26 |
def runTest(self): |
28 |
27 |
pass |
| … | … | @@ -31,8 +30,8 @@ class JsLintTestCase(unittest.TestCase): |
31 |
30 |
cmd = [self.jsl_bin] |
32 |
31 |
cmd.extend(self.jsl_options) |
33 |
32 |
|
34 |
start = '=NOSEJS=START=' |
|
35 |
sep = '=NOSEJS=SEP=' |
|
33 |
start = '=NJS=ST=' |
|
34 |
sep = '=NJS=SEP=' |
|
36 |
35 |
|
37 |
36 |
cmd.extend([ |
38 |
37 |
'-output-format', (start + '__FILE__' + sep + '__LINE__' + sep + '__ERROR__'), |
| … | … | @@ -45,32 +44,44 @@ class JsLintTestCase(unittest.TestCase): |
45 |
44 |
) |
46 |
45 |
output = p.stdout.read() |
47 |
46 |
returncode = p.wait() |
48 |
if returncode != 0: |
|
49 |
# or use result.stream ? |
|
50 |
|
|
47 |
try: |
|
48 |
if returncode != 0: |
|
49 |
# or use result.stream ? |
|
50 |
# sys.stdout.write(output) |
|
51 |
51 |
|
52 |
msgs = output.split(start) |
|
53 |
for msg in msgs: |
|
54 |
if msg.strip() == '': |
|
55 |
continue |
|
56 |
try: |
|
57 |
file, line, error = msg.split(sep) |
|
58 |
except: |
|
59 |
log.debug("Could not split %s using markers" % msg) |
|
60 |
|
|
52 |
msgs = output.split(start) |
|
53 |
for msg in msgs: |
|
54 |
if msg.strip() == '': |
|
55 |
continue |
|
56 |
try: |
|
57 |
file, line, error = msg.split(sep) |
|
58 |
except: |
|
59 |
log.debug("Could not split %s using markers" % msg) |
|
60 |
raise |
|
61 |
61 |
|
62 |
# log.debug("Extracted file %s, line %s, error %s" % (file, line, error)) |
|
63 |
error = error.strip() |
|
64 |
if error.startswith('lint warning:'): |
|
65 |
etype = JsLintWarning |
|
66 |
else: |
|
67 |
etype = JsLintError |
|
68 |
|
|
62 |
# log.debug("Extracted file %s, line %s, error %s" % (file, line, error)) |
|
63 |
error = error.strip() |
|
64 |
if error.startswith('lint warning:'): |
|
65 |
etype = JsLintWarning |
|
66 |
else: |
|
67 |
etype = JsLintError |
|
68 |
result.addError(self, (etype, "%s:%s %s" % (file, line, error), None)) |
|
69 |
69 |
|
70 |
if self.stop_on_error: |
|
71 |
break |
|
72 |
else: |
|
73 |
result.addSuccess(self) |
|
70 |
if self.stop_on_error: |
|
71 |
break |
|
72 |
else: |
|
73 |
result.addSuccess(self) |
|
74 |
finally: |
|
75 |
result.stopTest(self) |
|
76 |
||
77 |
def address(self): |
|
78 |
return (self.id(), None, None) |
|
79 |
||
80 |
def id(self): |
|
81 |
return repr(self) |
|
82 |
||
83 |
def shortDescription(self): |
|
84 |
return repr(self) |
|
74 |
85 |
|
75 |
86 |
def __repr__(self): |
76 |
87 |
return "javascript-lint: %s" % self.filename |
