diff options
author | John Ericson <git@JohnEricson.me> | 2020-08-03 11:48:27 -0400 |
---|---|---|
committer | John Ericson <git@JohnEricson.me> | 2020-08-03 11:48:27 -0400 |
commit | eaf6343c065842b9719793066e765b2e5f1c2f3b (patch) | |
tree | 1bfeac5297ba489721e704e63c28f33d0fb98990 /test cases/python | |
parent | 87aa98c1787d800145853a8e84654e4c54ee1078 (diff) | |
parent | 70edf82c6c77902cd64f44848302bbac92d611d8 (diff) | |
download | meson-lang-enum.zip meson-lang-enum.tar.gz meson-lang-enum.tar.bz2 |
Merge remote-tracking branch 'upstream/master' into lang-enumlang-enum
Diffstat (limited to 'test cases/python')
-rw-r--r-- | test cases/python/1 basic/meson.build | 3 | ||||
-rwxr-xr-x | test cases/python/1 basic/prog.py | 3 | ||||
-rwxr-xr-x | test cases/python/1 basic/subdir/subprog.py | 3 | ||||
-rwxr-xr-x | test cases/python/2 extmodule/blaster.py | 7 | ||||
-rw-r--r-- | test cases/python/2 extmodule/meson.build | 31 | ||||
-rwxr-xr-x | test cases/python/3 cython/cytest.py | 10 | ||||
-rw-r--r-- | test cases/python/3 cython/meson.build | 34 | ||||
-rw-r--r-- | test cases/python/4 custom target depends extmodule/blaster.py | 6 | ||||
-rw-r--r-- | test cases/python/4 custom target depends extmodule/meson.build | 39 | ||||
-rw-r--r-- | test cases/python/5 modules kwarg/meson.build | 2 |
10 files changed, 73 insertions, 65 deletions
diff --git a/test cases/python/1 basic/meson.build b/test cases/python/1 basic/meson.build index 9c3af10..bd9a65c 100644 --- a/test cases/python/1 basic/meson.build +++ b/test cases/python/1 basic/meson.build @@ -1,4 +1,4 @@ -project('python sample', 'c') +project('python sample') py_mod = import('python') py = py_mod.find_installation('python3') @@ -12,6 +12,7 @@ py_purelib = py.get_path('purelib') if not py_purelib.endswith('site-packages') error('Python3 purelib path seems invalid? ' + py_purelib) endif +message('Python purelib path:', py_purelib) # could be 'lib64' or 'Lib' on some systems py_platlib = py.get_path('platlib') diff --git a/test cases/python/1 basic/prog.py b/test cases/python/1 basic/prog.py index 9d95aea..720fdb1 100755 --- a/test cases/python/1 basic/prog.py +++ b/test cases/python/1 basic/prog.py @@ -1,9 +1,8 @@ #!/usr/bin/env python3 from gluon import gluonator -import sys print('Running mainprog from root dir.') if gluonator.gluoninate() != 42: - sys.exit(1) + raise ValueError("!= 42") diff --git a/test cases/python/1 basic/subdir/subprog.py b/test cases/python/1 basic/subdir/subprog.py index 08652f0..54178e5 100755 --- a/test cases/python/1 basic/subdir/subprog.py +++ b/test cases/python/1 basic/subdir/subprog.py @@ -4,9 +4,8 @@ # point to source root. from gluon import gluonator -import sys print('Running mainprog from subdir.') if gluonator.gluoninate() != 42: - sys.exit(1) + raise ValueError("!= 42") diff --git a/test cases/python/2 extmodule/blaster.py b/test cases/python/2 extmodule/blaster.py index 7e1eae6..1f01876 100755 --- a/test cases/python/2 extmodule/blaster.py +++ b/test cases/python/2 extmodule/blaster.py @@ -1,14 +1,11 @@ #!/usr/bin/env python3 import tachyon -import sys result = tachyon.phaserize('shoot') if not isinstance(result, int): - print('Returned result not an integer.') - sys.exit(1) + raise SystemExit('Returned result not an integer.') if result != 1: - print('Returned result {} is not 1.'.format(result)) - sys.exit(1) + raise SystemExit('Returned result {} is not 1.'.format(result)) diff --git a/test cases/python/2 extmodule/meson.build b/test cases/python/2 extmodule/meson.build index b4eb960..18d70c8 100644 --- a/test cases/python/2 extmodule/meson.build +++ b/test cases/python/2 extmodule/meson.build @@ -3,26 +3,33 @@ project('Python extension module', 'c', # Because Windows Python ships only with optimized libs, # we must build this project the same way. +if meson.backend() != 'ninja' + error('MESON_SKIP_TEST: Ninja backend required') +endif + + py_mod = import('python') py = py_mod.find_installation() -py_dep = py.dependency() +py_dep = py.dependency(required: false) -if py_dep.found() - subdir('ext') +if not py_dep.found() + error('MESON_SKIP_TEST: Python libraries not found.') +endif - test('extmod', - py, - args : files('blaster.py'), - env : ['PYTHONPATH=' + pypathdir]) +subdir('ext') - # Check we can apply a version constraint - dependency('python3', version: '>=@0@'.format(py_dep.version())) +test('extmod', + py, + args : files('blaster.py'), + env : ['PYTHONPATH=' + pypathdir]) -else - error('MESON_SKIP_TEST: Python3 libraries not found, skipping test.') -endif py3_pkg_dep = dependency('python3', method: 'pkg-config', required : false) if py3_pkg_dep.found() python_lib_dir = py3_pkg_dep.get_pkgconfig_variable('libdir') + + # Check we can apply a version constraint + dependency('python3', version: '>=@0@'.format(py_dep.version())) +else + message('Skipped python3 pkg-config test') endif diff --git a/test cases/python/3 cython/cytest.py b/test cases/python/3 cython/cytest.py index 43443dc..c08ffee 100755 --- a/test cases/python/3 cython/cytest.py +++ b/test cases/python/3 cython/cytest.py @@ -1,23 +1,19 @@ #!/usr/bin/env python3 from storer import Storer -import sys s = Storer() if s.get_value() != 0: - print('Initial value incorrect.') - sys.exit(1) + raise SystemExit('Initial value incorrect.') s.set_value(42) if s.get_value() != 42: - print('Setting value failed.') - sys.exit(1) + raise SystemExit('Setting value failed.') try: s.set_value('not a number') - print('Using wrong argument type did not fail.') - sys.exit(1) + raise SystemExit('Using wrong argument type did not fail.') except TypeError: pass diff --git a/test cases/python/3 cython/meson.build b/test cases/python/3 cython/meson.build index 194920b..5fc07a8 100644 --- a/test cases/python/3 cython/meson.build +++ b/test cases/python/3 cython/meson.build @@ -1,20 +1,26 @@ project('cython', 'c', default_options : ['warning_level=3']) -cython = find_program('cython3', required : false) -py3_dep = dependency('python3', required : false) +if meson.backend() != 'ninja' + error('MESON_SKIP_TEST: Ninja backend required') +endif -if cython.found() and py3_dep.found() - py_mod = import('python') - py3 = py_mod.find_installation() - py3_dep = py3.dependency() - subdir('libdir') +cython = find_program('cython', required : false) +if not cython.found() + error('MESON_SKIP_TEST: Cython3 not found.') +endif - test('cython tester', - py3, - args : files('cytest.py'), - env : ['PYTHONPATH=' + pydir] - ) -else - error('MESON_SKIP_TEST: Cython3 or Python3 libraries not found, skipping test.') +py_mod = import('python') +py3 = py_mod.find_installation() +py3_dep = py3.dependency(required: false) +if not py3_dep.found() + error('MESON_SKIP_TEST: Python library not found.') endif + +subdir('libdir') + +test('cython tester', + py3, + args : files('cytest.py'), + env : ['PYTHONPATH=' + pydir] +) diff --git a/test cases/python/4 custom target depends extmodule/blaster.py b/test cases/python/4 custom target depends extmodule/blaster.py index 6106f6b..09039cb 100644 --- a/test cases/python/4 custom target depends extmodule/blaster.py +++ b/test cases/python/4 custom target depends extmodule/blaster.py @@ -24,9 +24,7 @@ if options.output: f.write('success') if not isinstance(result, int): - print('Returned result not an integer.') - sys.exit(1) + raise SystemExit('Returned result not an integer.') if result != 1: - print('Returned result {} is not 1.'.format(result)) - sys.exit(1) + raise SystemExit('Returned result {} is not 1.'.format(result)) diff --git a/test cases/python/4 custom target depends extmodule/meson.build b/test cases/python/4 custom target depends extmodule/meson.build index 3835377..d8a62ed 100644 --- a/test cases/python/4 custom target depends extmodule/meson.build +++ b/test cases/python/4 custom target depends extmodule/meson.build @@ -3,11 +3,19 @@ project('Python extension module', 'c', # Because Windows Python ships only with optimized libs, # we must build this project the same way. +if meson.backend() != 'ninja' + error('MESON_SKIP_TEST: Ninja backend required') +endif + py_mod = import('python') py3 = py_mod.find_installation() py3_dep = py3.dependency(required : false) cc = meson.get_compiler('c') +if not py3_dep.found() + error('MESON_SKIP_TEST: Python3 libraries not found, skipping test.') +endif + # Copy to the builddir so that blaster.py can find the built tachyon module # FIXME: We should automatically detect this case and append the correct paths # to PYTHONLIBDIR @@ -20,21 +28,18 @@ import os, sys with open(sys.argv[1], 'rb') as f: assert(f.read() == b'success') ''' -if py3_dep.found() - message('Detected Python version: ' + py3_dep.version()) - if py3_dep.version().version_compare('>=3.8') and cc.get_id() == 'msvc' and cc.version().version_compare('<=19.00.24215.1') - error('MESON_SKIP_TEST: Python modules do not work with Python 3.8 and VS2015 or earlier.') - endif - subdir('ext') - - out_txt = custom_target('tachyon flux', - input : blaster_py, - output : 'out.txt', - command : [py3, '@INPUT@', '-o', '@OUTPUT@'], - depends : pylib, - build_by_default: true) - - test('flux', py3, args : ['-c', check_exists, out_txt]) -else - error('MESON_SKIP_TEST: Python3 libraries not found, skipping test.') + +message('Detected Python version: ' + py3_dep.version()) +if py3_dep.version().version_compare('>=3.8') and cc.get_id() == 'msvc' and cc.version().version_compare('<=19.00.24215.1') + error('MESON_SKIP_TEST: Python modules do not work with Python 3.8 and VS2015 or earlier.') endif +subdir('ext') + +out_txt = custom_target('tachyon flux', + input : blaster_py, + output : 'out.txt', + command : [py3, '@INPUT@', '-o', '@OUTPUT@'], + depends : pylib, + build_by_default: true) + +test('flux', py3, args : ['-c', check_exists, out_txt]) diff --git a/test cases/python/5 modules kwarg/meson.build b/test cases/python/5 modules kwarg/meson.build index 3c9d54f..9751ada 100644 --- a/test cases/python/5 modules kwarg/meson.build +++ b/test cases/python/5 modules kwarg/meson.build @@ -1,7 +1,7 @@ project('python kwarg') py = import('python') -prog_python = py.find_installation('python3', modules : ['setuptools']) +prog_python = py.find_installation('python3', modules : ['distutils']) assert(prog_python.found() == true, 'python not found when should be') prog_python = py.find_installation('python3', modules : ['thisbetternotexistmod'], required : false) assert(prog_python.found() == false, 'python not found but reported as found') |