From 48a29759e677ee9d52e7c38375b2aa38131e89cd Mon Sep 17 00:00:00 2001 From: Caleb Fujimori Date: Thu, 10 Oct 2024 08:52:41 -0700 Subject: [PATCH] Remove additions to testing API --- git-branchless-lib/src/testing.rs | 40 +++------------------ git-branchless/tests/test_hooks.rs | 56 +++++++++++------------------- 2 files changed, 25 insertions(+), 71 deletions(-) diff --git a/git-branchless-lib/src/testing.rs b/git-branchless-lib/src/testing.rs index 87dee838a..cae3432d7 100644 --- a/git-branchless-lib/src/testing.rs +++ b/git-branchless-lib/src/testing.rs @@ -536,15 +536,14 @@ then you can only run tests in the main `git-branchless` and \ /// hash. The filename is always appended to the message prefix. #[track_caller] #[instrument] - pub fn commit_file_with_contents_and_message_and_file_name( + pub fn commit_file_with_contents_and_message( &self, name: &str, time: isize, contents: &str, message_prefix: &str, - file_name: &str, ) -> eyre::Result { - let message = format!("{message_prefix} {file_name}"); + let message = format!("{message_prefix} {name}.txt"); self.write_file_txt(name, contents)?; self.run(&["add", "."])?; self.run_with_options( @@ -563,26 +562,6 @@ then you can only run tests in the main `git-branchless` and \ Ok(oid) } - /// Commit a file with given contents and message. The `time` argument is - /// used to set the commit timestamp, which is factored into the commit - /// hash. The filename is always appended to the message prefix. - #[instrument] - pub fn commit_file_with_contents_and_message( - &self, - name: &str, - time: isize, - contents: &str, - message_prefix: &str, - ) -> eyre::Result { - self.commit_file_with_contents_and_message_and_file_name( - name, - time, - contents, - message_prefix, - format!("{name}.txt").as_str(), - ) - } - /// Commit a file with given contents and a default message. The `time` /// argument is used to set the commit timestamp, which is factored into the /// commit hash. @@ -946,18 +925,6 @@ pub mod pty { branchless_subcommand: &str, args: &[&str], inputs: &[PtyAction], - ) -> eyre::Result { - // add "branchless" to subcommand list - run_in_pty_with_command(git, &["branchless", branchless_subcommand], args, inputs) - } - - /// Run the provided script in the context of a virtual terminal. - #[track_caller] - pub fn run_in_pty_with_command( - git: &Git, - command: &[&str], - args: &[&str], - inputs: &[PtyAction], ) -> eyre::Result { // Use the native pty implementation for the system let pty_system = native_pty_system(); @@ -977,7 +944,8 @@ pub mod pty { cmd.env(k, v); } cmd.env("TERM", "xterm"); - cmd.args(command); + cmd.arg("branchless"); + cmd.arg(branchless_subcommand); cmd.args(args); cmd.cwd(&git.repo_path); diff --git a/git-branchless/tests/test_hooks.rs b/git-branchless/tests/test_hooks.rs index 41648f37a..f142d789a 100644 --- a/git-branchless/tests/test_hooks.rs +++ b/git-branchless/tests/test_hooks.rs @@ -5,12 +5,9 @@ use lib::core::eventlog::{Event, EventLogDb, EventReplayer}; use lib::core::formatting::Glyphs; use lib::git::GitVersion; use lib::testing::make_git; -use lib::testing::pty::{run_in_pty_with_command, PtyAction}; use lib::util::get_sh; use std::process::Command; -const CARRIAGE_RETURN: &str = "\r"; - #[test] fn test_abandoned_commit_message() -> eyre::Result<()> { let git = make_git()?; @@ -425,44 +422,33 @@ fn test_git_rebase_multiple_fixup_does_not_strand_commits() -> eyre::Result<()> git.init_repo()?; git.detach_head()?; - git.commit_file_with_contents_and_message_and_file_name( - "test1", - 1, - "bleh", - "create", - "test1.txt", - )?; - git.commit_file_with_contents_and_message_and_file_name( - "test2", - 2, - "bleh", - "fixup! create", - "test1.txt", - )?; - git.commit_file_with_contents_and_message_and_file_name( - "test3", - 3, - "bleh", - "fixup! create", - "test1.txt", - )?; - - run_in_pty_with_command( - &git, - &["rebase"], - &["-i", "--autosquash", "master"], - &[ - PtyAction::WaitUntilContains(" "), - PtyAction::Write(CARRIAGE_RETURN), - ], - )?; + + git.write_file("test1.txt", "bleh")?; + git.run(&["add", "."])?; + git.run(&["commit", "-m", "create test1.txt"])?; + git.write_file("test2.txt", "bleh")?; + git.run(&["add", "."])?; + git.run(&["commit", "-m", "fixup! create test1.txt"])?; + git.write_file("test3.txt", "bleh")?; + git.run(&["add", "."])?; + git.run(&["commit", "-m", "fixup! create test1.txt"])?; + git.write_file("test3.txt", "bleh")?; + + git.run(&[ + "-c", + "sequence.editor=:", + "rebase", + "-i", + "--autosquash", + "master", + ])?; { let stdout = git.smartlog()?; insta::assert_snapshot!(stdout, @r###" O f777ecc (master) create initial.txt | - @ 916a41f create test1.txt + @ 8777bab create test1.txt "###); }