Skip to content

Commit

Permalink
Adapt tests to be able to run in miri
Browse files Browse the repository at this point in the history
Decrease the Ns of bug loops to a smaller N, which
makes them a lot faster in miri.
  • Loading branch information
Noratrieb committed Jun 3, 2022
1 parent 9a74608 commit 907ea55
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions compiler/rustc_arena/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ fn test_arena_alloc_nested() {
#[test]
pub fn test_copy() {
let arena = TypedArena::default();
for _ in 0..100000 {
#[cfg(not(miri))]
const N: usize = 100000;
#[cfg(miri)]
const N: usize = 1000;
for _ in 0..N {
arena.alloc(Point { x: 1, y: 2, z: 3 });
}
}
Expand All @@ -106,15 +110,23 @@ struct Noncopy {
#[test]
pub fn test_noncopy() {
let arena = TypedArena::default();
for _ in 0..100000 {
#[cfg(not(miri))]
const N: usize = 100000;
#[cfg(miri)]
const N: usize = 1000;
for _ in 0..N {
arena.alloc(Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] });
}
}

#[test]
pub fn test_typed_arena_zero_sized() {
let arena = TypedArena::default();
for _ in 0..100000 {
#[cfg(not(miri))]
const N: usize = 100000;
#[cfg(miri)]
const N: usize = 1000;
for _ in 0..N {
arena.alloc(());
}
}
Expand All @@ -124,7 +136,11 @@ pub fn test_typed_arena_clear() {
let mut arena = TypedArena::default();
for _ in 0..10 {
arena.clear();
for _ in 0..10000 {
#[cfg(not(miri))]
const N: usize = 10000;
#[cfg(miri)]
const N: usize = 100;
for _ in 0..N {
arena.alloc(Point { x: 1, y: 2, z: 3 });
}
}
Expand Down

0 comments on commit 907ea55

Please sign in to comment.