diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-08-17 18:49:07 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2021-08-18 17:58:30 -0400 |
commit | 44e123dd90d0af9af5dcec494aa13e1f278fdaca (patch) | |
tree | 32ff2081266dfa831a0e8f97049c7299637c4717 | |
parent | d9a9c3b5dadd7a132bd221b7d2b4f84c0f0edb13 (diff) | |
download | meson-44e123dd90d0af9af5dcec494aa13e1f278fdaca.zip meson-44e123dd90d0af9af5dcec494aa13e1f278fdaca.tar.gz meson-44e123dd90d0af9af5dcec494aa13e1f278fdaca.tar.bz2 |
test runner: add the ability to configure test.json for python paths
Adds new installed file types with @VAR@ substitution.
-rw-r--r-- | data/test.schema.json | 3 | ||||
-rw-r--r-- | docs/markdown/Contributing.md | 10 | ||||
-rwxr-xr-x | run_project_tests.py | 21 |
3 files changed, 32 insertions, 2 deletions
diff --git a/data/test.schema.json b/data/test.schema.json index b89a874..a809388 100644 --- a/data/test.schema.json +++ b/data/test.schema.json @@ -21,11 +21,14 @@ "type": "string", "enum": [ "file", + "python_file", "dir", "exe", "shared_lib", + "python_lib", "pdb", "implib", + "py_implib", "implibempty", "expr" ] diff --git a/docs/markdown/Contributing.md b/docs/markdown/Contributing.md index 77e5165..3e3ff22 100644 --- a/docs/markdown/Contributing.md +++ b/docs/markdown/Contributing.md @@ -264,15 +264,18 @@ current platform. The following values are currently supported: | type | Description | | ------------- | ------------------------------------------------------------------------------------------------------- | | `file` | No postprocessing, just use the provided path | +| `python_file` | Use the provided path while replacing the python directory. | | `dir` | To include all files inside the directory (for generated docs, etc). The path must be a valid directory | | `exe` | For executables. On Windows the `.exe` suffix is added to the path in `file` | | `shared_lib` | For shared libraries, always written as `name`. The appropriate suffix and prefix are added by platform | +| `python_lib` | For python libraries, while replacing the python directory. The appropriate suffix is added by platform | | `pdb` | For Windows PDB files. PDB entries are ignored on non Windows platforms | | `implib` | For Windows import libraries. These entries are ignored on non Windows platforms | +| `py_implib` | For Windows import libraries. These entries are ignored on non Windows platforms | | `implibempty` | Like `implib`, but no symbols are exported in the library | | `expr` | `file` is an expression. This type should be avoided and removed if possible | -Except for the `file` and `expr` types, all paths should be provided *without* a suffix. +Except for the `file`, `python_file` and `expr` types, all paths should be provided *without* a suffix. | Argument | Applies to | Description | | -----------|----------------------------|-------------------------------------------------------------------------------| @@ -284,6 +287,11 @@ parameter, `version`, this is us a string in `X.Y.Z` format that will be applied to the library. Each version to be tested must have a single version. The harness will apply this correctly per platform: +The `python_file`, `python_lib`, and `py_implib` types have basic support for configuring the string with the `@<VAR>@` syntax: + +- `@PYTHON_PLATLIB@`: python `get_install_dir` directory relative to prefix +- `@PYTHON_PURELIB@`: python `get_install_dir(pure: true)` directory relative to prefix + `pdb` takes an optional `language` argument. This determines which compiler/linker should generate the pdb file. Because it's possible to mix compilers that do and don't generate pdb files (dmd's optlink diff --git a/run_project_tests.py b/run_project_tests.py index e8e9e67..154b66f 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -52,6 +52,7 @@ from mesonbuild.mesonlib import MachineChoice, Popen_safe, TemporaryDirectoryWin from mesonbuild.mlog import blue, bold, cyan, green, red, yellow, normal_green from mesonbuild.coredata import backendlist, version as meson_version from mesonbuild.mesonmain import setup_vsenv +from mesonbuild.modules.python import PythonExternalProgram from run_tests import get_fake_options, run_configure, get_meson_script from run_tests import get_backend_commands, get_backend_args_for_dir, Backend from run_tests import ensure_backend_detects_changes @@ -62,6 +63,7 @@ if T.TYPE_CHECKING: from mesonbuild.environment import Environment from mesonbuild._typing import Protocol from concurrent.futures import Future + from mesonbuild.modules.python import PythonIntrospectionDict class CompilerArgumentType(Protocol): cross_file: str @@ -122,6 +124,9 @@ class TestResult(BaseException): def fail(self, msg: str) -> None: self.msg = msg +python = PythonExternalProgram(sys.executable) +python.sanity() + class InstalledFile: def __init__(self, raw: T.Dict[str, str]): self.path = raw['file'] @@ -143,6 +148,9 @@ class InstalledFile: (env.machines.host.is_windows() and compiler in {'pgi', 'dmd', 'ldc'})): canonical_compiler = 'msvc' + python_paths = python.info['install_paths'] + python_suffix = python.info['suffix'] + has_pdb = False if self.language in {'c', 'cpp'}: has_pdb = canonical_compiler == 'msvc' @@ -161,6 +169,15 @@ class InstalledFile: return None # Handle the different types + if self.typ in {'py_implib', 'python_lib', 'python_file'}: + val = p.as_posix() + val = val.replace('@PYTHON_PLATLIB@', python_paths['platlib']) + val = val.replace('@PYTHON_PURELIB@', python_paths['purelib']) + p = Path(val) + if self.typ == 'python_file': + return p + if self.typ == 'python_lib': + return p.with_suffix(python_suffix) if self.typ in ['file', 'dir']: return p elif self.typ == 'shared_lib': @@ -195,13 +212,15 @@ class InstalledFile: if self.version: p = p.with_name('{}-{}'.format(p.name, self.version[0])) return p.with_suffix('.pdb') if has_pdb else None - elif self.typ == 'implib' or self.typ == 'implibempty': + elif self.typ in {'implib', 'implibempty', 'py_implib'}: if env.machines.host.is_windows() and canonical_compiler == 'msvc': # only MSVC doesn't generate empty implibs if self.typ == 'implibempty' and compiler == 'msvc': return None return p.parent / (re.sub(r'^lib', '', p.name) + '.lib') elif env.machines.host.is_windows() or env.machines.host.is_cygwin(): + if self.typ == 'py_implib': + p = p.with_suffix(python_suffix) return p.with_suffix('.dll.a') else: return None |