Offer to close TODO: parse rustflags

Aperta
#333 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
rust
Ambito
devtools, testing

Direzione di ricerca

Leggi src/rustflags.rs, in particolare il TODO alle righe 5 e 13-16, e confrontalo con l’API proposta TestCases::with_rustflags. È completato quando trybuild può passare flag forniti esplicitamente alla compilazione del test pertinente senza leggere lo stato dell’ambiente; l’issue non indica alcun file di test da eseguire.

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

Descrizione

in
https://github.com/dtolnay/trybuild/blob/69689b3ff26787f18592ae9e13035aff619c2310/src/rustflags.rs#L5
you have
https://github.com/dtolnay/trybuild/blob/69689b3ff26787f18592ae9e13035aff619c2310/src/rustflags.rs#L13-L16

I now have a (very specific) use case where additional rustflags are required.

Suggestion & PR offer

I would be happy to offer to draft a PR (manually, not via AI) to offer something like the following API (reading from the env would clearly lead to flaky tests):

#[test]
fn specific_rustflags() {
    let t = trybuild::TestCases::with_rustflags(vec!["-Zallow-features=", "--cfg", "some_cfg"]);
    t.compile_fail("tests/some_cfg/*.rs");
}
Background

My case is the following - I'm sure there will be others who need rustflags for similar or very different reasons:

  • I have a created wrapper around proc_macro::Diagnostic for proc_macro2.
  • I provide a consistent API for all usage, regardless of which channel the final compilation occurs on.
  • I also use additional experimental features (from the try_trait_v2 family) where available.
  • The API is consistent, regardless of which channel is used for the final compilation. I have fall-back to (acceptable, non-breaking & clearly documented) reduced functionality where certain features are not available.
  • I would like to consistently test (not just manually) the outcomes in the following situation:
    • current stable & beta: no diagnostics & no try_trait_v2 ✅ (I can run CI on various toolchains & cfg-gate the path passed to trybuild)
    • current nightly: diagnostics & try_trait_v2 ✅ (I can run CI on various toolchains & cfg-gate the path passed to trybuild)
    • possible future 1: diagnostics but no try_trait_v2 ❌ (can only test manually, I have no way to construct this situation in trybuild)
    • possible future 2: try_trait_v2 but no diagnostics ❌ (can only test manually, I have no way to construct this situation in trybuild)
Lingua principale
Rust
Stelle
1k
Fork
87
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 dtolnay/trybuild

Tutte le issue di dtolnay/trybuild

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.