Allow to set `building` in the tests dict

Aperta
#2,240 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
build-system

Direzione di ricerca

This is a proposal to accept a building key in each tests entry so a test runs in the same environment as rez env --build <pkg>. Start with the issue's example and the rez docs on the building attribute and tests, then read #2211, which the issue depends on. Done means a test entry with building: True gets the build environment, including build-only requires, and other tests are unchanged. Since the design is still open, check with maintainers before writing code.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

A stepping stone to #2211 — or some variant of that — is to be able to set the building attribute for a test in the tests dict.

It would look something like:

def commands():
    if building:
        env.PKG_CONFIG_PATH.prepend("{root}/lib/pkgconfig")

tests = {
    "pkgconf": {
        "command": "pkg-config mylib",
        "requires": ["pkgconf"],
        "building": True,
        "run_on": ["default", "pre_release"]
    },
}

The environment would be equivalent to the one you get with rez env --build <current_pkg> + <testing_pkgs>

Motivation

I encountered an issue when trying to add some tests for a C++ package. Our packages only prepend things to PKG_CONFIG_PATH or CMAKE_PREFIX_PATH when building is true. Similar to what the rez documentation for the building attribute shows with the env.FOO_INCLUDE_PATH example.

A workaround would be to change if building: to if building or testing:. But you don't necessarily want the build specific options for all of your tests. Most tests you would want the environment to be as when you run rez env <current_pkg>.

And in our case that would require a lot of effort. I did a quick grep and we have ~430 rez releases with if building:, not all of them are still in use but a substantial chunk of them would need to be fixed.

Another thing that if building and testing:wouldn't fix, is the build specific dependencies you get when specifying rez env --build. Those you would need to manually add to the test's requires in order to get a similar environment as the building environment.

Having the option to opt-in to a build environment for a given test would solve all of this and avoid muddying the waters between the building and testing attribute.

This would allow us to test things like if the pkgconfig file a package generated works as expected. And run source specific tests with some gotchas.

Related Issues/PRs

  • #2211
Lingua principale
Python
Stelle
1.1k
Fork
370
Merge medio
2g 10h
PR unite (30g)
11

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AcademySoftwareFoundation/rez

Tutte le issue di AcademySoftwareFoundation/rez

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.