diff options
author | Mats Wichmann <mats@linux.com> | 2018-08-30 15:31:21 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2018-08-30 15:31:21 (GMT) |
commit | c487700ccd4cae873170b812c2f201f1400d8dea (patch) | |
tree | 51a6f1a89ae86aa4ebf375e6d419daabd17359a1 /runtest.py | |
parent | 0357e3670d475fbd0a1b56b6fb05f78e92ad8485 (diff) | |
download | SCons-c487700ccd4cae873170b812c2f201f1400d8dea.zip SCons-c487700ccd4cae873170b812c2f201f1400d8dea.tar.gz SCons-c487700ccd4cae873170b812c2f201f1400d8dea.tar.bz2 |
Do not use time.clock for Py3 in runtest
time.clock is deprecated since Python 3.3 and will be removed in
Python 3.8. 3.7 started issuing DeprecationWarning, which
fails about 16 tests in AppVeyor CI (and running manually),
since the warning appears in stderr stream and so real vs expected
does not match any longer. Arguably the tests could be fixed to
do a different check (contains rather than exactly-equal), but
a change needs to be made anyway.
use time.perf_counter as the time function for Python 3. This
works for Windows and non-Windows; however since this function
did not exist in 2.7 (added for 3.3), the Py2 case is left, which
selects between time.clock and time.time depending on OS.
Note this addresses runtest.py, but not code in bench/, which
need attention also. Suggest that be a separate change since
it's not failing tests.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'runtest.py')
-rwxr-xr-x | runtest.py | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -95,11 +95,12 @@ import time import threading try: # python3 from queue import Queue + PY3=True except ImportError as e: # python2 from Queue import Queue + PY3=False import subprocess - cwd = os.getcwd() baseline = 0 @@ -770,10 +771,13 @@ os.environ["python_executable"] = python # but time.time() does a better job on Linux systems, so let that be # the non-Windows default. -if sys.platform == 'win32': - time_func = time.clock +if PY3: + time_func = time.perf_counter else: - time_func = time.time + if sys.platform == 'win32': + time_func = time.clock + else: + time_func = time.time if print_times: print_time_func = lambda fmt, time: sys.stdout.write(fmt % time) |