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

Abierto
#260 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

  • #262 de @kioku — cerrado sin fusionar

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
32/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).

Lenguaje dominante
Rust
Estrellas
601
Forks
34
Merge medio
1 h 58 min
PR fusionados (30 d)
45

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de makepad/relax

Todos los issues de makepad/relax

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.