test runner: add the ability to configure test.json for python paths

Adds new installed file types with @VAR@ substitution.
pull/9134/head
Eli Schwartz 3 years ago
parent d9a9c3b5da
commit 44e123dd90
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 3
      data/test.schema.json
  2. 10
      docs/markdown/Contributing.md
  3. 21
      run_project_tests.py

@ -21,11 +21,14 @@
"type": "string",
"enum": [
"file",
"python_file",
"dir",
"exe",
"shared_lib",
"python_lib",
"pdb",
"implib",
"py_implib",
"implibempty",
"expr"
]

@ -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

@ -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

Loading…
Cancel
Save