Skip to content

Commit 62ce68d

Browse files
authored
Merge pull request #298 from epage/d
fix(dir)!: Rename `path` feature to `dir` to match mod
2 parents 253fd33 + 5fc67de commit 62ce68d

File tree

8 files changed

+33
-33
lines changed

8 files changed

+33
-33
lines changed

crates/snapbox/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ default = ["color-auto", "diff"]
3434

3535
## Smarter binary file detection
3636
detect-encoding = ["dep:content_inspector"]
37-
## Snapshotting of paths
38-
path = ["dep:tempfile", "dep:walkdir", "dep:dunce", "detect-encoding", "dep:filetime"]
37+
## Snapshotting of directories
38+
dir = ["dep:tempfile", "dep:walkdir", "dep:dunce", "detect-encoding", "dep:filetime"]
3939
## Snapshotting of commands
4040
cmd = ["dep:os_pipe", "dep:wait-timeout", "dep:libc", "dep:windows-sys"]
4141
## Building of examples for snapshotting

crates/snapbox/src/assert/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl Assert {
197197
}
198198

199199
/// # Directory Assertions
200-
#[cfg(feature = "path")]
200+
#[cfg(feature = "dir")]
201201
impl Assert {
202202
#[track_caller]
203203
pub fn subset_eq(

crates/snapbox/src/dir/diff.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(feature = "path")]
1+
#[cfg(feature = "dir")]
22
use crate::filters::{Filter as _, FilterNewlines, FilterPaths, FilterRedactions};
33

44
#[derive(Clone, Debug, PartialEq, Eq)]
@@ -28,7 +28,7 @@ impl PathDiff {
2828
/// Report differences between `actual_root` and `pattern_root`
2929
///
3030
/// Note: Requires feature flag `path`
31-
#[cfg(feature = "path")]
31+
#[cfg(feature = "dir")]
3232
pub fn subset_eq_iter(
3333
pattern_root: impl Into<std::path::PathBuf>,
3434
actual_root: impl Into<std::path::PathBuf>,
@@ -38,7 +38,7 @@ impl PathDiff {
3838
Self::subset_eq_iter_inner(pattern_root, actual_root)
3939
}
4040

41-
#[cfg(feature = "path")]
41+
#[cfg(feature = "dir")]
4242
pub(crate) fn subset_eq_iter_inner(
4343
expected_root: std::path::PathBuf,
4444
actual_root: std::path::PathBuf,
@@ -101,7 +101,7 @@ impl PathDiff {
101101
/// Report differences between `actual_root` and `pattern_root`
102102
///
103103
/// Note: Requires feature flag `path`
104-
#[cfg(feature = "path")]
104+
#[cfg(feature = "dir")]
105105
pub fn subset_matches_iter(
106106
pattern_root: impl Into<std::path::PathBuf>,
107107
actual_root: impl Into<std::path::PathBuf>,
@@ -112,7 +112,7 @@ impl PathDiff {
112112
Self::subset_matches_iter_inner(pattern_root, actual_root, substitutions, true)
113113
}
114114

115-
#[cfg(feature = "path")]
115+
#[cfg(feature = "dir")]
116116
pub(crate) fn subset_matches_iter_inner(
117117
expected_root: std::path::PathBuf,
118118
actual_root: std::path::PathBuf,

crates/snapbox/src/dir/fixture.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ pub struct PathFixture(PathFixtureInner);
66
enum PathFixtureInner {
77
None,
88
Immutable(std::path::PathBuf),
9-
#[cfg(feature = "path")]
9+
#[cfg(feature = "dir")]
1010
MutablePath(std::path::PathBuf),
11-
#[cfg(feature = "path")]
11+
#[cfg(feature = "dir")]
1212
MutableTemp {
1313
temp: tempfile::TempDir,
1414
path: std::path::PathBuf,
@@ -24,7 +24,7 @@ impl PathFixture {
2424
Self(PathFixtureInner::Immutable(target.to_owned()))
2525
}
2626

27-
#[cfg(feature = "path")]
27+
#[cfg(feature = "dir")]
2828
pub fn mutable_temp() -> Result<Self, crate::assert::Error> {
2929
let temp = tempfile::tempdir().map_err(|e| e.to_string())?;
3030
// We need to get the `/private` prefix on Mac so variable substitutions work
@@ -34,15 +34,15 @@ impl PathFixture {
3434
Ok(Self(PathFixtureInner::MutableTemp { temp, path }))
3535
}
3636

37-
#[cfg(feature = "path")]
37+
#[cfg(feature = "dir")]
3838
pub fn mutable_at(target: &std::path::Path) -> Result<Self, crate::assert::Error> {
3939
let _ = std::fs::remove_dir_all(target);
4040
std::fs::create_dir_all(target)
4141
.map_err(|e| format!("Failed to create {}: {}", target.display(), e))?;
4242
Ok(Self(PathFixtureInner::MutablePath(target.to_owned())))
4343
}
4444

45-
#[cfg(feature = "path")]
45+
#[cfg(feature = "dir")]
4646
pub fn with_template(
4747
self,
4848
template_root: &std::path::Path,
@@ -67,9 +67,9 @@ impl PathFixture {
6767
pub fn is_mutable(&self) -> bool {
6868
match &self.0 {
6969
PathFixtureInner::None | PathFixtureInner::Immutable(_) => false,
70-
#[cfg(feature = "path")]
70+
#[cfg(feature = "dir")]
7171
PathFixtureInner::MutablePath(_) => true,
72-
#[cfg(feature = "path")]
72+
#[cfg(feature = "dir")]
7373
PathFixtureInner::MutableTemp { .. } => true,
7474
}
7575
}
@@ -78,9 +78,9 @@ impl PathFixture {
7878
match &self.0 {
7979
PathFixtureInner::None => None,
8080
PathFixtureInner::Immutable(path) => Some(path.as_path()),
81-
#[cfg(feature = "path")]
81+
#[cfg(feature = "dir")]
8282
PathFixtureInner::MutablePath(path) => Some(path.as_path()),
83-
#[cfg(feature = "path")]
83+
#[cfg(feature = "dir")]
8484
PathFixtureInner::MutableTemp { path, .. } => Some(path.as_path()),
8585
}
8686
}
@@ -89,9 +89,9 @@ impl PathFixture {
8989
pub fn close(self) -> Result<(), std::io::Error> {
9090
match self.0 {
9191
PathFixtureInner::None | PathFixtureInner::Immutable(_) => Ok(()),
92-
#[cfg(feature = "path")]
92+
#[cfg(feature = "dir")]
9393
PathFixtureInner::MutablePath(_) => Ok(()),
94-
#[cfg(feature = "path")]
94+
#[cfg(feature = "dir")]
9595
PathFixtureInner::MutableTemp { temp, .. } => temp.close(),
9696
}
9797
}

crates/snapbox/src/dir/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ mod tests;
99
pub use diff::FileType;
1010
pub use diff::PathDiff;
1111
pub use fixture::PathFixture;
12-
#[cfg(feature = "path")]
12+
#[cfg(feature = "dir")]
1313
pub use ops::copy_template;
1414
pub use ops::resolve_dir;
1515
pub use ops::strip_trailing_slash;
16-
#[cfg(feature = "path")]
16+
#[cfg(feature = "dir")]
1717
pub use ops::Walk;
1818

19-
#[cfg(feature = "path")]
19+
#[cfg(feature = "dir")]
2020
pub(crate) use ops::canonicalize;
2121
pub(crate) use ops::display_relpath;
2222
pub(crate) use ops::shallow_copy;

crates/snapbox/src/dir/ops.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// Recursively walk a path
22
///
33
/// Note: Ignores `.keep` files
4-
#[cfg(feature = "path")]
4+
#[cfg(feature = "dir")]
55
pub struct Walk {
66
inner: walkdir::IntoIter,
77
}
88

9-
#[cfg(feature = "path")]
9+
#[cfg(feature = "dir")]
1010
impl Walk {
1111
pub fn new(path: &std::path::Path) -> Self {
1212
Self {
@@ -15,7 +15,7 @@ impl Walk {
1515
}
1616
}
1717

18-
#[cfg(feature = "path")]
18+
#[cfg(feature = "dir")]
1919
impl Iterator for Walk {
2020
type Item = Result<std::path::PathBuf, std::io::Error>;
2121

@@ -39,7 +39,7 @@ impl Iterator for Walk {
3939
/// Note: Generally you'll use [`PathFixture::with_template`][super::PathFixture::with_template] instead.
4040
///
4141
/// Note: Ignores `.keep` files
42-
#[cfg(feature = "path")]
42+
#[cfg(feature = "dir")]
4343
pub fn copy_template(
4444
source: impl AsRef<std::path::Path>,
4545
dest: impl AsRef<std::path::Path>,
@@ -110,7 +110,7 @@ pub(crate) fn shallow_copy(
110110
Ok(())
111111
}
112112

113-
#[cfg(feature = "path")]
113+
#[cfg(feature = "dir")]
114114
fn copy_stats(
115115
source_meta: &std::fs::Metadata,
116116
dest: &std::path::Path,
@@ -121,7 +121,7 @@ fn copy_stats(
121121
Ok(())
122122
}
123123

124-
#[cfg(not(feature = "path"))]
124+
#[cfg(not(feature = "dir"))]
125125
fn copy_stats(
126126
_source_meta: &std::fs::Metadata,
127127
_dest: &std::path::Path,
@@ -157,11 +157,11 @@ pub fn resolve_dir(
157157
}
158158

159159
pub(crate) fn canonicalize(path: &std::path::Path) -> Result<std::path::PathBuf, std::io::Error> {
160-
#[cfg(feature = "path")]
160+
#[cfg(feature = "dir")]
161161
{
162162
dunce::canonicalize(path)
163163
}
164-
#[cfg(not(feature = "path"))]
164+
#[cfg(not(feature = "dir"))]
165165
{
166166
// Hope for the best
167167
Ok(strip_trailing_slash(path).to_owned())

crates/snapbox/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub mod prelude {
9898
/// let expected_root = "tests/snapshots/output.txt";
9999
/// snapbox::assert_subset_eq(expected_root, output_root);
100100
/// ```
101-
#[cfg(feature = "path")]
101+
#[cfg(feature = "dir")]
102102
#[track_caller]
103103
pub fn assert_subset_eq(
104104
expected_root: impl Into<std::path::PathBuf>,
@@ -125,7 +125,7 @@ pub fn assert_subset_eq(
125125
/// let expected_root = "tests/snapshots/output.txt";
126126
/// snapbox::assert_subset_matches(expected_root, output_root);
127127
/// ```
128-
#[cfg(feature = "path")]
128+
#[cfg(feature = "dir")]
129129
#[track_caller]
130130
pub fn assert_subset_matches(
131131
pattern_root: impl Into<std::path::PathBuf>,

crates/trycmd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ default = ["color-auto", "filesystem", "diff"]
3333
color = ["snapbox/color", "dep:anstream"]
3434
color-auto = ["snapbox/color-auto"]
3535
diff = ["snapbox/diff"]
36-
filesystem = ["snapbox/path"]
36+
filesystem = ["snapbox/dir"]
3737

3838
schema = ["dep:schemars", "dep:serde_json"]
3939
examples = ["snapbox/examples"]

0 commit comments

Comments
 (0)