Allow specifying MAX_EXCERPTS via an env variable in random tests

This commit is contained in:
Antonio Scandurra 2021-12-16 12:28:54 +01:00
parent 3e2f684545
commit ec39c9d335
7 changed files with 12 additions and 7 deletions

View file

@ -178,13 +178,18 @@ impl MultiBuffer {
#[cfg(any(test, feature = "test-support"))]
pub fn build_random(
excerpts: usize,
mut rng: &mut impl rand::Rng,
cx: &mut gpui::MutableAppContext,
) -> ModelHandle<Self> {
use rand::prelude::*;
use std::env;
use text::RandomCharIter;
let max_excerpts = env::var("MAX_EXCERPTS")
.map(|i| i.parse().expect("invalid `MAX_EXCERPTS` variable"))
.unwrap_or(5);
let excerpts = rng.gen_range(1..=max_excerpts);
cx.add_model(|cx| {
let mut multibuffer = MultiBuffer::new(0);
let mut buffers = Vec::new();