@@ -1596,15 +1596,27 @@ def mock_trial(value: str) -> T.Iterable[None]:
15961596 ('aarch64_be' , 'aarch64' ),
15971597 ]
15981598
1599+ cc = ClangCCompiler ([], [], 'fake' , MachineChoice .HOST , False , mock .Mock ())
1600+
15991601 with mock .patch ('mesonbuild.environment.any_compiler_has_define' , mock .Mock (return_value = False )):
16001602 for test , expected in cases :
16011603 with self .subTest (test , has_define = False ), mock_trial (test ):
1602- actual = mesonbuild .environment .detect_cpu_family ({})
1604+ actual = mesonbuild .environment .detect_cpu_family ({'c' : cc })
16031605 self .assertEqual (actual , expected )
16041606
16051607 with mock .patch ('mesonbuild.environment.any_compiler_has_define' , mock .Mock (return_value = True )):
16061608 for test , expected in [('x86_64' , 'x86' ), ('aarch64' , 'arm' ), ('ppc' , 'ppc64' ), ('mips64' , 'mips64' )]:
16071609 with self .subTest (test , has_define = True ), mock_trial (test ):
1610+ actual = mesonbuild .environment .detect_cpu_family ({'c' : cc })
1611+ self .assertEqual (actual , expected )
1612+
1613+ # machine_info_can_run calls detect_cpu_family with no compilers at all
1614+ with mock .patch (
1615+ 'mesonbuild.environment.any_compiler_has_define' ,
1616+ mock .Mock (side_effect = AssertionError ('Should not be called' )),
1617+ ):
1618+ for test , expected in [('mips64' , 'mips64' )]:
1619+ with self .subTest (test , has_compiler = False ), mock_trial (test ):
16081620 actual = mesonbuild .environment .detect_cpu_family ({})
16091621 self .assertEqual (actual , expected )
16101622
@@ -1633,15 +1645,26 @@ def mock_trial(value: str) -> T.Iterable[None]:
16331645 ('aarch64_be' , 'aarch64' ),
16341646 ]
16351647
1648+ cc = ClangCCompiler ([], [], 'fake' , MachineChoice .HOST , False , mock .Mock ())
1649+
16361650 with mock .patch ('mesonbuild.environment.any_compiler_has_define' , mock .Mock (return_value = False )):
16371651 for test , expected in cases :
16381652 with self .subTest (test , has_define = False ), mock_trial (test ):
1639- actual = mesonbuild .environment .detect_cpu ({})
1653+ actual = mesonbuild .environment .detect_cpu ({'c' : cc })
16401654 self .assertEqual (actual , expected )
16411655
16421656 with mock .patch ('mesonbuild.environment.any_compiler_has_define' , mock .Mock (return_value = True )):
16431657 for test , expected in [('x86_64' , 'i686' ), ('aarch64' , 'arm' ), ('ppc' , 'ppc64' ), ('mips64' , 'mips64' )]:
16441658 with self .subTest (test , has_define = True ), mock_trial (test ):
1659+ actual = mesonbuild .environment .detect_cpu ({'c' : cc })
1660+ self .assertEqual (actual , expected )
1661+
1662+ with mock .patch (
1663+ 'mesonbuild.environment.any_compiler_has_define' ,
1664+ mock .Mock (side_effect = AssertionError ('Should not be called' )),
1665+ ):
1666+ for test , expected in [('mips64' , 'mips64' )]:
1667+ with self .subTest (test , has_compiler = False ), mock_trial (test ):
16451668 actual = mesonbuild .environment .detect_cpu ({})
16461669 self .assertEqual (actual , expected )
16471670
0 commit comments