##// END OF EJS Templates
Update test_pr to allow passing args to iptest
Thomas Kluyver -
Show More
@@ -41,10 +41,11 b' def get_missing_libraries(log):'
41 41 return m.group(1)
42 42
43 43 class TestRun(object):
44 def __init__(self, pr_num):
44 def __init__(self, pr_num, extra_args):
45 45 self.unavailable_pythons = []
46 46 self.venvs = []
47 47 self.pr_num = pr_num
48 self.extra_args = extra_args
48 49
49 50 self.pr = gh_api.get_pull_request(gh_project, pr_num)
50 51
@@ -131,8 +132,10 b' class TestRun(object):'
131 132 "Platform: " + sys.platform,
132 133 ""] + \
133 134 [format_result(r) for r in self.results] + \
134 ["",
135 "Not available for testing: " + ", ".join(self.unavailable_pythons)]
135 [""]
136 if self.extra_args:
137 lines.append("Extra args: %r" % self.extra_args),
138 lines.append("Not available for testing: " + ", ".join(self.unavailable_pythons))
136 139 return "\n".join(lines)
137 140
138 141 def post_results_comment(self):
@@ -156,6 +159,9 b' class TestRun(object):'
156 159 print(" Test log:", result.get('log_url') or result.log_file)
157 160 if result.missing_libraries:
158 161 print(" Libraries not available:", result.missing_libraries)
162
163 if self.extra_args:
164 print("Extra args:", self.extra_args)
159 165 print("Not available for testing:", ", ".join(self.unavailable_pythons))
160 166
161 167 def dump_results(self):
@@ -187,7 +193,7 b' class TestRun(object):'
187 193 def run(self):
188 194 for py, venv in self.venvs:
189 195 tic = time.time()
190 passed, log = run_tests(venv)
196 passed, log = run_tests(venv, self.extra_args)
191 197 elapsed = int(time.time() - tic)
192 198 print("Ran tests with %s in %is" % (py, elapsed))
193 199 missing_libraries = get_missing_libraries(log)
@@ -200,7 +206,7 b' class TestRun(object):'
200 206 )
201 207
202 208
203 def run_tests(venv):
209 def run_tests(venv, extra_args):
204 210 py = os.path.join(basedir, venv, 'bin', 'python')
205 211 print(py)
206 212 os.chdir(repodir)
@@ -226,8 +232,8 b' def run_tests(venv):'
226 232 ipython_file = check_output([py, '-c', 'import IPython; print (IPython.__file__)'])
227 233 ipython_file = ipython_file.strip().decode('utf-8')
228 234 if not ipython_file.startswith(os.path.join(basedir, venv)):
229 msg = u"IPython does not appear to be in the venv: %s" % ipython_file
230 msg += u"\nDo you use setupegg.py develop?"
235 msg = "IPython does not appear to be in the venv: %s" % ipython_file
236 msg += "\nDo you use setupegg.py develop?"
231 237 print(msg, file=sys.stderr)
232 238 return False, msg
233 239
@@ -237,7 +243,7 b' def run_tests(venv):'
237 243
238 244 print("\nRunning tests, this typically takes a few minutes...")
239 245 try:
240 return True, check_output([iptest], stderr=STDOUT).decode('utf-8')
246 return True, check_output([iptest] + extra_args, stderr=STDOUT).decode('utf-8')
241 247 except CalledProcessError as e:
242 248 return False, e.output.decode('utf-8')
243 249 finally:
@@ -245,13 +251,13 b' def run_tests(venv):'
245 251 os.environ["PATH"] = orig_path
246 252
247 253
248 def test_pr(num, post_results=True):
254 def test_pr(num, post_results=True, extra_args=None):
249 255 # Get Github authorisation first, so that the user is prompted straight away
250 256 # if their login is needed.
251 257 if post_results:
252 258 gh_api.get_auth_token()
253 259
254 testrun = TestRun(num)
260 testrun = TestRun(num, extra_args or [])
255 261
256 262 testrun.get_branch()
257 263
@@ -278,5 +284,5 b" if __name__ == '__main__':"
278 284 help="Publish the results to Github")
279 285 parser.add_argument('number', type=int, help="The pull request number")
280 286
281 args = parser.parse_args()
282 test_pr(args.number, post_results=args.publish)
287 args, extra_args = parser.parse_known_args()
288 test_pr(args.number, post_results=args.publish, extra_args=extra_args)
General Comments 0
You need to be logged in to leave comments. Login now