Skip to content

Commit

Permalink
Remove dead code from test-harness
Browse files Browse the repository at this point in the history
  • Loading branch information
9999years committed Oct 15, 2024
1 parent 095cfa6 commit 64e9918
Showing 1 changed file with 0 additions and 56 deletions.
56 changes: 0 additions & 56 deletions test-harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ use std::process::Command;
use camino::Utf8PathBuf;
use clonable_command::Command as ClonableCommand;
use command_error::CommandExt;
use expect_test::Expect;
use fs_err as fs;
use git_prole::format_bulleted_list;
use git_prole::Git;
use git_prole::Utf8TempDir;
use itertools::Itertools;
use miette::miette;
use miette::Context;
use miette::IntoDiagnostic;

Expand Down Expand Up @@ -101,39 +98,6 @@ impl GitProle {
self.tempdir.join(tail)
}

pub fn exists(&self, path: &str) -> bool {
self.path(path).exists()
}

pub fn contents(&self, path: &str) -> miette::Result<String> {
fs::read_to_string(self.path(path)).into_diagnostic()
}

#[track_caller]
pub fn assert_exists(&self, paths: &[&str]) {
let mut missing = Vec::new();
for path in paths {
if !self.exists(path) {
missing.push(path);
}
}

if !missing.is_empty() {
panic!(
"{:?}",
miette!("Paths are missing:\n{}", format_bulleted_list(missing))
)
}
}

#[track_caller]
pub fn assert_contents(&self, contents: &[(&str, Expect)]) {
for (path, expect) in contents {
let actual = self.contents(path).unwrap();
expect.assert_eq(&actual);
}
}

pub fn sh(&self, script: &str) -> miette::Result<()> {
let tempfile = tempfile::NamedTempFile::new().into_diagnostic()?;
fs::write(
Expand Down Expand Up @@ -170,26 +134,6 @@ impl GitProle {
git
}

pub fn current_branch_in(&self, directory: &str) -> miette::Result<String> {
Ok(self
.git(directory)
.branch()
.current()?
.ok_or_else(|| miette!("HEAD is detached in {directory}"))?
.branch_name()
.to_owned())
}

pub fn upstream_for_branch_in(&self, directory: &str, branch: &str) -> miette::Result<String> {
Ok(self
.git(directory)
.branch()
.upstream(branch)?
.ok_or_else(|| miette!("Branch {branch} has no upstream in {directory}"))?
.qualified_branch_name()
.to_owned())
}

/// Set up a new repository in `path` with a single commit.
pub fn setup_repo(&self, path: &str) -> miette::Result<Utf8PathBuf> {
let path = self.path(path);
Expand Down

0 comments on commit 64e9918

Please sign in to comment.