Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some test issues #1396

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
Binary file removed git-branchless-lib/.Cargo.toml.swp
Binary file not shown.
Binary file removed git-branchless-submit/src/.github.rs.swp
Binary file not shown.
29 changes: 29 additions & 0 deletions git-branchless/tests/test_branchless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,32 @@ fn test_sparse_checkout() -> eyre::Result<()> {

Ok(())
}

/// The Git index v4 format is supported as of libgit2 v1.8.0: https://github.com/arxanas/git-branchless/issues/894#issuecomment-2044059209
/// libgit2 v1.8.0 was bundled into git2 v0.19.0: https://github.com/arxanas/git-branchless/issues/894#issuecomment-2270760735
///
/// See https://github.com/arxanas/git-branchless/issues/894
/// See https://github.com/arxanas/git-branchless/issues/1363
#[test]
fn test_index_version_4() -> eyre::Result<()> {
let git = make_git()?;
git.init_repo()?;

git.run(&["update-index", "--index-version=4"])?;
{
let stdout = git.smartlog()?;
insta::assert_snapshot!(stdout, @r###"
@ f777ecc (> master) create initial.txt
"###);
}

{
let (stdout, _stderr) = git.branchless("switch", &["HEAD"])?;
insta::assert_snapshot!(stdout, @r###"
branchless: running command: <git-executable> checkout HEAD
@ f777ecc (> master) create initial.txt
"###);
}

Ok(())
}
26 changes: 14 additions & 12 deletions git-branchless/tests/test_init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;

use eyre::Context;
use itertools::Itertools;
use lib::git::GitVersion;
use lib::testing::{
make_git, make_git_worktree, GitInitOptions, GitRunOptions, GitWorktreeWrapper,
Expand Down Expand Up @@ -363,13 +364,11 @@ fn test_init_uninstall() -> eyre::Result<()> {
Ok(())
}

#[cfg(feature = "man-pages")]
#[test]
fn test_man_viewer_installed() -> eyre::Result<()> {
use std::collections::HashMap;

use itertools::Itertools;

fn test_help_flag() -> eyre::Result<()> {
// NOTE(arxanas, 2024-09-07): Not sure if this test actually fails on
// Windows since it's no longer exercising the `man` code path.
//
// The `man` executable isn't installed for most Windows Git installations.
// In particular, it's not installed on Github Actions. It might be
// possible to install it manually, but I didn't bother.
Expand All @@ -384,6 +383,9 @@ fn test_man_viewer_installed() -> eyre::Result<()> {
let git = make_git()?;
git.init_repo()?;

// NOTE(arxanas, 2024-09-07): This test no longer exercises the man viewer
// code path, so the below environment manipulation probably does nothing.
//
// `env` and `man` are not on the sanitized testing `PATH`, so use the
// caller's `PATH` instead.
let testing_path = git.get_path_for_env();
Expand All @@ -407,10 +409,10 @@ fn test_man_viewer_installed() -> eyre::Result<()> {
..Default::default()
},
)?;
let first_word = stdout.split_whitespace().next();
insta::assert_debug_snapshot!(first_word, @r###"
let first_line = stdout.lines().next();
insta::assert_debug_snapshot!(first_line, @r###"
Some(
"GIT-BRANCHLESS-SMARTLOG(1)",
"`smartlog` command",
)
"###);
}
Expand All @@ -424,10 +426,10 @@ fn test_man_viewer_installed() -> eyre::Result<()> {
..Default::default()
},
)?;
let first_word = stdout.split_whitespace().next();
insta::assert_debug_snapshot!(first_word, @r###"
let first_line = stdout.lines().next();
insta::assert_debug_snapshot!(first_line, @r###"
Some(
"GIT-INIT(1)",
"Initialize the branchless workflow for this repository",
)
"###);
}
Expand Down
13 changes: 3 additions & 10 deletions git-branchless/tests/test_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2738,9 +2738,7 @@ fn test_move_base_onto_head() -> eyre::Result<()> {
if !git.supports_reference_transactions()? {
return Ok(());
}

git.init_repo()?;
git.run(&["config", "branchless.restack.preserveTimestamps", "true"])?;

git.commit_file("test1", 1)?;
git.detach_head()?;
Expand Down Expand Up @@ -6208,15 +6206,10 @@ fn test_move_fixup_added_files() -> eyre::Result<()> {
git.commit_file("test1", 1)?;
git.commit_file("test2", 2)?;

let (stdout, _stderr) = git.run(&[
let (stdout, _stderr) = git.branchless(
"move",
"--in-memory",
"--fixup",
"-x",
"HEAD",
"-d",
"HEAD~",
])?;
&["--in-memory", "--fixup", "-x", "HEAD", "-d", "HEAD~"],
)?;

insta::assert_snapshot!(stdout, @r###"
Attempting rebase in-memory...
Expand Down
Loading