From 61554ad37b32001f352739382e79f8639dea3c31 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 5 Aug 2023 11:40:04 +0100 Subject: [PATCH] tests: Assert that mips64 kernel is detected as mips64 with no compilers Reproduces: https://github.com/mesonbuild/meson/issues/12017 Signed-off-by: Simon McVittie --- unittests/internaltests.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/unittests/internaltests.py b/unittests/internaltests.py index 89979cd94..56d36117a 100644 --- a/unittests/internaltests.py +++ b/unittests/internaltests.py @@ -1600,6 +1600,16 @@ class InternalTests(unittest.TestCase): actual = mesonbuild.environment.detect_cpu_family({'c': cc}) self.assertEqual(actual, expected) + # machine_info_can_run calls detect_cpu_family with no compilers at all + with mock.patch( + 'mesonbuild.environment.any_compiler_has_define', + mock.Mock(side_effect=AssertionError('Should not be called')), + ): + for test, expected in [('mips64', 'mips64')]: + with self.subTest(test, has_compiler=False), mock_trial(test): + actual = mesonbuild.environment.detect_cpu_family({}) + self.assertEqual(actual, expected) + def test_detect_cpu(self) -> None: @contextlib.contextmanager @@ -1639,6 +1649,15 @@ class InternalTests(unittest.TestCase): actual = mesonbuild.environment.detect_cpu({'c': cc}) self.assertEqual(actual, expected) + with mock.patch( + 'mesonbuild.environment.any_compiler_has_define', + mock.Mock(side_effect=AssertionError('Should not be called')), + ): + for test, expected in [('mips64', 'mips64')]: + with self.subTest(test, has_compiler=False), mock_trial(test): + actual = mesonbuild.environment.detect_cpu({}) + self.assertEqual(actual, expected) + def test_interpreter_unpicklable(self) -> None: build = mock.Mock() build.environment = mock.Mock()