##// END OF EJS Templates
JSController working, `iptest js` runs casperjs
Paul Ivanov -
Show More
@@ -56,10 +56,13 b' class TestController(object):'
56 self.env = {}
56 self.env = {}
57 self.dirs = []
57 self.dirs = []
58
58
59
59 @property
60 @property
60 def will_run(self):
61 def will_run(self):
61 """Override in subclasses to check for dependencies."""
62 try:
62 return False
63 return test_sections[self.section].will_run
64 except KeyError:
65 return True
63
66
64 def launch(self):
67 def launch(self):
65 # print('*** ENV:', self.env) # dbg
68 # print('*** ENV:', self.env) # dbg
@@ -128,13 +131,6 b' class PyTestController(TestController):'
128 # This means we won't get odd effects from our own matplotlib config
131 # This means we won't get odd effects from our own matplotlib config
129 self.env['MPLCONFIGDIR'] = workingdir.name
132 self.env['MPLCONFIGDIR'] = workingdir.name
130
133
131 @property
132 def will_run(self):
133 try:
134 return test_sections[self.section].will_run
135 except KeyError:
136 return True
137
138 def add_xunit(self):
134 def add_xunit(self):
139 xunit_file = os.path.abspath(self.section + '.xunit.xml')
135 xunit_file = os.path.abspath(self.section + '.xunit.xml')
140 self.cmd.extend(['--with-xunit', '--xunit-file', xunit_file])
136 self.cmd.extend(['--with-xunit', '--xunit-file', xunit_file])
@@ -162,21 +158,42 b' class PyTestController(TestController):'
162 self.cmd[2] = self.pycmd
158 self.cmd[2] = self.pycmd
163 super(PyTestController, self).launch()
159 super(PyTestController, self).launch()
164
160
165 def prepare_controllers(testgroups=None, inc_slow=False):
161 class JSController(TestController):
162 """Run CasperJS tests """
163 def __init__(self, section):
164 """Create new test runner."""
165 TestController.__init__(self)
166 self.section = section
167
168 import IPython.html.tests as t
169 test_dir = os.path.join(os.path.dirname(t.__file__), 'casperjs')
170 includes = '--includes=' + os.path.join(test_dir,'util.js')
171 test_cases = os.path.join(test_dir, 'test_cases')
172 self.cmd = ['casperjs', 'test', includes, test_cases]
173
174
175 def prepare_controllers(options):
166 """Returns two lists of TestController instances, those to run, and those
176 """Returns two lists of TestController instances, those to run, and those
167 not to run."""
177 not to run."""
178 testgroups = options.testgroups
179
168 if not testgroups:
180 if not testgroups:
169 testgroups = test_group_names
181 testgroups = test_group_names
170 if not inc_slow:
182 if not options.all:
171 test_sections['parallel'].enabled = False
183 test_sections['parallel'].enabled = False
172
184
173 controllers = [PyTestController(name) for name in testgroups]
185 c_js = [JSController(name) for name in testgroups if 'js' in name]
186 c_py = [PyTestController(name) for name in testgroups if 'js' not in name]
174
187
188 configure_py_controllers(c_py, xunit=options.xunit,
189 coverage=options.coverage)
190
191 controllers = c_py + c_js
175 to_run = [c for c in controllers if c.will_run]
192 to_run = [c for c in controllers if c.will_run]
176 not_run = [c for c in controllers if not c.will_run]
193 not_run = [c for c in controllers if not c.will_run]
177 return to_run, not_run
194 return to_run, not_run
178
195
179 def configure_controllers(controllers, xunit=False, coverage=False, extra_args=()):
196 def configure_py_controllers(controllers, xunit=False, coverage=False, extra_args=()):
180 """Apply options for a collection of TestController objects."""
197 """Apply options for a collection of TestController objects."""
181 for controller in controllers:
198 for controller in controllers:
182 if xunit:
199 if xunit:
@@ -267,10 +284,7 b' def run_iptestall(options):'
267 # If running in parallel, capture output so it doesn't get interleaved
284 # If running in parallel, capture output so it doesn't get interleaved
268 TestController.buffer_output = True
285 TestController.buffer_output = True
269
286
270 to_run, not_run = prepare_controllers(options.testgroups, inc_slow=options.all)
287 to_run, not_run = prepare_controllers(options)
271
272 configure_controllers(to_run, xunit=options.xunit, coverage=options.coverage,
273 extra_args=options.extra_args)
274
288
275 def justify(ltext, rtext, width=70, fill='-'):
289 def justify(ltext, rtext, width=70, fill='-'):
276 ltext += ' '
290 ltext += ' '
General Comments 0
You need to be logged in to leave comments. Login now