Skip to content

Commit

Permalink
Tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda committed Dec 29, 2018
1 parent eb7d25a commit e59d757
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/markdown/IDE-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ The possible values for `section` are:

To set the options, use the `meson configure` command.

It is also possible to get the default buildoptions without a build directory by providing the root `meson.build` instead of a build directory to `meson introspect --buildoptions`.

Running `--buildoptions` without a build directory produces the same output as running
it with a freshly configured build directory.

However, this behavior is not guaranteed if subprojects are present. Due to internal
limitations all subprojects are processed even if they are never used in a real meson run.
Because of this options for the subprojects can differ.

## Tests

Compilation and unit tests are done as usual by running the `ninja` and `ninja test` commands. A JSON formatted result log can be found in `workspace/project/builddir/meson-logs/testlog.json`.
Expand Down
11 changes: 11 additions & 0 deletions docs/markdown/snippets/introspect_buildoptions_no_bd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## `introspect --buildoptions` can now be used without configured build directory

It is now possible to run `meson introspect --buildoptions /path/to/meson.build`
without a configured build directory.

Running `--buildoptions` without a build directory produces the same output as running
it with a freshly configured build directory.

However, this behavior is not guaranteed if subprojects are present. Due to internal
limitations all subprojects are processed even if they are never used in a real meson run.
Because of this options for the subprojects can differ.
16 changes: 15 additions & 1 deletion run_unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,12 @@ def introspect_directory(self, directory, args):
args = [args]
out = subprocess.check_output(self.mintro_command + args + [directory],
universal_newlines=True)
return json.loads(out)
try:
obj = json.loads(out)
except Exception as e:
print(out)
raise e
return obj

def assertPathEqual(self, path1, path2):
'''
Expand Down Expand Up @@ -3053,6 +3058,15 @@ def test_introspect_projectinfo_subprojects(self):
}
self.assertDictEqual(res, expected)

def test_introspect_buildoptions_without_configured_build(self):
testdir = os.path.join(self.unit_test_dir, '51 introspect buildoptions')
testfile = os.path.join(testdir, 'meson.build')
res_nb = self.introspect_directory(testfile, ['--buildoptions'] + self.meson_args)
self.init(testdir, default_args=False)
res_wb = self.introspect('--buildoptions')
self.maxDiff = None
self.assertListEqual(res_nb, res_wb)


class FailureTests(BasePlatformTests):
'''
Expand Down
3 changes: 3 additions & 0 deletions test cases/unit/51 introspect buildoptions/c_compiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python3

print('c')
11 changes: 11 additions & 0 deletions test cases/unit/51 introspect buildoptions/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
project('introspect buildargs', ['c'], default_options: ['c_std=c11', 'cpp_std=c++14', 'buildtype=release'])

subA = subproject('projectA')

r = run_command(find_program('c_compiler.py'))
if r.returncode() != 0
error('FAILED')
endif

add_languages(r.stdout().strip(), required: true)
add_languages('afgggergearvearghergervergreaergaergasv', required: false)
2 changes: 2 additions & 0 deletions test cases/unit/51 introspect buildoptions/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
option('max_register_count', type: 'integer', min: 0, value: 125)
option('use_external_fmt', type: 'boolean', value: false)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project('introspect subproject A', 'c', default_options: ['cpp_std=c++11', 'buildtype=debug'])

add_languages('cpp')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('subproj_var', type: 'boolean', value: false)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pfggggaergaeg(sdgrgjgn)aga

rgqeh
th
thtr
e
tb
tbqebt
tbqebttrtt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('should_not_appear', type: 'integer', min: 0, value: 125)

0 comments on commit e59d757

Please sign in to comment.