diff --git a/IPython/testing/iptestcontroller.py b/IPython/testing/iptestcontroller.py index 498e6da..ce8bc80 100644 --- a/IPython/testing/iptestcontroller.py +++ b/IPython/testing/iptestcontroller.py @@ -29,8 +29,9 @@ import subprocess import time from .iptest import have, test_group_names as py_test_group_names, test_sections +from IPython.utils.path import compress_user from IPython.utils.py3compat import bytes_to_str -from IPython.utils.sysinfo import sys_info +from IPython.utils.sysinfo import get_sys_info from IPython.utils.tempdir import TemporaryDirectory @@ -270,8 +271,20 @@ def do_run(controller): def report(): """Return a string with a summary report of test-related variables.""" + inf = get_sys_info() + out = [] + def _add(name, value): + out.append((name, value)) - out = [ sys_info(), '\n'] + _add('IPython version', inf['ipython_version']) + _add('IPython commit', "{} ({})".format(inf['commit_hash'], inf['commit_source'])) + _add('IPython package', compress_user(inf['ipython_path'])) + _add('Python version', inf['sys_version'].replace('\n','')) + _add('sys.executable', compress_user(inf['sys_executable'])) + _add('Platform', inf['platform']) + + width = max(len(n) for (n,v) in out) + out = ["{:<{width}}: {}\n".format(n, v, width=width) for (n,v) in out] avail = [] not_avail = [] @@ -385,17 +398,16 @@ def run_iptestall(options): print('_'*70) print('Test suite completed for system with the following information:') print(report()) - print('Ran %s test groups in %.3fs' % (nrunners, t_tests)) - print() + took = "Took %.3fs." % t_tests print('Status: ', end='') if not failed: - print('OK') + print('OK (%d test groups).' % nrunners, took) else: # If anything went wrong, point out what command to rerun manually to # see the actual errors and individual summary failed_sections = [c.section for c in failed] print('ERROR - {} out of {} test groups failed ({}).'.format(nfail, - nrunners, ', '.join(failed_sections))) + nrunners, ', '.join(failed_sections)), took) print() print('You may wish to rerun these, with:') print(' iptest', *failed_sections) diff --git a/IPython/utils/path.py b/IPython/utils/path.py index f75af64..367fea7 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -88,6 +88,13 @@ def unquote_filename(name, win32=(sys.platform=='win32')): name = name[1:-1] return name +def compress_user(path): + """Reverse of :func:`os.path.expanduser` + """ + home = os.path.expanduser('~') + if path.startswith(home): + path = "~" + path[len(home):] + return path def get_py_filename(name, force_win32=None): """Return a valid python filename in the current directory. diff --git a/IPython/utils/sysinfo.py b/IPython/utils/sysinfo.py index 69abde2..a61c764 100644 --- a/IPython/utils/sysinfo.py +++ b/IPython/utils/sysinfo.py @@ -93,6 +93,11 @@ def pkg_info(pkg_path): default_encoding=encoding.DEFAULT_ENCODING, ) +def get_sys_info(): + """Return useful information about IPython and the system, as a dict.""" + p = os.path + path = p.dirname(p.abspath(p.join(__file__, '..'))) + return pkg_info(path) @py3compat.doctest_refactor_print def sys_info(): @@ -112,11 +117,8 @@ def sys_info(): 'sys_executable': '/usr/bin/python', 'sys_platform': 'linux2', 'sys_version': '2.6.6 (r266:84292, Sep 15 2010, 15:52:39) \\n[GCC 4.4.5]'} - """ - p = os.path - path = p.dirname(p.abspath(p.join(__file__, '..'))) - return pprint.pformat(pkg_info(path)) - + """ + return pprint.pformat(get_sys_info()) def _num_cpus_unix(): """Return the number of active CPUs on a Unix system."""