Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug where the outer
num_ignored
variable was ignored.
The basic problem is that Rust allows move closure to capture variables if they have a `Copy`able type, leading to the "outer" and "inner" variables to diverge. For example, this simple program: fn main() { let mut x = 0; let mut y = move |z: u32| { x += z; println!("inner x {}", x); }; println!("outer x {}", x); y(2); println!("outer x {}", x); } outputs: outer x 0 inner x 2 outer x 0 Note that the above program gives no warnings (or errors) in rustc or clippy. In this case, the `num_ignored` variable had started life in single-threaded code and later been moved to multi-threaded code. It compiled, even though the outer variable could never be mutated. In other words, lang_tester always said that 0 tests were ignored -- even if some were ignored! This commit fixes this problem using an `AtomicUsize` so that ignored tests now count as can be seen here: $ cargo run --example rust_lang_tester Finished dev [unoptimized + debuginfo] target(s) in 0.12s Running `target/debug/examples/rust_lang_tester` running 7 tests test lang_tests::no_main ... ok test lang_tests::ignore ... ignored test lang_tests::unknown_var ... ok test lang_tests::exit_code ... ok test lang_tests::unused_var ... ok test lang_tests::sig_caught ... ok test lang_tests::custom_cla ... ok test result: ok. 7 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
- Loading branch information