Skip to content

Commit 907ea55

Browse files
committed
Adapt tests to be able to run in miri
Decrease the Ns of bug loops to a smaller N, which makes them a lot faster in miri.
1 parent 9a74608 commit 907ea55

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

compiler/rustc_arena/src/tests.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ fn test_arena_alloc_nested() {
7979
#[test]
8080
pub fn test_copy() {
8181
let arena = TypedArena::default();
82-
for _ in 0..100000 {
82+
#[cfg(not(miri))]
83+
const N: usize = 100000;
84+
#[cfg(miri)]
85+
const N: usize = 1000;
86+
for _ in 0..N {
8387
arena.alloc(Point { x: 1, y: 2, z: 3 });
8488
}
8589
}
@@ -106,15 +110,23 @@ struct Noncopy {
106110
#[test]
107111
pub fn test_noncopy() {
108112
let arena = TypedArena::default();
109-
for _ in 0..100000 {
113+
#[cfg(not(miri))]
114+
const N: usize = 100000;
115+
#[cfg(miri)]
116+
const N: usize = 1000;
117+
for _ in 0..N {
110118
arena.alloc(Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] });
111119
}
112120
}
113121

114122
#[test]
115123
pub fn test_typed_arena_zero_sized() {
116124
let arena = TypedArena::default();
117-
for _ in 0..100000 {
125+
#[cfg(not(miri))]
126+
const N: usize = 100000;
127+
#[cfg(miri)]
128+
const N: usize = 1000;
129+
for _ in 0..N {
118130
arena.alloc(());
119131
}
120132
}
@@ -124,7 +136,11 @@ pub fn test_typed_arena_clear() {
124136
let mut arena = TypedArena::default();
125137
for _ in 0..10 {
126138
arena.clear();
127-
for _ in 0..10000 {
139+
#[cfg(not(miri))]
140+
const N: usize = 10000;
141+
#[cfg(miri)]
142+
const N: usize = 100;
143+
for _ in 0..N {
128144
arena.alloc(Point { x: 1, y: 2, z: 3 });
129145
}
130146
}

0 commit comments

Comments
 (0)