diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2018-12-10 14:33:58 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2018-12-12 12:23:37 -0800 |
| commit | 978e6fb88f926da14314a3563de13197a092cc9f (patch) | |
| tree | 00d6d6d73d812561b4f778ccedfad109dc24a3ad /test cases/python/1 basic | |
| parent | f6405adc2de0c6cc494b4957df9d796b76195ec4 (diff) | |
| download | meson-978e6fb88f926da14314a3563de13197a092cc9f.tar.gz | |
tests: Add tests for the python module
This doesn't touch everything as it's just based on the python3 module
tests, ported to the python module. It's still better than the one very
basic test in the unit test module.
Diffstat (limited to 'test cases/python/1 basic')
| -rw-r--r-- | test cases/python/1 basic/gluon/__init__.py | 0 | ||||
| -rw-r--r-- | test cases/python/1 basic/gluon/gluonator.py | 2 | ||||
| -rw-r--r-- | test cases/python/1 basic/meson.build | 26 | ||||
| -rwxr-xr-x | test cases/python/1 basic/prog.py | 9 | ||||
| -rw-r--r-- | test cases/python/1 basic/subdir/meson.build | 4 | ||||
| -rwxr-xr-x | test cases/python/1 basic/subdir/subprog.py | 12 |
6 files changed, 53 insertions, 0 deletions
diff --git a/test cases/python/1 basic/gluon/__init__.py b/test cases/python/1 basic/gluon/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/test cases/python/1 basic/gluon/__init__.py diff --git a/test cases/python/1 basic/gluon/gluonator.py b/test cases/python/1 basic/gluon/gluonator.py new file mode 100644 index 000000000..b53d6ded3 --- /dev/null +++ b/test cases/python/1 basic/gluon/gluonator.py @@ -0,0 +1,2 @@ +def gluoninate(): + return 42 diff --git a/test cases/python/1 basic/meson.build b/test cases/python/1 basic/meson.build new file mode 100644 index 000000000..f9a743379 --- /dev/null +++ b/test cases/python/1 basic/meson.build @@ -0,0 +1,26 @@ +project('python sample', 'c') + +py_mod = import('python') +py = py_mod.find_installation() + +py_version = py.language_version() +if py_version.version_compare('< 3.2') + error('MESON_SKIP_TEST python 3 required for tests') +endif + +py_purelib = py.get_path('purelib') +if not py_purelib.endswith('site-packages') + error('Python3 purelib path seems invalid? ' + py_purelib) +endif + +# could be 'lib64' or 'Lib' on some systems +py_platlib = py.get_path('platlib') +if not py_platlib.endswith('site-packages') + error('Python3 platlib path seems invalid? ' + py_platlib) +endif + +main = files('prog.py') + +test('toplevel', py, args : main) + +subdir('subdir') diff --git a/test cases/python/1 basic/prog.py b/test cases/python/1 basic/prog.py new file mode 100755 index 000000000..9d95aea27 --- /dev/null +++ b/test cases/python/1 basic/prog.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 + +from gluon import gluonator +import sys + +print('Running mainprog from root dir.') + +if gluonator.gluoninate() != 42: + sys.exit(1) diff --git a/test cases/python/1 basic/subdir/meson.build b/test cases/python/1 basic/subdir/meson.build new file mode 100644 index 000000000..66957c108 --- /dev/null +++ b/test cases/python/1 basic/subdir/meson.build @@ -0,0 +1,4 @@ +test('subdir', + py, + args : files('subprog.py'), + env : 'PYTHONPATH=' + meson.source_root()) diff --git a/test cases/python/1 basic/subdir/subprog.py b/test cases/python/1 basic/subdir/subprog.py new file mode 100755 index 000000000..08652f084 --- /dev/null +++ b/test cases/python/1 basic/subdir/subprog.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +# In order to run this program, PYTHONPATH must be set to +# point to source root. + +from gluon import gluonator +import sys + +print('Running mainprog from subdir.') + +if gluonator.gluoninate() != 42: + sys.exit(1) |
