Skip to content
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.4.0

* Prefer `CARGO_WORKSPACE_DIR` if set, use heuristic as fallback to find cargo workspace ([#34])

# 1.3.0

* Add `data()` getter to Expect ([#31])
Expand All @@ -13,6 +17,7 @@

* No changelog until this point :-(

[#34]: https://github.com/rust-analyzer/expect-test/pull/34
[#31]: https://github.com/rust-analyzer/expect-test/pull/31
[#27]: https://github.com/rust-analyzer/expect-test/pull/27
[#26]: https://github.com/rust-analyzer/expect-test/pull/26
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "expect-test"
version = "1.3.0"
version = "1.4.0"
description = "Minimalistic snapshot testing library"
keywords = ["snapshot", "testing", "expect"]
categories = ["development-tools::testing"]
Expand Down
16 changes: 9 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,7 @@ fn lit_kind_for_patch(patch: &str) -> StrLitKind {
let has_dquote = patch.chars().any(|c| c == '"');
if !has_dquote {
let has_bslash_or_newline = patch.chars().any(|c| matches!(c, '\\' | '\n'));
return if has_bslash_or_newline {
StrLitKind::Raw(1)
} else {
StrLitKind::Normal
};
return if has_bslash_or_newline { StrLitKind::Raw(1) } else { StrLitKind::Normal };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crap, "format on save" strikes again

}

// Find the maximum number of hashes that follow a double quote in the string.
Expand Down Expand Up @@ -649,9 +645,15 @@ fn to_abs_ws_path(path: &Path) -> PathBuf {
static WORKSPACE_ROOT: OnceCell<PathBuf> = OnceCell::new();
WORKSPACE_ROOT
.get_or_try_init(|| {
let my_manifest = env::var("CARGO_MANIFEST_DIR")?;
// Until https://github.com/rust-lang/cargo/issues/3946 is resolved, this
// is set with a hack like https://github.com/rust-lang/cargo/issues/3946#issuecomment-973132993
if let Ok(workspace_root) = env::var("CARGO_WORKSPACE_DIR") {
return Ok(workspace_root.into());
}

// Heuristic, see https://github.com/rust-lang/cargo/issues/3946
// If a hack isn't used, we use a heuristic to find the "top-level" workspace.
// This fails in some cases, see https://github.com/rust-analyzer/expect-test/issues/33
let my_manifest = env::var("CARGO_MANIFEST_DIR")?;
let workspace_root = Path::new(&my_manifest)
.ancestors()
.filter(|it| it.join("Cargo.toml").exists())
Expand Down