Skip to content

Conversation

@dcbaker
Copy link
Member

@dcbaker dcbaker commented Dec 3, 2025

Built on top of: #15092. Set to draft for that reason.

Since the sanity tests have been refactored to work both inside of the build directory and outside of it, and the compilers actually implement (for the most part) competent sanity checking, we can make use of that inside run_project_tests.py. This means we can detect all of the compilers once, and keep re-using those compilers elsewhere.

For me this shaves about .5 seconds off of the startup cost of run_project_tests.py. There is definitely more work that could be done here, but this was some low hanging fruit.

Vala really needs a known working C compiler, and once we fix its
sanity_check, it will fail without one, so ensure it's there.
The goal is to reduce code duplication, and allow each language to
implement as little as possible to get good checking. The main
motivation is that half of the checks are fragile, as they add the work
directory to the paths of the generated files they want to use. This
works when run inside mesonmain because we always have an absolute build
directory, but when put into run_project_tests.py it doesn't work
because that gives a relative build directory.

Additionally, this fixes the implementation of sanity checking for
transpiled languages like Vala and Cython, which previously didn't test
the output of their compilers at all, but re-ran the C compiler test for
itself.
Instead of doing this in the sanity checking code. Apart from being more
"correct", this allows us to remove the custom sanity_checking
implementation.
`global` is only needed when we want to overwrite a varaible at the
global scope, not to read or mutate. Ie:
```python
foo: list[str] = []

def read() -> bool:
    return 'x' in foo

def mutate() -> None:
    foo.append('x')

def write() -> None:
    global foo
    foo = ['y']
```
This uses detect_compiler_for to create a global mapping of compilers
once, and then to re-use them whenever we need a compiler
We already know which compiler we want to use, and whether it works. So
we can now make better selections about when to run specific test
categories, often without having to invoke the compiler a second time.
Instead, use the `all_compilers` dict to get the 'c' compiler.

This also handles there not being a C compiler for installations more
gracefully.
So that if an invalid `--only` option is passed, we error *before* doing
a bunch of work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant