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