diff --git a/run_unittests.py b/run_unittests.py index d28f903ae..2b2da7c1a 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3604,20 +3604,19 @@ recommended as it is not supported on some platforms''') self.setconf('-Dcpp_std=c++14') self.setconf('-Dbuildtype=release') - for idx, i in enumerate(res1): + with open(introfile, 'r') as fp: + res2 = json.load(fp) + + for idx, i in enumerate(res2): if i['name'] == 'cpp_std': - res1[idx]['value'] = 'c++14' + self.assertEqual(res2[idx]['value'], 'c++14') if i['name'] == 'buildtype': - res1[idx]['value'] = 'release' + self.assertEqual(res2[idx]['value'], 'release') if i['name'] == 'optimization': - res1[idx]['value'] = '3' + self.assertEqual(res2[idx]['value'], '3') if i['name'] == 'debug': - res1[idx]['value'] = False - - with open(introfile, 'r') as fp: - res2 = json.load(fp) + self.assertEqual(res2[idx]['value'], False) - self.assertListEqual(res1, res2) def test_introspect_targets_from_source(self): testdir = os.path.join(self.unit_test_dir, '55 introspection') @@ -5215,20 +5214,14 @@ endian = 'little' # Assert that self.assertEqual(len(line.split(lib)), 2, msg=(lib, line)) - @skipIfNoPkgconfig - def test_pkg_config_option(self): - testdir = os.path.join(self.unit_test_dir, '55 pkg_config_path option') - self.init(testdir, extra_args=[ - '-Dbuild.pkg_config_path=' + os.path.join(testdir, 'build_extra_path'), - '-Dpkg_config_path=' + os.path.join(testdir, 'host_extra_path'), - ]) - - def test_std_remains(self): + def test_std_noncross_options(self): # C_std defined in project options must be in effect also when native compiling. - testdir = os.path.join(self.unit_test_dir, '50 std remains') - self.init(testdir) + testdir = os.path.join(self.unit_test_dir, '51 noncross options') + self.init(testdir, extra_args=['-Dpkg_config_path=' + testdir]) compdb = self.get_compdb() + self.assertEqual(len(compdb), 2) self.assertRegex(compdb[0]['command'], '-std=c99') + self.assertRegex(compdb[1]['command'], '-std=c99') self.build() def test_identity_cross(self): @@ -5296,12 +5289,20 @@ class LinuxCrossArmTests(BasePlatformTests): def test_std_remains(self): # C_std defined in project options must be in effect also when cross compiling. - testdir = os.path.join(self.unit_test_dir, '50 std remains') + testdir = os.path.join(self.unit_test_dir, '51 noncross options') self.init(testdir) compdb = self.get_compdb() self.assertRegex(compdb[0]['command'], '-std=c99') self.build() + @skipIfNoPkgconfig + def test_pkg_config_option(self): + testdir = os.path.join(self.unit_test_dir, '55 pkg_config_path option') + self.init(testdir, extra_args=[ + '-Dbuild.pkg_config_path=' + os.path.join(testdir, 'build_extra_path'), + '-Dpkg_config_path=' + os.path.join(testdir, 'host_extra_path'), + ]) + def should_run_cross_mingw_tests(): return shutil.which('x86_64-w64-mingw32-gcc') and not (is_windows() or is_cygwin()) diff --git a/test cases/unit/50 std remains/meson.build b/test cases/unit/50 std remains/meson.build deleted file mode 100644 index ac6f9e247..000000000 --- a/test cases/unit/50 std remains/meson.build +++ /dev/null @@ -1,2 +0,0 @@ -project('std_remains', 'c', default_options: ['c_std=c99']) -executable('prog', 'prog.c') diff --git a/test cases/unit/51 noncross options/meson.build b/test cases/unit/51 noncross options/meson.build new file mode 100644 index 000000000..6d479d60a --- /dev/null +++ b/test cases/unit/51 noncross options/meson.build @@ -0,0 +1,14 @@ +project('std_remains', 'c', default_options: ['c_std=c99']) + +executable('prog', 'prog.c') + +# Check that native: true does not affect the use of c_std in +# non-cross builds + +if not meson.is_cross_build() + executable('prog2', 'prog.c', native: true) + + # Check that even deps marked as native are found + # by default when not cross compiling. + dependency('ylib', method: 'pkg-config') +endif diff --git a/test cases/unit/50 std remains/prog.c b/test cases/unit/51 noncross options/prog.c similarity index 100% rename from test cases/unit/50 std remains/prog.c rename to test cases/unit/51 noncross options/prog.c diff --git a/test cases/unit/51 noncross options/ylib.pc b/test cases/unit/51 noncross options/ylib.pc new file mode 100644 index 000000000..afec2d3f7 --- /dev/null +++ b/test cases/unit/51 noncross options/ylib.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib/x86_64-linux-gnu +sharedlibdir=${libdir} +includedir=${prefix}/include + +Name: ylib +Description: ylib compression library +Version: 1.2.3 + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -ly +Cflags: -I${includedir} diff --git a/test cases/unit/55 introspection/staticlib/static.h b/test cases/unit/55 introspection/staticlib/static.h index 506784e43..d43670f77 100644 --- a/test cases/unit/55 introspection/staticlib/static.h +++ b/test cases/unit/55 introspection/staticlib/static.h @@ -1,3 +1,12 @@ #pragma once -int add_numbers(int a, int b); \ No newline at end of file +#ifdef __cplusplus +extern "C" { +#endif + +int add_numbers(int a, int b); + +/* End Extern "C" and Include Guard */ +#ifdef __cplusplus +} +#endif