aboutsummaryrefslogtreecommitdiff
path: root/run_unittests.py
diff options
context:
space:
mode:
authorDaniel Schulte <trilader@schroedingers-bit.net>2018-09-16 17:42:57 +0200
committerDaniel Schulte <trilader@schroedingers-bit.net>2018-11-26 23:12:00 +0100
commit0e621937306575b9c1a2f5b07e6dd8d9e6c27ee7 (patch)
treebe82e3b81b18205edc18b0f71d9683c88920ed9a /run_unittests.py
parent8c9c5199f9c2c08190e424ffcaed6d54b8c47184 (diff)
downloadmeson-0e621937306575b9c1a2f5b07e6dd8d9e6c27ee7.zip
meson-0e621937306575b9c1a2f5b07e6dd8d9e6c27ee7.tar.gz
meson-0e621937306575b9c1a2f5b07e6dd8d9e6c27ee7.tar.bz2
mintro: Allow introspect --projectinfo without build directory.
This variant was added to allow introspection before configuring a build directory. This is useful for IDE integration to allow displaying and/or setting options for the initial configuration of the build directory. It also allows showing basic information about the project even if it's not yet configured or configuring failed. The project 'name' field in --projectinfo is used inconsistently: For the top level project it always shows the name configured in the top level meson.build file. For subprojects it's referring to the name of the directory the subproject's meson.build is contained in. To have a consistent output and preserve the existing behavior this adds the 'descriptive_name' field which always shows the name set in the project. To be consistent the 'descriptive_name' field was also added to the --projectfiles variant that uses an already configured build. It also extends the information shown with the list of buildsystem-files. This is currently only implemented in the variant for unconfigured projects.
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-xrun_unittests.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/run_unittests.py b/run_unittests.py
index b99bc05..9ab88bc 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -1165,6 +1165,13 @@ class BasePlatformTests(unittest.TestCase):
universal_newlines=True)
return json.loads(out)
+ def introspect_directory(self, directory, args):
+ if isinstance(args, str):
+ args = [args]
+ out = subprocess.check_output(self.mintro_command + args + [directory],
+ universal_newlines=True)
+ return json.loads(out)
+
def assertPathEqual(self, path1, path2):
'''
Handles a lot of platform-specific quirks related to paths such as
@@ -2913,6 +2920,36 @@ recommended as it is not supported on some platforms''')
'target2-id', '@other')
self.assertEqual('81d46d1@@target2-id@other', target_id)
+ def test_introspect_projectinfo_without_configured_build(self):
+ testfile = os.path.join(self.common_test_dir, '36 run program', 'meson.build')
+ res = self.introspect_directory(testfile, '--projectinfo')
+ self.assertEqual(set(res['buildsystem_files']), set(['meson.build']))
+ self.assertEqual(res['name'], 'run command')
+ self.assertEqual(res['version'], None)
+ self.assertEqual(res['descriptive_name'], 'run command')
+ self.assertEqual(res['subprojects'], [])
+
+ testfile = os.path.join(self.common_test_dir, '44 options', 'meson.build')
+ res = self.introspect_directory(testfile, '--projectinfo')
+ self.assertEqual(set(res['buildsystem_files']), set(['meson_options.txt', 'meson.build']))
+ self.assertEqual(res['name'], 'options')
+ self.assertEqual(res['version'], None)
+ self.assertEqual(res['descriptive_name'], 'options')
+ self.assertEqual(res['subprojects'], [])
+
+ testfile = os.path.join(self.common_test_dir, '47 subproject options', 'meson.build')
+ res = self.introspect_directory(testfile, '--projectinfo')
+ self.assertEqual(set(res['buildsystem_files']), set(['meson_options.txt', 'meson.build']))
+ self.assertEqual(res['name'], 'suboptions')
+ self.assertEqual(res['version'], None)
+ self.assertEqual(res['descriptive_name'], 'suboptions')
+ self.assertEqual(len(res['subprojects']), 1)
+ subproject_files = set(f.replace('\\', '/') for f in res['subprojects'][0]['buildsystem_files'])
+ self.assertEqual(subproject_files, set(['subprojects/subproject/meson_options.txt', 'subprojects/subproject/meson.build']))
+ self.assertEqual(res['subprojects'][0]['name'], 'subproject')
+ self.assertEqual(res['subprojects'][0]['version'], 'undefined')
+ self.assertEqual(res['subprojects'][0]['descriptive_name'], 'subproject')
+
class FailureTests(BasePlatformTests):
'''