Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7f5c22c0
Kaydet (Commit)
7f5c22c0
authored
Eyl 02, 2013
tarafından
Eli Bendersky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactor the main function of regrtest a bit.
Moving subprocess execution of tests into a function.
üst
a35adf5b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
23 deletions
+33
-23
regrtest.py
Lib/test/regrtest.py
+33
-23
No files found.
Lib/test/regrtest.py
Dosyayı görüntüle @
7f5c22c0
...
@@ -426,6 +426,38 @@ def _parse_args(args, **kwargs):
...
@@ -426,6 +426,38 @@ def _parse_args(args, **kwargs):
return
ns
return
ns
def
run_test_in_subprocess
(
testname
,
ns
):
"""Run the given test in a subprocess with --slaveargs.
ns is the option Namespace parsed from command-line arguments. regrtest
is invoked in a subprocess with the --slaveargs argument; when the
subprocess exits, its return code, stdout and stderr are returned as a
3-tuple.
"""
from
subprocess
import
Popen
,
PIPE
base_cmd
=
([
sys
.
executable
]
+
support
.
args_from_interpreter_flags
()
+
[
'-X'
,
'faulthandler'
,
'-m'
,
'test.regrtest'
])
slaveargs
=
(
(
testname
,
ns
.
verbose
,
ns
.
quiet
),
dict
(
huntrleaks
=
ns
.
huntrleaks
,
use_resources
=
ns
.
use_resources
,
debug
=
ns
.
debug
,
output_on_failure
=
ns
.
verbose3
,
timeout
=
ns
.
timeout
,
failfast
=
ns
.
failfast
,
match_tests
=
ns
.
match_tests
))
# Running the child from the same working directory as regrtest's original
# invocation ensures that TEMPDIR for the child is the same when
# sysconfig.is_python_build() is true. See issue 15300.
popen
=
Popen
(
base_cmd
+
[
'--slaveargs'
,
json
.
dumps
(
slaveargs
)],
stdout
=
PIPE
,
stderr
=
PIPE
,
universal_newlines
=
True
,
close_fds
=
(
os
.
name
!=
'nt'
),
cwd
=
support
.
SAVEDCWD
)
stdout
,
stderr
=
popen
.
communicate
()
retcode
=
popen
.
wait
()
return
retcode
,
stdout
,
stderr
def
main
(
tests
=
None
,
**
kwargs
):
def
main
(
tests
=
None
,
**
kwargs
):
"""Execute a test suite.
"""Execute a test suite.
...
@@ -648,13 +680,9 @@ def main(tests=None, **kwargs):
...
@@ -648,13 +680,9 @@ def main(tests=None, **kwargs):
print
(
"Multiprocess option requires thread support"
)
print
(
"Multiprocess option requires thread support"
)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
from
queue
import
Queue
from
queue
import
Queue
from
subprocess
import
Popen
,
PIPE
debug_output_pat
=
re
.
compile
(
r"\[\d+ refs, \d+ blocks\]$"
)
debug_output_pat
=
re
.
compile
(
r"\[\d+ refs, \d+ blocks\]$"
)
output
=
Queue
()
output
=
Queue
()
pending
=
MultiprocessTests
(
tests
)
pending
=
MultiprocessTests
(
tests
)
opt_args
=
support
.
args_from_interpreter_flags
()
base_cmd
=
[
sys
.
executable
]
+
opt_args
base_cmd
+=
[
'-X'
,
'faulthandler'
,
'-m'
,
'test.regrtest'
]
def
work
():
def
work
():
# A worker thread.
# A worker thread.
try
:
try
:
...
@@ -664,25 +692,7 @@ def main(tests=None, **kwargs):
...
@@ -664,25 +692,7 @@ def main(tests=None, **kwargs):
except
StopIteration
:
except
StopIteration
:
output
.
put
((
None
,
None
,
None
,
None
))
output
.
put
((
None
,
None
,
None
,
None
))
return
return
args_tuple
=
(
retcode
,
stdout
,
stderr
=
run_test_in_subprocess
(
test
,
ns
)
(
test
,
ns
.
verbose
,
ns
.
quiet
),
dict
(
huntrleaks
=
ns
.
huntrleaks
,
use_resources
=
ns
.
use_resources
,
debug
=
ns
.
debug
,
output_on_failure
=
ns
.
verbose3
,
timeout
=
ns
.
timeout
,
failfast
=
ns
.
failfast
,
match_tests
=
ns
.
match_tests
)
)
# -E is needed by some tests, e.g. test_import
# Running the child from the same working directory ensures
# that TEMPDIR for the child is the same when
# sysconfig.is_python_build() is true. See issue 15300.
popen
=
Popen
(
base_cmd
+
[
'--slaveargs'
,
json
.
dumps
(
args_tuple
)],
stdout
=
PIPE
,
stderr
=
PIPE
,
universal_newlines
=
True
,
close_fds
=
(
os
.
name
!=
'nt'
),
cwd
=
support
.
SAVEDCWD
)
stdout
,
stderr
=
popen
.
communicate
()
retcode
=
popen
.
wait
()
# Strip last refcount output line if it exists, since it
# Strip last refcount output line if it exists, since it
# comes from the shutdown of the interpreter in the subcommand.
# comes from the shutdown of the interpreter in the subcommand.
stderr
=
debug_output_pat
.
sub
(
""
,
stderr
)
stderr
=
debug_output_pat
.
sub
(
""
,
stderr
)
...
...
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