1818 import generate_getbuildinfo
1919
2020SRC_DIR = os .path .dirname (test_tools .toolsdir )
21+ SCRIPT_NAME = 'generate_getbuildinfo.py'
2122
2223
2324class TestGetBuildInfo (unittest .TestCase ):
@@ -102,6 +103,7 @@ def test_get_compiler(self):
102103 mock_run_command .assert_called_once_with (cmd , check = False )
103104
104105 def test_compact_compiler (self ):
106+ get_compiler = generate_getbuildinfo .get_compiler
105107 compact_compiler = generate_getbuildinfo .compact_compiler
106108
107109 def check (compiler , expected ):
@@ -143,6 +145,13 @@ def check_unchanged(compiler):
143145 check_unchanged ('GCC 15.2.0' )
144146 check_unchanged ('MSC v.1951 32 bit (Intel)' )
145147
148+ with support .captured_stdout () as stdout :
149+ compiler = get_compiler ('Clang 21.0.0 (clang-2100.1.1.101)' )
150+ self .assertEqual (compiler , '[Clang 21.0.0]' )
151+ self .assertEqual (stdout .getvalue (),
152+ f"{ SCRIPT_NAME } : Truncate compiler string 'Clang 21.0.0 "
153+ "(clang-2100.1.1.101)' to 'Clang 21.0.0'\n " )
154+
146155 def test_functional (self ):
147156 old_locale = locale .setlocale (locale .LC_ALL )
148157 self .addCleanup (locale .setlocale , locale .LC_ALL , old_locale )
@@ -165,7 +174,7 @@ def test_functional(self):
165174 env ['SOURCE_DATE_EPOCH' ] = str (1791419852 )
166175 with support .captured_stdout () as stdout :
167176 generate_getbuildinfo .main ()
168- self .assertEqual (stdout .getvalue (), f'{ filename } updated\n ' )
177+ self .assertEqual (stdout .getvalue (), f'{ SCRIPT_NAME } : { filename } updated\n ' )
169178
170179 with open (filename ) as fp :
171180 output = fp .read ()
0 commit comments