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
2731c049
Kaydet (Commit)
2731c049
authored
Tem 21, 2012
tarafından
Ned Deily
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15184: Ensure configuration-related environment variables
are unset during test execution.
üst
636601df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
59 deletions
+63
-59
test__osx_support.py
Lib/test/test__osx_support.py
+63
-59
No files found.
Lib/test/test__osx_support.py
Dosyayı görüntüle @
2731c049
...
@@ -20,6 +20,14 @@ class Test_OSXSupport(unittest.TestCase):
...
@@ -20,6 +20,14 @@ class Test_OSXSupport(unittest.TestCase):
self
.
maxDiff
=
None
self
.
maxDiff
=
None
self
.
prog_name
=
'bogus_program_xxxx'
self
.
prog_name
=
'bogus_program_xxxx'
self
.
temp_path_dir
=
os
.
path
.
abspath
(
os
.
getcwd
())
self
.
temp_path_dir
=
os
.
path
.
abspath
(
os
.
getcwd
())
self
.
env
=
test
.
support
.
EnvironmentVarGuard
()
self
.
addCleanup
(
self
.
env
.
__exit__
)
for
cv
in
(
'CFLAGS'
,
'LDFLAGS'
,
'CPPFLAGS'
,
'BASECFLAGS'
,
'BLDSHARED'
,
'LDSHARED'
,
'CC'
,
'CXX'
,
'PY_CFLAGS'
,
'PY_LDFLAGS'
,
'PY_CPPFLAGS'
,
'PY_CORE_CFLAGS'
):
if
cv
in
self
.
env
:
self
.
env
.
unset
(
cv
)
def
add_expected_saved_initial_values
(
self
,
config_vars
,
expected_vars
):
def
add_expected_saved_initial_values
(
self
,
config_vars
,
expected_vars
):
# Ensure that the initial values for all modified config vars
# Ensure that the initial values for all modified config vars
...
@@ -29,31 +37,29 @@ class Test_OSXSupport(unittest.TestCase):
...
@@ -29,31 +37,29 @@ class Test_OSXSupport(unittest.TestCase):
if
config_vars
[
k
]
!=
expected_vars
[
k
])
if
config_vars
[
k
]
!=
expected_vars
[
k
])
def
test__find_executable
(
self
):
def
test__find_executable
(
self
):
with
test
.
support
.
EnvironmentVarGuard
()
as
env
:
if
self
.
env
[
'PATH'
]:
if
env
[
'PATH'
]:
self
.
env
[
'PATH'
]
=
self
.
env
[
'PATH'
]
+
':'
env
[
'PATH'
]
=
env
[
'PATH'
]
+
':'
self
.
env
[
'PATH'
]
=
self
.
env
[
'PATH'
]
+
os
.
path
.
abspath
(
self
.
temp_path_dir
)
env
[
'PATH'
]
=
env
[
'PATH'
]
+
os
.
path
.
abspath
(
self
.
temp_path_dir
)
test
.
support
.
unlink
(
self
.
prog_name
)
test
.
support
.
unlink
(
self
.
prog_name
)
self
.
assertIsNone
(
_osx_support
.
_find_executable
(
self
.
prog_name
))
self
.
assertIsNone
(
_osx_support
.
_find_executable
(
self
.
prog_name
))
self
.
addCleanup
(
test
.
support
.
unlink
,
self
.
prog_name
)
self
.
addCleanup
(
test
.
support
.
unlink
,
self
.
prog_name
)
with
open
(
self
.
prog_name
,
'w'
)
as
f
:
with
open
(
self
.
prog_name
,
'w'
)
as
f
:
f
.
write
(
"#!/bin/sh
\n
/bin/echo OK
\n
"
)
f
.
write
(
"#!/bin/sh
\n
/bin/echo OK
\n
"
)
os
.
chmod
(
self
.
prog_name
,
stat
.
S_IRWXU
)
os
.
chmod
(
self
.
prog_name
,
stat
.
S_IRWXU
)
self
.
assertEqual
(
self
.
prog_name
,
self
.
assertEqual
(
self
.
prog_name
,
_osx_support
.
_find_executable
(
self
.
prog_name
))
_osx_support
.
_find_executable
(
self
.
prog_name
))
def
test__read_output
(
self
):
def
test__read_output
(
self
):
with
test
.
support
.
EnvironmentVarGuard
()
as
env
:
if
self
.
env
[
'PATH'
]:
if
env
[
'PATH'
]:
self
.
env
[
'PATH'
]
=
self
.
env
[
'PATH'
]
+
':'
env
[
'PATH'
]
=
env
[
'PATH'
]
+
':'
self
.
env
[
'PATH'
]
=
self
.
env
[
'PATH'
]
+
os
.
path
.
abspath
(
self
.
temp_path_dir
)
env
[
'PATH'
]
=
env
[
'PATH'
]
+
os
.
path
.
abspath
(
self
.
temp_path_dir
)
test
.
support
.
unlink
(
self
.
prog_name
)
test
.
support
.
unlink
(
self
.
prog_name
)
self
.
addCleanup
(
test
.
support
.
unlink
,
self
.
prog_name
)
self
.
addCleanup
(
test
.
support
.
unlink
,
self
.
prog_name
)
with
open
(
self
.
prog_name
,
'w'
)
as
f
:
with
open
(
self
.
prog_name
,
'w'
)
as
f
:
f
.
write
(
"#!/bin/sh
\n
/bin/echo ExpectedOutput
\n
"
)
f
.
write
(
"#!/bin/sh
\n
/bin/echo ExpectedOutput
\n
"
)
os
.
chmod
(
self
.
prog_name
,
stat
.
S_IRWXU
)
os
.
chmod
(
self
.
prog_name
,
stat
.
S_IRWXU
)
self
.
assertEqual
(
'ExpectedOutput'
,
self
.
assertEqual
(
'ExpectedOutput'
,
_osx_support
.
_read_output
(
self
.
prog_name
))
_osx_support
.
_read_output
(
self
.
prog_name
))
def
test__find_build_tool
(
self
):
def
test__find_build_tool
(
self
):
out
=
_osx_support
.
_find_build_tool
(
'cc'
)
out
=
_osx_support
.
_find_build_tool
(
'cc'
)
...
@@ -133,18 +139,17 @@ class Test_OSXSupport(unittest.TestCase):
...
@@ -133,18 +139,17 @@ class Test_OSXSupport(unittest.TestCase):
}
}
self
.
add_expected_saved_initial_values
(
config_vars
,
expected_vars
)
self
.
add_expected_saved_initial_values
(
config_vars
,
expected_vars
)
with
test
.
support
.
EnvironmentVarGuard
()
as
env
:
suffix
=
(
':'
+
self
.
env
[
'PATH'
])
if
self
.
env
[
'PATH'
]
else
''
suffix
=
(
':'
+
env
[
'PATH'
])
if
env
[
'PATH'
]
else
''
self
.
env
[
'PATH'
]
=
os
.
path
.
abspath
(
self
.
temp_path_dir
)
+
suffix
env
[
'PATH'
]
=
os
.
path
.
abspath
(
self
.
temp_path_dir
)
+
suffix
for
c_name
,
c_output
in
compilers
:
for
c_name
,
c_output
in
compilers
:
test
.
support
.
unlink
(
c_name
)
test
.
support
.
unlink
(
c_name
)
self
.
addCleanup
(
test
.
support
.
unlink
,
c_name
)
self
.
addCleanup
(
test
.
support
.
unlink
,
c_name
)
with
open
(
c_name
,
'w'
)
as
f
:
with
open
(
c_name
,
'w'
)
as
f
:
f
.
write
(
"#!/bin/sh
\n
/bin/echo "
+
c_output
)
f
.
write
(
"#!/bin/sh
\n
/bin/echo "
+
c_output
)
os
.
chmod
(
c_name
,
stat
.
S_IRWXU
)
os
.
chmod
(
c_name
,
stat
.
S_IRWXU
)
self
.
assertEqual
(
expected_vars
,
self
.
assertEqual
(
expected_vars
,
_osx_support
.
_find_appropriate_compiler
(
_osx_support
.
_find_appropriate_compiler
(
config_vars
))
config_vars
))
def
test__remove_universal_flags
(
self
):
def
test__remove_universal_flags
(
self
):
config_vars
=
{
config_vars
=
{
...
@@ -195,31 +200,30 @@ class Test_OSXSupport(unittest.TestCase):
...
@@ -195,31 +200,30 @@ class Test_OSXSupport(unittest.TestCase):
config_vars
))
config_vars
))
def
test__override_all_archs
(
self
):
def
test__override_all_archs
(
self
):
with
test
.
support
.
EnvironmentVarGuard
()
as
env
:
self
.
env
[
'ARCHFLAGS'
]
=
'-arch x86_64'
env
[
'ARCHFLAGS'
]
=
'-arch x86_64'
config_vars
=
{
config_vars
=
{
'CC'
:
'clang'
,
'CC'
:
'clang'
,
'CFLAGS'
:
'-fno-strict-aliasing -g -O3 -arch ppc -arch i386 '
,
'CFLAGS'
:
'-fno-strict-aliasing -g -O3 -arch ppc -arch i386 '
,
'LDFLAGS'
:
'-arch ppc -arch i386 -g'
,
'LDFLAGS'
:
'-arch ppc -arch i386 -g'
,
'CPPFLAGS'
:
'-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk'
,
'CPPFLAGS'
:
'-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk'
,
'BLDSHARED'
:
'gcc-4.0 -bundle -arch ppc -arch i386 -g'
,
'BLDSHARED'
:
'gcc-4.0 -bundle -arch ppc -arch i386 -g'
,
'LDSHARED'
:
'gcc-4.0 -bundle -arch ppc -arch i386 '
'LDSHARED'
:
'gcc-4.0 -bundle -arch ppc -arch i386 '
'-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g'
,
'-isysroot /Developer/SDKs/MacOSX10.4u.sdk -g'
,
}
}
expected_vars
=
{
expected_vars
=
{
'CC'
:
'clang'
,
'CC'
:
'clang'
,
'CFLAGS'
:
'-fno-strict-aliasing -g -O3 -arch x86_64'
,
'CFLAGS'
:
'-fno-strict-aliasing -g -O3 -arch x86_64'
,
'LDFLAGS'
:
' -g -arch x86_64'
,
'LDFLAGS'
:
' -g -arch x86_64'
,
'CPPFLAGS'
:
'-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk'
,
'CPPFLAGS'
:
'-I. -isysroot /Developer/SDKs/MacOSX10.4u.sdk'
,
'BLDSHARED'
:
'gcc-4.0 -bundle -g -arch x86_64'
,
'BLDSHARED'
:
'gcc-4.0 -bundle -g -arch x86_64'
,
'LDSHARED'
:
'gcc-4.0 -bundle -isysroot '
'LDSHARED'
:
'gcc-4.0 -bundle -isysroot '
'/Developer/SDKs/MacOSX10.4u.sdk -g -arch x86_64'
,
'/Developer/SDKs/MacOSX10.4u.sdk -g -arch x86_64'
,
}
}
self
.
add_expected_saved_initial_values
(
config_vars
,
expected_vars
)
self
.
add_expected_saved_initial_values
(
config_vars
,
expected_vars
)
self
.
assertEqual
(
expected_vars
,
self
.
assertEqual
(
expected_vars
,
_osx_support
.
_override_all_archs
(
_osx_support
.
_override_all_archs
(
config_vars
))
config_vars
))
def
test__check_for_unavailable_sdk
(
self
):
def
test__check_for_unavailable_sdk
(
self
):
config_vars
=
{
config_vars
=
{
...
...
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