@@ -70,37 +70,37 @@ def test_get_build_info(self):
7070 def test_get_compiler (self ):
7171 getcompiler = os .path .join ('Programs' , '_getcompiler' )
7272 MOCK_COMPILER = 'MOCK_COMPILER'
73+ CC = 'gcc -std=c11'
7374
7475 for hostrunner in ('' , 'node' ):
75- makefile_vars = {
76- 'HOSTRUNNER' : hostrunner ,
77- 'CC' : 'gcc -std=c11' ,
78- }
7976 for use_cc in (False , True ):
80- with mock .patch .object (generate_getbuildinfo ,
81- 'get_makefile_vars' ,
82- return_value = makefile_vars ):
83- with mock .patch .object (generate_getbuildinfo ,
84- 'run_command' ) as mock_run_command :
85- if use_cc :
86- mock_run_command .side_effect = ('' , MOCK_COMPILER )
87- else :
88- mock_run_command .return_value = MOCK_COMPILER
89- compiler = generate_getbuildinfo ._get_compiler ()
90- self .assertEqual (compiler , MOCK_COMPILER )
91- if hostrunner :
92- cmd = [hostrunner , getcompiler ]
93- else :
94- cmd = [getcompiler ]
95- if use_cc :
96- self .assertEqual (mock_run_command .call_args_list ,
97- [
98- mock .call (cmd , check = False ),
99- mock .call (['gcc' , '-std=c11' , '--version' ], check = False ),
100- ]
101- )
102- else :
103- mock_run_command .assert_called_once_with (cmd , check = False )
77+ with (mock .patch .object (generate_getbuildinfo ,
78+ 'get_hostrunner' ,
79+ return_value = hostrunner ),
80+ mock .patch .object (generate_getbuildinfo ,
81+ 'get_makefile_cc' ,
82+ return_value = CC ),
83+ mock .patch .object (generate_getbuildinfo ,
84+ 'run_command' ) as mock_run_command ):
85+ if use_cc :
86+ mock_run_command .side_effect = ('' , MOCK_COMPILER )
87+ else :
88+ mock_run_command .return_value = MOCK_COMPILER
89+ compiler = generate_getbuildinfo ._get_compiler ()
90+ self .assertEqual (compiler , MOCK_COMPILER )
91+ if hostrunner :
92+ cmd = [hostrunner , getcompiler ]
93+ else :
94+ cmd = [getcompiler ]
95+ if use_cc :
96+ self .assertEqual (mock_run_command .call_args_list ,
97+ [
98+ mock .call (cmd , check = False ),
99+ mock .call (['gcc' , '-std=c11' , '--version' ], check = False ),
100+ ]
101+ )
102+ else :
103+ mock_run_command .assert_called_once_with (cmd , check = False )
104104
105105 def test_compact_compiler (self ):
106106 get_compiler = generate_getbuildinfo .get_compiler
0 commit comments