Disable line wrapping during scenario tests (#784)

Adds support for a `PUFFIN_NO_WRAP` environment variable which disables
line wrapping in `miette` output.

We set this variable in the scenario tests to improve the readability of
snapshots.

I contributed the ability to disable line wrapping upstream at
https://github.com/zkat/miette/pull/328
This commit is contained in:
Zanie Blue 2024-01-04 13:07:16 -06:00 committed by GitHub
parent d7c9b151fb
commit 5e04a95c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 59 deletions

4
Cargo.lock generated
View File

@ -1755,7 +1755,7 @@ dependencies = [
[[package]] [[package]]
name = "miette" name = "miette"
version = "5.10.0" version = "5.10.0"
source = "git+https://github.com/zkat/miette.git?rev=fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6#fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6" source = "git+https://github.com/zkat/miette.git?rev=b0744462adbbfbb6d845f382db36be883c7f3c45#b0744462adbbfbb6d845f382db36be883c7f3c45"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"backtrace-ext", "backtrace-ext",
@ -1775,7 +1775,7 @@ dependencies = [
[[package]] [[package]]
name = "miette-derive" name = "miette-derive"
version = "5.10.0" version = "5.10.0"
source = "git+https://github.com/zkat/miette.git?rev=fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6#fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6" source = "git+https://github.com/zkat/miette.git?rev=b0744462adbbfbb6d845f382db36be883c7f3c45#b0744462adbbfbb6d845f382db36be883c7f3c45"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View File

@ -46,8 +46,8 @@ indicatif = { version = "0.17.7" }
indoc = { version = "2.0.4" } indoc = { version = "2.0.4" }
itertools = { version = "0.11.0" } itertools = { version = "0.11.0" }
mailparse = { version = "0.14.0" } mailparse = { version = "0.14.0" }
# For additional textwrap options: https://github.com/zkat/miette/pull/321 # For additional textwrap options: https://github.com/zkat/miette/pull/321, https://github.com/zkat/miette/pull/328
miette = { git = "https://github.com/zkat/miette.git", rev = "fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6" } miette = { git = "https://github.com/zkat/miette.git", rev = "b0744462adbbfbb6d845f382db36be883c7f3c45" }
once_cell = { version = "1.18.0" } once_cell = { version = "1.18.0" }
petgraph = { version = "0.6.4" } petgraph = { version = "0.6.4" }
platform-info = { version = "2.0.2" } platform-info = { version = "2.0.2" }

View File

@ -57,6 +57,7 @@ pub(crate) async fn pip_compile(
.break_words(false) .break_words(false)
.word_separator(textwrap::WordSeparator::AsciiSpace) .word_separator(textwrap::WordSeparator::AsciiSpace)
.word_splitter(textwrap::WordSplitter::NoHyphenation) .word_splitter(textwrap::WordSplitter::NoHyphenation)
.wrap_lines(env::var("PUFFIN_NO_WRAP").map(|_| false).unwrap_or(true))
.build(), .build(),
) )
}))?; }))?;

View File

@ -1,3 +1,4 @@
use std::env;
use std::fmt::Write; use std::fmt::Write;
use std::path::Path; use std::path::Path;
@ -58,6 +59,7 @@ pub(crate) async fn pip_install(
.break_words(false) .break_words(false)
.word_separator(textwrap::WordSeparator::AsciiSpace) .word_separator(textwrap::WordSeparator::AsciiSpace)
.word_splitter(textwrap::WordSplitter::NoHyphenation) .word_splitter(textwrap::WordSplitter::NoHyphenation)
.wrap_lines(env::var("PUFFIN_NO_WRAP").map(|_| false).unwrap_or(true))
.build(), .build(),
) )
}))?; }))?;

View File

