Relax live tests rerun the whole suite after a one-line body edit

Aperta
#260 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #262 di @kioku — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

Start in libs/relax/compiler/src/domain.rs at threads_besides and domain::enter, then compare how the live-test restart decision consumes that thread set. Build the issue's minimal-repro/ crate and run relax test ctfe-thread-repro --lib --live; edit src/lib.rs after the first pass to reproduce selected=all instead of the control's selected=affected. The live_test_results fixture came with c9f9d129e and lacks a proc macro, so extend or add a fixture covering constant-evaluation/macro-expansion worker registration. Done means the proc-macro case resets the static and reruns only affected, with the worker no longer counted as a test-started thread.

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

Descrizione

Verified on upstream Relax 27746f54 (Linux). minimal-repro/ is a standalone Rust library with two tests and one local identity proc macro; it has no registry dependencies. Neither test starts a thread.

Crate files

Cargo.toml
[package]
name = "ctfe-thread-repro"
version = "0.1.0"
edition = "2021"

[dependencies]
repro-macro = { path = "macros" }
src/lib.rs
use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};

static COUNTER: AtomicUsize = AtomicUsize::new(0);

#[test]
fn affected() {
    assert_eq!(COUNTER.swap(1, Relaxed), repro_macro::identity!(0));
}

#[test]
fn unrelated() {}
macros/Cargo.toml
[package]
name = "repro-macro"
version = "0.1.0"
edition = "2021"

[lib]
proc-macro = true
macros/src/lib.rs
extern crate proc_macro;

use proc_macro::TokenStream;

#[proc_macro]
pub fn identity(input: TokenStream) -> TokenStream {
    input
}

Reproduce

  1. Create minimal-repro/ in a fresh working directory using the four files above. With the 27746f54 Relax build and a host Rust toolchain available, run from the crate root:
    relax test ctfe-thread-repro --lib --live
    
    The recorded run used a fresh HOME and TMPDIR, with network access disabled.
  2. Wait for both tests to pass and for testverdict group=0.
  3. In src/lib.rs, change COUNTER.swap(1, Relaxed) to COUNTER.swap(2, Relaxed) and save without stopping Relax. Do not change the expected old value (0).

Expected: Relax resets the affected test's static and reruns only affected (selected=affected, skipped=1).

Actual: Relax reports that it patched one function, then prints restarting (1 static(s) of the program hold an earlier run's values, and 1 thread(s) an earlier test started still run (thread-5)). It reruns both tests (selected=all, skipped=0).

testverdict group=0 ran=2 passed=2 failed=0 ms=191.5 selected=all skipped=0 why="unknown reach: 2 tests" borrowck=clean
relax live: restarting (1 static(s) of the program hold an earlier run's values, and 1 thread(s) an earlier test started still run (thread-5))
testverdict group=1 ran=2 passed=2 failed=0 ms=7.7 selected=all skipped=0 why="unknown reach: 2 tests" borrowck=clean

Control: In a fresh copy, replace repro_macro::identity!(0) with 0 and remove the repro-macro dependency from Cargo.toml. Repeat the edit: Relax resets the static and reruns only affected. No const-generic return is needed to reproduce the restart.

testverdict group=0 ran=2 passed=2 failed=0 ms=247.4 selected=all skipped=0 why="unknown reach: 2 tests" borrowck=clean
testverdict group=1 ran=1 passed=2 failed=0 ms=1.9 selected=affected skipped=1 statics_reset=1 borrowck=clean

Diagnosis: In the original larger case, a Relax worker registered during pre-test constant evaluation was counted as a thread started by an earlier test, forcing a restart instead of an affected-only rerun. The reduced case shows the same false attribution, but its black-box output does not identify the worker.

Origin: the restart rule came in with c9f9d129e ("relax test --live: each rerun starts from the program's initial statics"), which restarts "when a thread an earlier test started still runs". domain::threads_besides (libs/relax/compiler/src/domain.rs) counts every thread registered in the program's domain except the harness, and domain::enter registers any thread that runs program code, including Relax's own worker during constant evaluation and macro expansion. That registration predates c9f9d129e, and the commit's live_test_results fixture has no proc macro, so this case was likely not exercised.

Possibly related: #223 (proc-macro world in live sessions).

Lingua principale
Rust
Stelle
601
Fork
34
Merge medio
1h 58m
PR unite (30g)
45

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 makepad/relax

Tutte le issue di makepad/relax

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.