Skip to content

Commit 55f9116

Browse files
committed
Fix new test case
Address the following: * use the compiler's executable extension in asserts * remove any environment variables that may have been injected by CI * add a pragma to ignore a line without coverage Signed-off-by: Vincent Fazio <[email protected]>
1 parent c0d6d71 commit 55f9116

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

distutils/compilers/C/tests/test_unix.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def gcv(v):
260260
def gcvs(*args, _orig=sysconfig.get_config_vars):
261261
if args:
262262
return list(map(sysconfig.get_config_var, args))
263-
return _orig()
263+
return _orig() # pragma: no cover
264264

265265
sysconfig.get_config_var = gcv
266266
sysconfig.get_config_vars = gcvs
@@ -270,6 +270,10 @@ def gcvs(*args, _orig=sysconfig.get_config_vars):
270270
mock.patch.object(self.cc, 'mkpath', return_value=None),
271271
EnvironmentVarGuard() as env,
272272
):
273+
# override environment overrides in case they're specified by CI
274+
del env['CXX']
275+
del env['LDCXXSHARED']
276+
273277
sysconfig.customize_compiler(self.cc)
274278
assert self.cc.linker_so_cxx[0:2] == ['ccache', 'g++-4.2']
275279
assert self.cc.linker_exe_cxx[0:2] == ['ccache', 'g++-4.2']
@@ -280,7 +284,7 @@ def gcvs(*args, _orig=sysconfig.get_config_vars):
280284

281285
self.cc.link_executable([], 'a.out', target_lang='c++')
282286
call_args = mock_spawn.call_args[0][0]
283-
expected = ['ccache', 'g++-4.2', '-o', 'a.out']
287+
expected = ['ccache', 'g++-4.2', '-o', self.cc.executable_filename('a.out')]
284288
assert call_args[:4] == expected
285289

286290
env['LDCXXSHARED'] = 'wrapper g++-4.2 -bundle -undefined dynamic_lookup'
@@ -295,7 +299,12 @@ def gcvs(*args, _orig=sysconfig.get_config_vars):
295299

296300
self.cc.link_executable([], 'a.out', target_lang='c++')
297301
call_args = mock_spawn.call_args[0][0]
298-
expected = ['wrapper', 'g++-4.2', '-o', 'a.out']
302+
expected = [
303+
'wrapper',
304+
'g++-4.2',
305+
'-o',
306+
self.cc.executable_filename('a.out'),
307+
]
299308
assert call_args[:4] == expected
300309

301310
@pytest.mark.skipif('platform.system == "Windows"')

0 commit comments

Comments
 (0)