Skip to content

Commit

Permalink
fix(dir): Rename path to dir
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Apr 23, 2024
1 parent 877c0b1 commit e764cde
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions crates/snapbox/src/assert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl Assert {
}

let checks: Vec<_> =
crate::path::PathDiff::subset_eq_iter_inner(expected_root, actual_root).collect();
crate::dir::PathDiff::subset_eq_iter_inner(expected_root, actual_root).collect();
self.verify(checks);
}

Expand Down Expand Up @@ -248,7 +248,7 @@ impl Assert {
Action::Ignore | Action::Verify | Action::Overwrite => {}
}

let checks: Vec<_> = crate::path::PathDiff::subset_matches_iter_inner(
let checks: Vec<_> = crate::dir::PathDiff::subset_matches_iter_inner(
expected_root,
actual_root,
&self.substitutions,
Expand All @@ -261,7 +261,7 @@ impl Assert {
#[track_caller]
fn verify(
&self,
mut checks: Vec<Result<(std::path::PathBuf, std::path::PathBuf), crate::path::PathDiff>>,
mut checks: Vec<Result<(std::path::PathBuf, std::path::PathBuf), crate::dir::PathDiff>>,
) {
if checks.iter().all(Result::is_ok) {
for check in checks {
Expand Down
2 changes: 1 addition & 1 deletion crates/snapbox/src/data/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl From<Inline> for DataSource {
impl std::fmt::Display for DataSource {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self.inner {
DataSourceInner::Path(value) => crate::path::display_relpath(value).fmt(f),
DataSourceInner::Path(value) => crate::dir::display_relpath(value).fmt(f),
DataSourceInner::Inline(value) => value.fmt(f),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl PathDiff {
expected_root: std::path::PathBuf,
actual_root: std::path::PathBuf,
) -> impl Iterator<Item = Result<(std::path::PathBuf, std::path::PathBuf), Self>> {
let walker = crate::path::Walk::new(&expected_root);
let walker = crate::dir::Walk::new(&expected_root);
walker.map(move |r| {
let expected_path = r.map_err(|e| Self::Failure(e.to_string().into()))?;
let rel = expected_path.strip_prefix(&expected_root).unwrap();
Expand Down Expand Up @@ -119,7 +119,7 @@ impl PathDiff {
substitutions: &crate::Redactions,
normalize_paths: bool,
) -> impl Iterator<Item = Result<(std::path::PathBuf, std::path::PathBuf), Self>> + '_ {
let walker = crate::path::Walk::new(&expected_root);
let walker = crate::dir::Walk::new(&expected_root);
walker.map(move |r| {
let expected_path = r.map_err(|e| Self::Failure(e.to_string().into()))?;
let rel = expected_path.strip_prefix(&expected_root).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl PathFixture {
let temp = tempfile::tempdir().map_err(|e| e.to_string())?;
// We need to get the `/private` prefix on Mac so variable substitutions work
// correctly
let path = crate::path::canonicalize(temp.path())
let path = crate::dir::canonicalize(temp.path())
.map_err(|e| format!("Failed to canonicalize {}: {}", temp.path().display(), e))?;
Ok(Self(PathFixtureInner::MutableTemp { temp, path }))
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions crates/snapbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
//! [`Output`][std::process::Output].
//!
//! Testing Filesystem Interactions:
//! - [`path::PathFixture`]: Working directory for tests
//! - [`dir::PathFixture`]: Working directory for tests
//! - [`Assert`]: Diff a directory against files present in a pattern directory
//!
//! You can also build your own version of these with the lower-level building blocks these are
Expand Down Expand Up @@ -66,8 +66,8 @@ mod macros;
pub mod assert;
pub mod cmd;
pub mod data;
pub mod dir;
pub mod filters;
pub mod path;
pub mod report;
pub mod utils;

Expand Down
28 changes: 14 additions & 14 deletions crates/trycmd/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use std::io::stderr;

use rayon::prelude::*;
use snapbox::data::DataFormat;
use snapbox::dir::FileType;
use snapbox::filters::{Filter as _, FilterNewlines, FilterPaths, FilterRedactions};
use snapbox::path::FileType;
use snapbox::IntoData;

#[derive(Debug)]
Expand Down Expand Up @@ -188,7 +188,7 @@ impl Case {
.map(|p| {
sequence.fs.rel_cwd().map(|rel| {
let p = p.join(rel);
snapbox::path::strip_trailing_slash(&p).to_owned()
snapbox::dir::strip_trailing_slash(&p).to_owned()
})
})
.transpose()
Expand Down Expand Up @@ -504,7 +504,7 @@ impl Case {
} else {
let fixture_root = self.path.with_extension("out");
if fixture_root.exists() {
for status in snapbox::path::PathDiff::subset_matches_iter(
for status in snapbox::dir::PathDiff::subset_matches_iter(
fixture_root,
actual_root,
substitutions,
Expand Down Expand Up @@ -878,11 +878,11 @@ impl FileStatus {
}
}

impl From<snapbox::path::PathDiff> for FileStatus {
fn from(other: snapbox::path::PathDiff) -> Self {
impl From<snapbox::dir::PathDiff> for FileStatus {
fn from(other: snapbox::dir::PathDiff) -> Self {
match other {
snapbox::path::PathDiff::Failure(err) => FileStatus::Failure(err),
snapbox::path::PathDiff::TypeMismatch {
snapbox::dir::PathDiff::Failure(err) => FileStatus::Failure(err),
snapbox::dir::PathDiff::TypeMismatch {
expected_path,
actual_path,
expected_type,
Expand All @@ -893,7 +893,7 @@ impl From<snapbox::path::PathDiff> for FileStatus {
actual_type,
expected_type,
},
snapbox::path::PathDiff::LinkMismatch {
snapbox::dir::PathDiff::LinkMismatch {
expected_path,
actual_path,
expected_target,
Expand All @@ -904,7 +904,7 @@ impl From<snapbox::path::PathDiff> for FileStatus {
actual_target,
expected_target,
},
snapbox::path::PathDiff::ContentMismatch {
snapbox::dir::PathDiff::ContentMismatch {
expected_path,
actual_path,
expected_content,
Expand Down Expand Up @@ -1016,20 +1016,20 @@ fn fs_context(
cwd: Option<&std::path::Path>,
sandbox: bool,
mode: &crate::Mode,
) -> Result<snapbox::path::PathFixture, crate::Error> {
) -> Result<snapbox::dir::PathFixture, crate::Error> {
if sandbox {
#[cfg(feature = "filesystem")]
match mode {
crate::Mode::Dump(root) => {
let target = root.join(path.with_extension("out").file_name().unwrap());
let mut context = snapbox::path::PathFixture::mutable_at(&target)?;
let mut context = snapbox::dir::PathFixture::mutable_at(&target)?;
if let Some(cwd) = cwd {
context = context.with_template(cwd)?;
}
Ok(context)
}
crate::Mode::Fail | crate::Mode::Overwrite => {
let mut context = snapbox::path::PathFixture::mutable_temp()?;
let mut context = snapbox::dir::PathFixture::mutable_temp()?;
if let Some(cwd) = cwd {
context = context.with_template(cwd)?;
}
Expand All @@ -1040,7 +1040,7 @@ fn fs_context(
Err("Sandboxing is disabled".into())
} else {
Ok(cwd
.map(snapbox::path::PathFixture::immutable)
.unwrap_or_else(snapbox::path::PathFixture::none))
.map(snapbox::dir::PathFixture::immutable)
.unwrap_or_else(snapbox::dir::PathFixture::none))
}
}
4 changes: 2 additions & 2 deletions crates/trycmd/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ impl TryCmd {
.fs
.base
.take()
.map(|p| snapbox::path::resolve_dir(p).map_err(|e| e.to_string()))
.map(|p| snapbox::dir::resolve_dir(p).map_err(|e| e.to_string()))
.transpose()?;
sequence.fs.cwd = sequence
.fs
.cwd
.take()
.map(|p| snapbox::path::resolve_dir(p).map_err(|e| e.to_string()))
.map(|p| snapbox::dir::resolve_dir(p).map_err(|e| e.to_string()))
.transpose()?;

Ok(sequence)
Expand Down

0 comments on commit e764cde

Please sign in to comment.