diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-08-17 18:49:07 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2021-08-17 22:51:41 -0400 |
commit | 90cf7d7e6ec28c3b42bc3895d211fec32fe04335 (patch) | |
tree | de60eb0bd8a401cbe21c8af6efff8591f4ae6c9a | |
parent | 12c06e0d55025b382069f4d4c7c17f7e1b83e3b7 (diff) | |
download | meson-90cf7d7e6ec28c3b42bc3895d211fec32fe04335.zip meson-90cf7d7e6ec28c3b42bc3895d211fec32fe04335.tar.gz meson-90cf7d7e6ec28c3b42bc3895d211fec32fe04335.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 | 22 |
3 files changed, 33 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..0572ec1 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, always written as `python_file`. 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 7896ee5..0a4d8ac 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -62,6 +62,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 +123,8 @@ class TestResult(BaseException): def fail(self, msg: str) -> None: self.msg = msg +python_info: 'PythonIntrospectionDict' + class InstalledFile: def __init__(self, raw: T.Dict[str, str]): self.path = raw['file'] @@ -143,6 +146,14 @@ class InstalledFile: (env.machines.host.is_windows() and compiler in {'pgi', 'dmd', 'ldc'})): canonical_compiler = 'msvc' + global python_info + if not globals().get('python_info'): + from mesonbuild.modules.python import PythonExternalProgram + python_info = PythonExternalProgram(sys.executable).sanity().info + + 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 +172,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']) + if self.typ == 'python_file': + return Path(val) + p = Path(val).with_suffix(python_suffix) + if self.typ == 'python_lib': + return p if self.typ in ['file', 'dir']: return p elif self.typ == 'shared_lib': @@ -195,7 +215,7 @@ 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': |