Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 38 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ git-ai = { path = ".", features = ["test-support"] }
rustls-native-certs = "0.8"
tempfile = "3.27"
insta = "1.47"
rand = "0.8"
rand = "0.10"
regex = "1.12"
filetime = "0.2"
serial_test = "3.4"
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/checkpoint_size.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::repos::test_repo::TestRepo;
use rand::{Rng, distributions::Alphanumeric};
use rand::{RngExt, distr::Alphanumeric};
use std::{fs, time::Instant};

#[test]
fn test_checkpoint_size_logging_large_ai_rewrites() {
eprintln!("test_checkpoint_size_logging_large_ai_rewrites started...");
let repo = TestRepo::new();
let mut rng = rand::thread_rng();
let mut rng = rand::rng();

// (target_lines, iterations)
let configs: &[(usize, usize)] = &[
Expand Down
13 changes: 6 additions & 7 deletions tests/integration/performance.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use git_ai::feature_flags::FeatureFlags;
use rand::seq::SliceRandom;
use rand::thread_rng;
use rand::seq::IndexedRandom;
use std::collections::HashMap;
use std::fs::OpenOptions;
use std::io::Write;
Expand Down Expand Up @@ -32,7 +31,7 @@ fn setup() {
mod tests {
use super::*;
use git_ai::observability::wrapper_performance_targets::PERFORMANCE_FLOOR_MS;
use rand::seq::SliceRandom;
use rand::seq::IndexedRandom;
use rstest::rstest;

#[rstest]
Expand Down Expand Up @@ -375,9 +374,9 @@ mod tests {
.expect("Checkpoint mock_ai should succeed");

// Step 3: Select 100 random files from the 1000 and edit them (simulating human edits)
let mut rng = thread_rng();
let mut rng = rand::rng();
let files_to_re_edit: Vec<String> = all_files
.choose_multiple(&mut rng, 100.min(all_files.len()))
.sample(&mut rng, 100.min(all_files.len()))
.cloned()
.collect();

Expand Down Expand Up @@ -577,7 +576,7 @@ pub fn find_random_files_with_options(
return Err("No files found in repository".to_string());
}

let mut rng = thread_rng();
let mut rng = rand::rng();

// Find large files using file size as a proxy (> 100KB considered large)
// This is much faster than reading files to count lines
Expand Down Expand Up @@ -609,7 +608,7 @@ pub fn find_random_files_with_options(
.collect();

let random_files: Vec<String> = candidates
.choose_multiple(&mut rng, options.random_file_count.min(candidates.len()))
.sample(&mut rng, options.random_file_count.min(candidates.len()))
.map(|s| (*s).clone())
.collect();

Expand Down
38 changes: 19 additions & 19 deletions tests/integration/repos/test_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use git_ai::git::repo_storage::PersistedWorkingLog;
use git_ai::git::repository as GitAiRepository;
use git_ai::observability::wrapper_performance_targets::BenchmarkResult;
use insta::{Settings, assert_debug_snapshot};
use rand::Rng;
use rand::RngExt;
use std::cell::Cell;
use std::collections::HashMap;
use std::fs;
Expand Down Expand Up @@ -478,8 +478,8 @@ fn shared_daemon_process(repo_path: &Path) -> Arc<DaemonProcess> {
}

fn start_shared_daemon_process(repo_path: &Path, shard: Option<usize>) -> DaemonProcess {
let mut rng = rand::thread_rng();
let n: u64 = rng.gen_range(0..10_000_000_000);
let mut rng = rand::rng();
let n: u64 = rng.random_range(0..10_000_000_000);
let base = std::env::temp_dir();
let shard_suffix = shard
.map(|shard| format!("-pool-{}", shard))
Expand Down Expand Up @@ -936,8 +936,8 @@ impl TestRepo {
let default_branch = default_branchname();
let base_branch = base.current_branch();
if base_branch == default_branch {
let mut rng = rand::thread_rng();
let n: u64 = rng.gen_range(0..10_000_000_000);
let mut rng = rand::rng();
let n: u64 = rng.random_range(0..10_000_000_000);
let temp_branch = format!("base-worktree-{}", n);
let temp_ref = format!("refs/heads/{}", temp_branch);
let switch_output = Command::new(real_git_executable())
Expand All @@ -959,8 +959,8 @@ impl TestRepo {
}
}

let mut rng = rand::thread_rng();
let wt_n: u64 = rng.gen_range(0..10_000_000_000);
let mut rng = rand::rng();
let wt_n: u64 = rng.random_range(0..10_000_000_000);
let worktree_path = std::env::temp_dir().join(format!("{}-wt", wt_n));

let output = Command::new(real_git_executable())
Expand Down Expand Up @@ -1039,7 +1039,7 @@ impl TestRepo {
// Reuse the base DB path for linked worktrees so test expectations and daemon writes align.
base_test_db_path.clone()
} else {
let wt_db_n: u64 = rng.gen_range(0..10_000_000_000);
let wt_db_n: u64 = rng.random_range(0..10_000_000_000);
std::env::temp_dir().join(format!("{}-db", wt_db_n))
};

Expand Down Expand Up @@ -1073,8 +1073,8 @@ impl TestRepo {
// Isolate this test binary's HOME before any git or git-ai subprocess is spawned.
ensure_isolated_process_home();

let mut rng = rand::thread_rng();
let n: u64 = rng.gen_range(0..10000000000);
let mut rng = rand::rng();
let n: u64 = rng.random_range(0..10000000000);
let base = std::env::temp_dir();
let path = base.join(n.to_string());
let test_home = base.join(format!("{}-home", n));
Expand Down Expand Up @@ -1116,8 +1116,8 @@ impl TestRepo {
git_mode: GitTestMode,
daemon_scope: DaemonTestScope,
) -> Self {
let mut rng = rand::thread_rng();
let n: u64 = rng.gen_range(0..10000000000);
let mut rng = rand::rng();
let n: u64 = rng.random_range(0..10000000000);
let base = std::env::temp_dir();
let main_path = base.join(format!("{}-main", n));
let worktree_path = base.join(format!("{}-wt", n));
Expand Down Expand Up @@ -1199,8 +1199,8 @@ impl TestRepo {
git_mode: GitTestMode,
daemon_scope: DaemonTestScope,
) -> Self {
let mut rng = rand::thread_rng();
let n: u64 = rng.gen_range(0..10000000000);
let mut rng = rand::rng();
let n: u64 = rng.random_range(0..10000000000);
let base = std::env::temp_dir();
let path = base.join(n.to_string());
let test_home = base.join(format!("{}-home", n));
Expand Down Expand Up @@ -1256,11 +1256,11 @@ impl TestRepo {
git_mode: GitTestMode,
daemon_scope: DaemonTestScope,
) -> (Self, Self) {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let base = std::env::temp_dir();

// Create bare upstream repository (acts as the remote server)
let upstream_n: u64 = rng.gen_range(0..10000000000);
let upstream_n: u64 = rng.random_range(0..10000000000);
let upstream_path = base.join(upstream_n.to_string());
let upstream_test_home = base.join(format!("{}-home", upstream_n));
let upstream_test_db_path =
Expand All @@ -1285,7 +1285,7 @@ impl TestRepo {
let _ = upstream.git(&["symbolic-ref", "HEAD", "refs/heads/main"]);

// Clone upstream to create mirror with origin configured
let mirror_n: u64 = rng.gen_range(0..10000000000);
let mirror_n: u64 = rng.random_range(0..10000000000);
let mirror_path = base.join(mirror_n.to_string());
let mirror_test_home = base.join(format!("{}-home", mirror_n));
let mirror_test_db_path =
Expand Down Expand Up @@ -1352,8 +1352,8 @@ impl TestRepo {
git_mode: GitTestMode,
daemon_scope: DaemonTestScope,
) -> Self {
let mut rng = rand::thread_rng();
let db_n: u64 = rng.gen_range(0..10000000000);
let mut rng = rand::rng();
let db_n: u64 = rng.random_range(0..10000000000);
let test_home = std::env::temp_dir().join(format!("{}-home", db_n));
let test_db_path = resolve_test_db_path(&std::env::temp_dir(), db_n, &test_home, git_mode);

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/worktrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use git_ai::authorship::transcript::Message;
use git_ai::authorship::working_log::{AgentId, CheckpointKind};
use git_ai::git::repository as GitAiRepository;
use insta::assert_debug_snapshot;
use rand::Rng;
use rand::RngExt;
use regex::Regex;
use serde_json::json;
use std::collections::HashMap;
Expand Down Expand Up @@ -155,8 +155,8 @@ fn assert_file_lines(
}

fn unique_worktree_path() -> PathBuf {
let mut rng = rand::thread_rng();
let n: u64 = rng.gen_range(0..10_000_000_000);
let mut rng = rand::rng();
let n: u64 = rng.random_range(0..10_000_000_000);
std::env::temp_dir().join(format!("git-ai-worktree-{}", n))
}

Expand Down
Loading