diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-02-18 17:07:11 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-03-03 23:19:03 +0100 |
commit | 9e659b31304074583bd26486b77965ef07db6f53 (patch) | |
tree | 33029940422694705557819e78981c16ed040bec | |
parent | f9b41d5ecbed3adabb6a0433892ea801b531c412 (diff) | |
download | meson-9e659b31304074583bd26486b77965ef07db6f53.zip meson-9e659b31304074583bd26486b77965ef07db6f53.tar.gz meson-9e659b31304074583bd26486b77965ef07db6f53.tar.bz2 |
Added test cases
-rwxr-xr-x | run_unittests.py | 64 | ||||
-rw-r--r-- | test cases/unit/52 introspection/meson.build | 6 |
2 files changed, 70 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py index b5cb53c..d1bd201 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3511,6 +3511,70 @@ recommended as it is not supported on some platforms''') self.assertListEqual(res1, res2) + def test_introspect_targets_from_source(self): + testdir = os.path.join(self.unit_test_dir, '52 introspection') + testfile = os.path.join(testdir, 'meson.build') + introfile = os.path.join(self.builddir, 'meson-info', 'intro-targets.json') + self.init(testdir) + self.assertPathExists(introfile) + with open(introfile, 'r') as fp: + res_wb = json.load(fp) + + res_nb = self.introspect_directory(testfile, ['--targets'] + self.meson_args) + + # Account for differences in output + for i in res_wb: + i['filename'] = [os.path.relpath(x, self.builddir) for x in i['filename']] + if 'install_filename' in i: + del i['install_filename'] + + sources = [] + for j in i['target_sources']: + sources += j['sources'] + i['target_sources'] = [{ + 'language': 'unknown', + 'compiler': [], + 'parameters': [], + 'sources': sources, + 'generated_sources': [] + }] + + self.maxDiff = None + self.assertListEqual(res_nb, res_wb) + + def test_introspect_dependencies_from_source(self): + testdir = os.path.join(self.unit_test_dir, '52 introspection') + testfile = os.path.join(testdir, 'meson.build') + res_nb = self.introspect_directory(testfile, ['--dependencies'] + self.meson_args) + expected = [ + { + 'name': 'threads', + 'required': True, + 'has_fallback': False, + 'conditional': False + }, + { + 'name': 'zlib', + 'required': False, + 'has_fallback': False, + 'conditional': False + }, + { + 'name': 'somethingthatdoesnotexist', + 'required': True, + 'has_fallback': False, + 'conditional': True + }, + { + 'name': 'look_i_have_a_fallback', + 'required': True, + 'has_fallback': True, + 'conditional': True + } + ] + self.maxDiff = None + self.assertListEqual(res_nb, expected) + class FailureTests(BasePlatformTests): ''' Tests that test failure conditions. Build files here should be dynamically diff --git a/test cases/unit/52 introspection/meson.build b/test cases/unit/52 introspection/meson.build index 14d880b..98f6f22 100644 --- a/test cases/unit/52 introspection/meson.build +++ b/test cases/unit/52 introspection/meson.build @@ -1,6 +1,12 @@ project('introspection', ['c', 'cpp'], version: '1.2.3', default_options: ['cpp_std=c++11', 'buildtype=debug']) dep1 = dependency('threads') +dep2 = dependency('zlib', required: false) + +if false + dependency('somethingthatdoesnotexist', required: true) + dependency('look_i_have_a_fallback', fallback: ['oh_no', 'the_subproject_does_not_exist']) +endif subdir('sharedlib') subdir('staticlib') |