@ -43,6 +43,7 @@ fn requires_package_does_not_exist() -> Result<()> {
.arg("--cache-dir") .arg("--cache-dir")
.arg(cache_dir.path()) .arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str()) .env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###" .current_dir(&temp_dir), @r###"
success: false success: false
exit_code: 2 exit_code: 2
@ -87,6 +88,7 @@ fn requires_exact_version_does_not_exist() -> Result<()> {
.arg("--cache-dir") .arg("--cache-dir")
.arg(cache_dir.path()) .arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str()) .env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###" .current_dir(&temp_dir), @r###"
success: false success: false
exit_code: 1 exit_code: 1
@ -94,11 +96,7 @@ fn requires_exact_version_does_not_exist() -> Result<()> {
----- stderr ----- ----- stderr -----
× No solution found when resolving dependencies: × No solution found when resolving dependencies:
Because there is no version of Because there is no version of a available matching ==2.0.0 and root depends on a==2.0.0, version solving failed.
a
available matching ==2.0.0 and root depends on
a==2.0.0, version solving
failed.
"###); "###);
}); });
@ -137,6 +135,7 @@ fn requires_greater_version_does_not_exist() -> Result<()> {
.arg("--cache-dir") .arg("--cache-dir")
.arg(cache_dir.path()) .arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str()) .env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###" .current_dir(&temp_dir), @r###"
success: false success: false
exit_code: 1 exit_code: 1
@ -144,11 +143,7 @@ fn requires_greater_version_does_not_exist() -> Result<()> {
----- stderr ----- ----- stderr -----
× No solution found when resolving dependencies: × No solution found when resolving dependencies:
Because there is no version of Because there is no version of a available matching >1.0.0 and root depends on a>1.0.0, version solving failed.
a
available matching >1.0.0 and root depends on
a>1.0.0, version
solving failed.
"###); "###);
}); });
@ -188,6 +183,7 @@ fn requires_less_version_does_not_exist() -> Result<()> {
.arg("--cache-dir") .arg("--cache-dir")
.arg(cache_dir.path()) .arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str()) .env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###" .current_dir(&temp_dir), @r###"
success: false success: false
exit_code: 1 exit_code: 1
@ -195,11 +191,7 @@ fn requires_less_version_does_not_exist() -> Result<()> {
----- stderr ----- ----- stderr -----
× No solution found when resolving dependencies: × No solution found when resolving dependencies:
Because there is no version of Because there is no version of a available matching <2.0.0 and root depends on a<2.0.0, version solving failed.
a
available matching <2.0.0 and root depends on
a<2.0.0, version solving
failed.
"###); "###);
}); });
@ -239,6 +231,7 @@ fn transitive_requires_package_does_not_exist() -> Result<()> {
.arg("--cache-dir") .arg("--cache-dir")
.arg(cache_dir.path()) .arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str()) .env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###" .current_dir(&temp_dir), @r###"
success: false success: false
exit_code: 2 exit_code: 2
@ -287,6 +280,7 @@ fn requires_direct_incompatible_versions() -> Result<()> {
.arg("--cache-dir") .arg("--cache-dir")
.arg(cache_dir.path()) .arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str()) .env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###" .current_dir(&temp_dir), @r###"
success: false success: false
exit_code: 1 exit_code: 1
@ -294,10 +288,7 @@ fn requires_direct_incompatible_versions() -> Result<()> {
----- stderr ----- ----- stderr -----
× No solution found when resolving dependencies: × No solution found when resolving dependencies:
root dependencies are unusable: Conflicting versions root dependencies are unusable: Conflicting versions for `a`: `a==1.0.0` does not intersect with `a==2.0.0`
for `a`:
`a==1.0.0` does not
intersect with `a==2.0.0`
"###); "###);
}); });
@ -346,6 +337,7 @@ fn requires_transitive_incompatible_with_root_version() -> Result<()> {
.arg("--cache-dir") .arg("--cache-dir")
.arg(cache_dir.path()) .arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str()) .env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###" .current_dir(&temp_dir), @r###"
success: false success: false
exit_code: 1 exit_code: 1
@ -353,20 +345,8 @@ fn requires_transitive_incompatible_with_root_version() -> Result<()> {
----- stderr ----- ----- stderr -----
× No solution found when resolving dependencies: × No solution found when resolving dependencies:
Because Because a==1.0.0 depends on b==2.0.0 and there is no version of a available matching <1.0.0 | >1.0.0, a depends on b==2.0.0.
a==1.0.0 And because root depends on b==1.0.0 and root depends on a, version solving failed.
depends on
b==2.0.0
and there is no version of
a
available matching <1.0.0 | >1.0.0,
a depends on
b==2.0.0.
And because root depends on
b==1.0.0
and root depends on
a, version
solving failed.
"###); "###);
}); });
@ -419,6 +399,7 @@ fn requires_transitive_incompatible_with_transitive() -> Result<()> {
.arg("--cache-dir") .arg("--cache-dir")
.arg(cache_dir.path()) .arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str()) .env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###" .current_dir(&temp_dir), @r###"
success: false success: false
exit_code: 1 exit_code: 1
@ -426,28 +407,9 @@ fn requires_transitive_incompatible_with_transitive() -> Result<()> {
----- stderr ----- ----- stderr -----
× No solution found when resolving dependencies: × No solution found when resolving dependencies:
Because there is no version of Because there is no version of a available matching <1.0.0 | >1.0.0 and a==1.0.0 depends on c==1.0.0, a depends on c==1.0.0.
a And because b==1.0.0 depends on c==2.0.0 and there is no version of b available matching <1.0.0 | >1.0.0, a *, b * are incompatible.
available matching <1.0.0 | >1.0.0 and And because root depends on a and root depends on b, version solving failed.
a==1.0.0
depends on
c==1.0.0,
a depends on
c==1.0.0.
And because
b==1.0.0
depends on
c==2.0.0
and there is no version of
b
available matching <1.0.0 | >1.0.0,
a *,
b * are
incompatible.
And because root depends on
a and root
depends on b,
version solving failed.
"###); "###);
}); });

View File

@ -49,6 +49,7 @@ fn {{normalized_name}}() -> Result<()> {
.arg("--cache-dir") .arg("--cache-dir")
.arg(cache_dir.path()) .arg(cache_dir.path())
.env("VIRTUAL_ENV", venv.as_os_str()) .env("VIRTUAL_ENV", venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.current_dir(&temp_dir), @r###"<snapshot> .current_dir(&temp_dir), @r###"<snapshot>
"###); "###);
}); });