Unpack scenario root requirements in test cases (#757)

As mentioned in #746, instead of just installing the scenario root we
will unpack the root dependencies into the install command to allow
better coverage of direct user requests with scenarios.

I added display of the package tree provided by each scenario.

Use a mustache template for iterative replacements.
This commit is contained in:
Zanie Blue 2024-01-03 17:31:29 -06:00 committed by GitHub
parent 02b157085e
commit 1f2112191f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 196 additions and 117 deletions

View file

@ -1,4 +1,5 @@
#![cfg(all(feature = "python", feature = "pypi"))]
/// Generated by `scripts/scenarios/generate.py`
use std::process::Command;
@ -13,6 +14,11 @@ mod common;
/// requires-package-does-not-exist
///
/// The user requires any version of package `a` which does not exist.
///
/// requires-package-does-not-exist-59108293
/// └── root
/// └── requires a
/// └── unsatisfied: no versions for package
#[test]
fn requires_package_does_not_exist() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
@ -24,7 +30,7 @@ fn requires_package_does_not_exist() -> Result<()> {
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip-install")
.arg("requires-package-does-not-exist-59108293")
.arg("requires-package-does-not-exist-59108293-a")
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
@ -46,6 +52,13 @@ fn requires_package_does_not_exist() -> Result<()> {
/// requires-exact-version-does-not-exist
///
/// The user requires an exact version of package `a` but only other versions exist
///
/// requires-exact-version-does-not-exist-bc5f5f6d
/// ├── root
/// │ └── requires a==2.0.0
/// │ └── unsatisfied: no matching version
/// └── a
/// └── a-1.0.0
#[test]
fn requires_exact_version_does_not_exist() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
@ -57,7 +70,7 @@ fn requires_exact_version_does_not_exist() -> Result<()> {
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip-install")
.arg("requires-exact-version-does-not-exist-bc5f5f6d")
.arg("requires-exact-version-does-not-exist-bc5f5f6d-a==2.0.0")
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
@ -71,14 +84,10 @@ fn requires_exact_version_does_not_exist() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
Because there is no version of
requires-exact-version-does-not-exist-bc5f5f6d-a available matching
==2.0.0 and requires-exact-version-does-not-exist-bc5f5f6d==0.0.0
depends on requires-exact-version-does-not-exist-bc5f5f6d-a==2.0.0,
requires-exact-version-does-not-exist-bc5f5f6d==0.0.0 is forbidden.
And because there is no version of
requires-exact-version-does-not-exist-bc5f5f6d
available matching <0.0.0 | >0.0.0 and root depends on
requires-exact-version-does-not-exist-bc5f5f6d, version solving failed.
requires-exact-version-does-not-exist-bc5f5f6d-a
available matching ==2.0.0 and root depends on
requires-exact-version-does-not-exist-bc5f5f6d-a==2.0.0, version solving
failed.
"###);
});
@ -88,6 +97,14 @@ fn requires_exact_version_does_not_exist() -> Result<()> {
/// requires-greater-version-does-not-exist
///
/// The user requires a version of `a` greater than `1.0.0` but only smaller or equal versions exist
///
/// requires-greater-version-does-not-exist-670431f9
/// ├── root
/// │ └── requires a>1.0.0
/// │ └── unsatisfied: no matching version
/// └── a
/// ├── a-0.1.0
/// └── a-1.0.0
#[test]
fn requires_greater_version_does_not_exist() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
@ -99,7 +116,7 @@ fn requires_greater_version_does_not_exist() -> Result<()> {
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip-install")
.arg("requires-greater-version-does-not-exist-670431f9")
.arg("requires-greater-version-does-not-exist-670431f9-a>1.0.0")
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
@ -113,15 +130,10 @@ fn requires_greater_version_does_not_exist() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
Because there is no version of
requires-greater-version-does-not-exist-670431f9-a available matching
>1.0.0 and requires-greater-version-does-not-exist-670431f9==0.0.0
depends on requires-greater-version-does-not-exist-670431f9-a>1.0.0,
requires-greater-version-does-not-exist-670431f9==0.0.0 is forbidden.
And because there is no version of
requires-greater-version-does-not-exist-670431f9
available matching <0.0.0 | >0.0.0 and root depends on
requires-greater-version-does-not-exist-670431f9, version solving
failed.
requires-greater-version-does-not-exist-670431f9-a
available matching >1.0.0 and root depends on
requires-greater-version-does-not-exist-670431f9-a>1.0.0, version
solving failed.
"###);
});
@ -131,6 +143,15 @@ fn requires_greater_version_does_not_exist() -> Result<()> {
/// requires-less-version-does-not-exist
///
/// The user requires a version of `a` less than `1.0.0` but only larger versions exist
///
/// requires-less-version-does-not-exist-9a75991b
/// ├── root
/// │ └── requires a<2.0.0
/// │ └── unsatisfied: no matching version
/// └── a
/// ├── a-2.0.0
/// ├── a-3.0.0
/// └── a-4.0.0
#[test]
fn requires_less_version_does_not_exist() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
@ -142,7 +163,7 @@ fn requires_less_version_does_not_exist() -> Result<()> {
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip-install")
.arg("requires-less-version-does-not-exist-9a75991b")
.arg("requires-less-version-does-not-exist-9a75991b-a<2.0.0")
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
@ -156,14 +177,10 @@ fn requires_less_version_does_not_exist() -> Result<()> {
----- stderr -----
× No solution found when resolving dependencies:
Because there is no version of
requires-less-version-does-not-exist-9a75991b-a available matching
<2.0.0 and requires-less-version-does-not-exist-9a75991b==0.0.0
depends on requires-less-version-does-not-exist-9a75991b-a<2.0.0,
requires-less-version-does-not-exist-9a75991b==0.0.0 is forbidden.
And because there is no version of
requires-less-version-does-not-exist-9a75991b
available matching <0.0.0 | >0.0.0 and root depends on
requires-less-version-does-not-exist-9a75991b, version solving failed.
requires-less-version-does-not-exist-9a75991b-a
available matching <2.0.0 and root depends on
requires-less-version-does-not-exist-9a75991b-a<2.0.0, version solving
failed.
"###);
});
@ -173,6 +190,15 @@ fn requires_less_version_does_not_exist() -> Result<()> {
/// transitive-requires-package-does-not-exist
///
/// The user requires package `a` but `a` requires package `b` which does not exist
///
/// transitive-requires-package-does-not-exist-ca79eaa2
/// ├── root
/// │ └── requires a
/// │ └── satisfied by a-1.0.0
/// └── a
/// └── a-1.0.0
/// └── requires b
/// └── unsatisfied: no versions for package
#[test]
fn transitive_requires_package_does_not_exist() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
@ -184,7 +210,7 @@ fn transitive_requires_package_does_not_exist() -> Result<()> {
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip-install")
.arg("transitive-requires-package-does-not-exist-ca79eaa2")
.arg("transitive-requires-package-does-not-exist-ca79eaa2-a")
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
@ -206,6 +232,16 @@ fn transitive_requires_package_does_not_exist() -> Result<()> {
/// requires-direct-incompatible-versions
///
/// The user requires two incompatible, existing versions of package `a`
///
/// requires-direct-incompatible-versions-350bd4b0
/// ├── root
/// │ ├── requires a==1.0.0
/// │ │ └── satisfied by a-1.0.0
/// │ └── requires a==2.0.0
/// │ └── satisfied by a-2.0.0
/// └── a
/// ├── a-1.0.0
/// └── a-2.0.0
#[test]
fn requires_direct_incompatible_versions() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
@ -217,7 +253,8 @@ fn requires_direct_incompatible_versions() -> Result<()> {
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip-install")
.arg("requires-direct-incompatible-versions-350bd4b0")
.arg("requires-direct-incompatible-versions-350bd4b0-a==1.0.0")
.arg("requires-direct-incompatible-versions-350bd4b0-a==2.0.0")
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
@ -225,11 +262,15 @@ fn requires_direct_incompatible_versions() -> Result<()> {
.env("VIRTUAL_ENV", venv.as_os_str())
.current_dir(&temp_dir), @r###"
success: false
exit_code: 2
exit_code: 1
----- stdout -----
----- stderr -----
error: Conflicting versions for `requires-direct-incompatible-versions-350bd4b0-a`: `requires-direct-incompatible-versions-350bd4b0-a==1.0.0` does not intersect with `requires-direct-incompatible-versions-350bd4b0-a==2.0.0`
× No solution found when resolving dependencies:
root dependencies are unusable: Conflicting versions
for `requires-direct-incompatible-versions-350bd4b0-a`:
`requires-direct-incompatible-versions-350bd4b0-a==1.0.0` does not
intersect with `requires-direct-incompatible-versions-350bd4b0-a==2.0.0`
"###);
});
@ -239,6 +280,20 @@ fn requires_direct_incompatible_versions() -> Result<()> {
/// requires-transitive-incompatible-with-root-version
///
/// The user requires packages `a` and `b` but `a` requires a different version of `b`
///
/// requires-transitive-incompatible-with-root-version-3240dab1
/// ├── root
/// │ ├── requires a
/// │ │ └── satisfied by a-1.0.0
/// │ └── requires b==1.0.0
/// │ └── satisfied by b-1.0.0
/// ├── a
/// │ └── a-1.0.0
/// │ └── requires b==2.0.0
/// │ └── satisfied by b-2.0.0
/// └── b
/// ├── b-1.0.0
/// └── b-2.0.0
#[test]
fn requires_transitive_incompatible_with_root_version() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
@ -250,7 +305,8 @@ fn requires_transitive_incompatible_with_root_version() -> Result<()> {
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip-install")
.arg("requires-transitive-incompatible-with-root-version-3240dab1")
.arg("requires-transitive-incompatible-with-root-version-3240dab1-a")
.arg("requires-transitive-incompatible-with-root-version-3240dab1-b==1.0.0")
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
@ -272,18 +328,10 @@ fn requires_transitive_incompatible_with_root_version() -> Result<()> {
available matching <1.0.0 | >1.0.0,
requires-transitive-incompatible-with-root-version-3240dab1-a depends on
requires-transitive-incompatible-with-root-version-3240dab1-b==2.0.0.
And because
requires-transitive-incompatible-with-root-version-3240dab1==0.0.0
depends on
And because root depends on
requires-transitive-incompatible-with-root-version-3240dab1-b==1.0.0
and requires-transitive-incompatible-with-root-version-3240dab1==0.0.0
depends on requires-transitive-incompatible-with-root-version-3240dab1-a,
requires-transitive-incompatible-with-root-version-3240dab1==0.0.0 is
forbidden.
And because there is no version of
requires-transitive-incompatible-with-root-version-3240dab1
available matching <0.0.0 | >0.0.0 and root depends on
requires-transitive-incompatible-with-root-version-3240dab1, version
and root depends on
requires-transitive-incompatible-with-root-version-3240dab1-a, version
solving failed.
"###);
});
@ -294,6 +342,24 @@ fn requires_transitive_incompatible_with_root_version() -> Result<()> {
/// requires-transitive-incompatible-with-transitive
///
/// The user requires package `a` and `b`; `a` and `b` require different versions of `c`
///
/// requires-transitive-incompatible-with-transitive-8329cfc0
/// ├── root
/// │ ├── requires a
/// │ │ └── satisfied by a-1.0.0
/// │ └── requires b
/// │ └── satisfied by b-1.0.0
/// ├── a
/// │ └── a-1.0.0
/// │ └── requires c==1.0.0
/// │ └── satisfied by c-1.0.0
/// ├── b
/// │ └── b-1.0.0
/// │ └── requires c==2.0.0
/// │ └── satisfied by c-2.0.0
/// └── c
/// ├── c-1.0.0
/// └── c-2.0.0
#[test]
fn requires_transitive_incompatible_with_transitive() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
@ -305,7 +371,8 @@ fn requires_transitive_incompatible_with_transitive() -> Result<()> {
}, {
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
.arg("pip-install")
.arg("requires-transitive-incompatible-with-transitive-8329cfc0")
.arg("requires-transitive-incompatible-with-transitive-8329cfc0-a")
.arg("requires-transitive-incompatible-with-transitive-8329cfc0-b")
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
@ -336,18 +403,10 @@ fn requires_transitive_incompatible_with_transitive() -> Result<()> {
requires-transitive-incompatible-with-transitive-8329cfc0-a *,
requires-transitive-incompatible-with-transitive-8329cfc0-b * are
incompatible.
And because
requires-transitive-incompatible-with-transitive-8329cfc0==0.0.0
depends on requires-transitive-incompatible-with-transitive-8329cfc0-a
and requires-transitive-incompatible-with-transitive-8329cfc0==0.0.0
And because root depends on
requires-transitive-incompatible-with-transitive-8329cfc0-a and root
depends on requires-transitive-incompatible-with-transitive-8329cfc0-b,
requires-transitive-incompatible-with-transitive-8329cfc0==0.0.0 is
forbidden.
And because there is no version of
requires-transitive-incompatible-with-transitive-8329cfc0
available matching <0.0.0 | >0.0.0 and root depends on
requires-transitive-incompatible-with-transitive-8329cfc0, version
solving failed.
version solving failed.
"###);
});