Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
02d4292d
Commit
02d4292d
authored
Aug 21, 2017
by
Victor Stinner
Committed by
GitHub
Aug 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-30263: regrtest: add system load average (#3165)
Add the CPU count in the header.
parent
ec4ab09b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
Lib/test/regrtest.py
Lib/test/regrtest.py
+33
-3
Lib/test/test_regrtest.py
Lib/test/test_regrtest.py
+1
-1
No files found.
Lib/test/regrtest.py
View file @
02d4292d
...
...
@@ -295,6 +295,24 @@ def format_test_result(test_name, result):
return
fmt
%
test_name
def
cpu_count
():
# first try os.sysconf() to prevent loading the big multiprocessing module
try
:
return
os
.
sysconf
(
'SC_NPROCESSORS_ONLN'
)
except
(
AttributeError
,
ValueError
):
pass
# try multiprocessing.cpu_count()
try
:
import
multiprocessing
except
ImportError
:
pass
else
:
return
multiprocessing
.
cpu_count
()
return
None
def
unload_test_modules
(
save_modules
):
# Unload the newly imported modules (best effort finalization)
for
module
in
sys
.
modules
.
keys
():
...
...
@@ -617,15 +635,24 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
def
display_progress
(
test_index
,
test
):
# "[ 51/405/1] test_tcl"
fmt
=
"[{1:{0}}{2}/{3}] {4}"
if
bad
else
"[{1:{0}}{2}] {4}"
line
=
fmt
.
format
(
test_count_width
,
test_index
,
test_count
,
len
(
bad
),
test
)
line
=
"{1:{0}}{2}"
.
format
(
test_count_width
,
test_index
,
test_count
)
if
bad
and
not
pgo
:
line
=
'{}/{}'
.
format
(
line
,
len
(
bad
))
line
=
'[{}]'
.
format
(
line
)
# add the system load prefix: "load avg: 1.80 "
if
hasattr
(
os
,
'getloadavg'
):
load_avg_1min
=
os
.
getloadavg
()[
0
]
line
=
"load avg: {:.2f} {}"
.
format
(
load_avg_1min
,
line
)
# add the timestamp prefix: "0:01:05 "
test_time
=
time
.
time
()
-
regrtest_start_time
test_time
=
datetime
.
timedelta
(
seconds
=
int
(
test_time
))
line
=
"%s %s"
%
(
test_time
,
line
)
# add the test name
line
=
"{} {}"
.
format
(
line
,
test
)
print
(
line
)
sys
.
stdout
.
flush
()
...
...
@@ -638,6 +665,9 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
print
"== "
,
platform
.
platform
(
aliased
=
True
),
\
"%s-endian"
%
sys
.
byteorder
print
"== "
,
os
.
getcwd
()
ncpu
=
cpu_count
()
if
ncpu
:
print
"== CPU count:"
,
ncpu
print
"Testing with flags:"
,
sys
.
flags
if
randomize
:
...
...
Lib/test/test_regrtest.py
View file @
02d4292d
...
...
@@ -85,7 +85,7 @@ class BaseTestCase(unittest.TestCase):
self
.
assertRegexpMatches
(
output
,
regex
)
def
parse_executed_tests
(
self
,
output
):
regex
=
(
r'^[0-9]+:[0-9]+:[0-9]+ \
[ *[
0-9]+(?:/ *[0-9]+)*\
] (%s)
'
regex
=
(
r'^[0-9]+:[0-9]+:[0-9]+
(?:load avg: [0-9]+\
.[
0-9]{2} )?
\
[ *[
0-9]+(?:/ *[0-9]+)*\
] (%s)
'
% self.TESTNAME_REGEX)
parser = re.finditer(regex, output, re.MULTILINE)
return list(match.group(1) for match in parser)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment