From 8029fa3455bcbbeeff3ab377f791dbead211f522 Mon Sep 17 00:00:00 2001 From: Ziinc Date: Fri, 28 Aug 2026 05:34:01 +0800 Subject: [PATCH] test: cut git subprocess spawns in TestRepo::create() Replace `git init` + `git branch -M ` + `git checkout -b ` with a single `git init -b `, removing 2 of the ~9 git process spawns every integration test pays for setup. On Windows the windows-latest rust CI job spends ~16 minutes running ~663 tests that are dominated by jj/git process-spawn overhead rather than compute, so cutting redundant spawns from the shared setup path used by every TestRepo::new()/with_remote() call should add up across the suite. --- src-tauri/tests/e2e_test_helpers.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src-tauri/tests/e2e_test_helpers.rs b/src-tauri/tests/e2e_test_helpers.rs index b7e348f2..b6776028 100644 --- a/src-tauri/tests/e2e_test_helpers.rs +++ b/src-tauri/tests/e2e_test_helpers.rs @@ -70,8 +70,13 @@ impl TestRepo { let temp_dir = TempDir::new().map_err(|e| format!("Failed to create temp dir: {}", e))?; let repo_path = temp_dir.path().to_string_lossy().to_string(); - // Initialize git repo - Self::run_git(&repo_path, &["init"])?; + // Initialize git repo with its initial branch already named, in one + // spawn instead of `init` + `branch -M` + `checkout -b`. Each test + // creates its own repo, and on Windows process-spawn overhead (not + // git's actual work) dominates these setup calls, so cutting the + // subprocess count here matters for CI wall time. + let default_branch = random_default_branch_name(); + Self::run_git(&repo_path, &["init", "-b", &default_branch])?; // Configure git user (required for commits) Self::run_git(&repo_path, &["config", "user.email", "test@example.com"])?; @@ -81,12 +86,6 @@ impl TestRepo { // that default to core.autocrlf=true rewrite LF to CRLF on checkout. Self::run_git(&repo_path, &["config", "core.autocrlf", "false"])?; - let default_branch = random_default_branch_name(); - Self::run_git(&repo_path, &["branch", "-M", &default_branch]) - .map_err(|e| format!("Failed to create default branch: {}", e))?; - - Self::run_git(&repo_path, &["checkout", "-b", &default_branch])?; - // Record the default branch in local git config so get_default_branch() can // discover it via the merged init.defaultBranch fallback, even when HEAD moves // to a feature branch and there is no remote or main/master branch.