-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a smoke-test for GObject-Introspection using PyGI
Signed-off-by: Simon McVittie <[email protected]>
- Loading branch information
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright 2021 Simon McVittie | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
|
||
import unittest | ||
import sys | ||
|
||
class TestIntrospection(unittest.TestCase): | ||
def setUp(self): | ||
try: | ||
import gi | ||
except ImportError: | ||
self.skipTest('gi module not available') | ||
|
||
gi.require_version('Graphene', '1.0') | ||
|
||
def test_basics(self): | ||
'''Assert that introspection basically works''' | ||
from gi.repository import Graphene | ||
|
||
self.assertIsNotNone(Graphene.Box.empty()) | ||
|
||
def test_simd_not_exposed(self): | ||
'''Assert that SIMD implementation details are not present''' | ||
from gi.repository import Graphene | ||
|
||
for name in ( | ||
'HAS_ARM_NEON', | ||
'HAS_GCC', | ||
'HAS_SCALAR', | ||
'HAS_SSE', | ||
'SIMD_S', | ||
'USE_ARM_NEON', | ||
'USE_GCC', | ||
'USE_SCALAR', | ||
'USE_SSE', | ||
): | ||
with self.assertRaises( | ||
AttributeError, | ||
msg='%s should not be defined' % name, | ||
): | ||
getattr(Graphene, name) | ||
|
||
def main(): | ||
try: | ||
from tap.runner import TAPTestRunner | ||
except ImportError: | ||
# Minimal TAP implementation | ||
print('1..1') | ||
program = unittest.main(exit=False) | ||
if program.result.wasSuccessful(): | ||
print('ok 1 - %r' % program.result) | ||
else: | ||
print('not ok 1 - %r' % program.result) | ||
else: | ||
runner = TAPTestRunner() | ||
runner.set_stream(True) | ||
unittest.main(testRunner=runner) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,31 @@ if mutest_dep.found() | |
) | ||
endforeach | ||
endif | ||
|
||
if build_gir and host_system == 'linux' and not meson.is_cross_build() | ||
foreach unit: ['introspection.py'] | ||
wrapper = '@[email protected]'.format(unit) | ||
custom_target(wrapper, | ||
output: wrapper, | ||
command: [ | ||
gen_installed_test, | ||
'--testdir=@0@'.format(installed_test_bindir), | ||
'--testname=@0@'.format(unit), | ||
'--outdir=@OUTDIR@', | ||
'--outfile=@0@'.format(wrapper), | ||
], | ||
install: get_option('installed_tests'), | ||
install_dir: installed_test_datadir, | ||
) | ||
|
||
test(unit, | ||
python, | ||
args: [files(unit)], | ||
env: [ | ||
'GI_TYPELIB_PATH=' + join_paths(meson.current_build_dir(), '..', 'src'), | ||
'LD_LIBRARY_PATH=' + join_paths(meson.current_build_dir(), '..', 'src'), | ||
], | ||
protocol: 'tap', | ||
) | ||
endforeach | ||
endif |