summaryrefslogtreecommitdiff
path: root/compiler/rustc_arena
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2022-06-03 22:46:01 +0200
committerNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2022-06-03 22:46:01 +0200
commit907ea5584173464b31326480dd11d9a71cbd4141 (patch)
tree118ceb90d8230d61fdebb60de1a70ed17f068c96 /compiler/rustc_arena
parent9a74608543d499bcc7dd505e195e8bfab9447315 (diff)
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.
Diffstat (limited to 'compiler/rustc_arena')
-rw-r--r--compiler/rustc_arena/src/tests.rs24
1 files changed, 20 insertions, 4 deletions
diff --git a/compiler/rustc_arena/src/tests.rs b/compiler/rustc_arena/src/tests.rs
index 911e577c1ed..ad61464343a 100644
--- a/compiler/rustc_arena/src/tests.rs
+++ b/compiler/rustc_arena/src/tests.rs
@@ -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 });
}
}
@@ -106,7 +110,11 @@ 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] });
}
}
@@ -114,7 +122,11 @@ pub fn test_noncopy() {
#[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(());
}
}
@@ -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 });
}
}