From 9e659b31304074583bd26486b77965ef07db6f53 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Mon, 18 Feb 2019 17:07:11 +0100 Subject: Added test cases --- run_unittests.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'run_unittests.py') 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 -- cgit v1.1 From 7074f12644ae0ddc7f8d7471f776bce3375934d4 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 3 Mar 2019 22:12:31 +0100 Subject: mintro: Renamed --dependencies --> --scan-dependencies --- run_unittests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'run_unittests.py') diff --git a/run_unittests.py b/run_unittests.py index d1bd201..c1337a3 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3545,7 +3545,7 @@ recommended as it is not supported on some platforms''') 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) + res_nb = self.introspect_directory(testfile, ['--scan-dependencies'] + self.meson_args) expected = [ { 'name': 'threads', -- cgit v1.1