Skip to content

Commit

Permalink
unit tests: Test ObjC and ObjC++ as well as C and C++
Browse files Browse the repository at this point in the history
This tests ObjC and ObjC++ both with and without C enabled. I did this
because I ran into issues where ObjC only worked when C was enabled, and
then a later bug where C was disabled, due to the fact that C and ObjC
both use `c_std` and not `objc_std`.
  • Loading branch information
dcbaker committed Sep 25, 2024
1 parent 855acbe commit 76b2563
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
21 changes: 16 additions & 5 deletions test cases/unit/115 c cpp stds/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
project('c cpp stds', 'c', 'cpp',
default_options: [
'c_std=gnu89,c89',
'cpp_std=gnu++98,vc++11',
],
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2024 Intel Corporation

project(
'c cpp stds',
default_options: [
'c_std=gnu89,c89',
'cpp_std=gnu++98,vc++11',
],
)

if get_option('with-c')
add_languages('c', 'cpp', native : false)
endif
if get_option('with-objc')
add_languages('objc', 'objcpp', native : false)
endif
5 changes: 5 additions & 0 deletions test cases/unit/115 c cpp stds/meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2024 Intel Corporation

option('with-c', type : 'boolean', value : false)
option('with-objc', type : 'boolean', value : false)
21 changes: 17 additions & 4 deletions unittests/allplatformstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4999,9 +4999,9 @@ def test_configure_same_noop(self):
olddata = newdata
oldmtime = newmtime

def test_c_cpp_stds(self) -> None:
def __test_multi_stds(self, extra_args: T.List[str]) -> None:
testdir = os.path.join(self.unit_test_dir, '115 c cpp stds')
self.init(testdir)
self.init(testdir, extra_args=extra_args)
# Invalid values should fail whatever compiler we have
with self.assertRaises(subprocess.CalledProcessError):
self.setconf('-Dc_std=invalid')
Expand Down Expand Up @@ -5029,8 +5029,21 @@ def test_c_cpp_stds(self) -> None:
self.assertEqual(self.getconf('c_std'), 'gnu89')
self.assertEqual(self.getconf('cpp_std'), 'gnu++98')
# The first supported std should be selected
self.setconf('-Dcpp_std=c++11,gnu++11,vc++11')
self.assertEqual(self.getconf('cpp_std'), 'c++11')
# self.setconf('-Dcpp_std=c++11,gnu++11,vc++11')
# self.assertEqual(self.getconf('cpp_std'), 'c++11')

def test_c_cpp_stds(self) -> None:
self.__test_multi_stds(['-Dwith-c=true'])

@skip_if_not_language('objc')
@skip_if_not_language('objcpp')
def test_objc_objcpp_stds(self) -> None:
self.__test_multi_stds(['-Dwith-objc=true'])

@skip_if_not_language('objc')
@skip_if_not_language('objcpp')
def test_c_cpp_objc_objcpp_stds(self) -> None:
self.__test_multi_stds(['-Dwith-c=true', '-Dwith-objc=true'])

def test_rsp_support(self):
env = get_fake_env()
Expand Down

0 comments on commit 76b2563

Please sign in to comment.