Skip to content

Commit

Permalink
unit tests: make the test_c_cpp_stds test more robust
Browse files Browse the repository at this point in the history
Check clang-cl as well as cl, and clang as well as gcc. Also raise a
skip rather than a pass if the compiler is not supported
  • Loading branch information
dcbaker committed Sep 12, 2024
1 parent d2ab6d5 commit 981afbc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4999,7 +4999,7 @@ def test_configure_same_noop(self):
olddata = newdata
oldmtime = newmtime

def test_c_cpp_stds(self):
def test_c_cpp_stds(self) -> None:
testdir = os.path.join(self.unit_test_dir, '115 c cpp stds')
self.init(testdir)
# Invalid values should fail whatever compiler we have
Expand All @@ -5011,7 +5011,7 @@ def test_c_cpp_stds(self):
self.setconf('-Dc_std=c++11')
env = get_fake_env()
cc = detect_c_compiler(env, MachineChoice.HOST)
if cc.get_id() == 'msvc':
if cc.get_id() in {'msvc', 'clang-cl'}:
# default_option should have selected those
self.assertEqual(self.getconf('c_std'), 'c89')
self.assertEqual(self.getconf('cpp_std'), 'vc++11')
Expand All @@ -5024,7 +5024,7 @@ def test_c_cpp_stds(self):
# The first supported std should be selected
self.setconf('-Dcpp_std=gnu++11,vc++11,c++11')
self.assertEqual(self.getconf('cpp_std'), 'vc++11')
elif cc.get_id() == 'gcc':
elif cc.get_id() in {'gcc', 'clang'}:
# default_option should have selected those
self.assertEqual(self.getconf('c_std'), 'gnu89')
self.assertEqual(self.getconf('cpp_std'), 'gnu++98')
Expand Down

0 comments on commit 981afbc

Please sign in to comment.