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

Open
#260 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #262 by @kioku — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
32/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

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.

Written by the indexing model from the issue text.

Description

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

Dominant language
Rust
Stars
601
Forks
34
Avg merge
1h 58m
Merged PRs (30d)
45

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from makepad/relax

All issues in makepad/relax

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.