From 16aaaf796d180ef2a8bc1d803ae2912d79807c4b Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 17 Dec 2024 20:16:36 +0100 Subject: [PATCH] update most tests --- .../rattler_conda_types/src/match_spec/mod.rs | 10 +++--- .../src/match_spec/parse.rs | 2 +- ...parse__tests__test_from_string_Strict.snap | 33 +++---------------- ...sts__test_nameless_from_string_Strict.snap | 9 +++-- ...atch_spec__tests__serialize_matchspec.snap | 6 ++-- .../src/version_spec/constraint.rs | 2 +- .../src/version_spec/mod.rs | 17 +++++++--- .../src/version_spec/parse.rs | 4 +-- 8 files changed, 33 insertions(+), 50 deletions(-) diff --git a/crates/rattler_conda_types/src/match_spec/mod.rs b/crates/rattler_conda_types/src/match_spec/mod.rs index c50b9d8be..29abca62d 100644 --- a/crates/rattler_conda_types/src/match_spec/mod.rs +++ b/crates/rattler_conda_types/src/match_spec/mod.rs @@ -702,12 +702,12 @@ mod tests { #[test] fn test_serialize_matchspec() { - let specs = ["mamba 1.0 py37_0", - "conda-forge::pytest[version=1.0, sha256=aaac4bc9c6916ecc0e33137431645b029ade22190c7144eead61446dcbcc6f97, md5=dede6252c964db3f3e41c7d30d07f6bf]", + let specs = ["mamba 1.0.* py37_0", + "conda-forge::pytest[version='==1.0', sha256=aaac4bc9c6916ecc0e33137431645b029ade22190c7144eead61446dcbcc6f97, md5=dede6252c964db3f3e41c7d30d07f6bf]", "conda-forge/linux-64::pytest", - "conda-forge/linux-64::pytest[version=1.0]", - "conda-forge/linux-64::pytest[version=1.0, build=py37_0]", - "conda-forge/linux-64::pytest 1.2.3"]; + "conda-forge/linux-64::pytest[version=1.0.*]", + "conda-forge/linux-64::pytest[version=1.0.*, build=py37_0]", + "conda-forge/linux-64::pytest ==1.2.3"]; assert_snapshot!(specs .into_iter() diff --git a/crates/rattler_conda_types/src/match_spec/parse.rs b/crates/rattler_conda_types/src/match_spec/parse.rs index 007d86308..3b00c4822 100644 --- a/crates/rattler_conda_types/src/match_spec/parse.rs +++ b/crates/rattler_conda_types/src/match_spec/parse.rs @@ -804,7 +804,7 @@ mod tests { fn test_nameless_match_spec() { insta::assert_yaml_snapshot!([ NamelessMatchSpec::from_str("3.8.* *_cpython", Strict).unwrap(), - NamelessMatchSpec::from_str("1.0 py27_0[fn=\"bla\"]", Strict).unwrap(), + NamelessMatchSpec::from_str("1.0.* py27_0[fn=\"bla\"]", Strict).unwrap(), NamelessMatchSpec::from_str("=1.0 py27_0", Strict).unwrap(), NamelessMatchSpec::from_str("*cpu*", Strict).unwrap(), NamelessMatchSpec::from_str("conda-forge::foobar", Strict).unwrap(), diff --git a/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__parse__tests__test_from_string_Strict.snap b/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__parse__tests__test_from_string_Strict.snap index 05ea333c6..adf8218be 100644 --- a/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__parse__tests__test_from_string_Strict.snap +++ b/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__parse__tests__test_from_string_Strict.snap @@ -54,32 +54,13 @@ python=3.9: python=*: error: "invalid version constraint: '*' is incompatible with '=' operator'" "https://software.repos.intel.com/python/conda::python[version=3.9]": - name: python - version: "==3.9" - channel: - base_url: "https://software.repos.intel.com/python/conda" - name: python/conda + error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?" "https://c.com/p/conda/linux-64::python[version=3.9]": - name: python - version: "==3.9" - channel: - base_url: "https://c.com/p/conda" - name: p/conda - subdir: linux-64 + error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?" "https://c.com/p/conda::python[version=3.9, subdir=linux-64]": - name: python - version: "==3.9" - channel: - base_url: "https://c.com/p/conda" - name: p/conda - subdir: linux-64 + error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?" "conda-forge/linux-32::python[version=3.9, subdir=linux-64]": - name: python - version: "==3.9" - channel: - base_url: "https://conda.anaconda.org/conda-forge" - name: conda-forge - subdir: linux-64 + error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?" "conda-forge/linux-32::python ==3.9[subdir=linux-64, build_number=\"0\"]": name: python version: "==3.9" @@ -119,11 +100,7 @@ rust ~=1.2.3: base_url: "file:///relative/channel" name: "./relative/channel" "python[channel=https://conda.anaconda.org/python/conda,version=3.9]": - name: python - version: "==3.9" - channel: - base_url: "https://conda.anaconda.org/python/conda" - name: python/conda + error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?" "channel/win-64::foobar[channel=conda-forge, subdir=linux-64]": name: foobar channel: diff --git a/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__parse__tests__test_nameless_from_string_Strict.snap b/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__parse__tests__test_nameless_from_string_Strict.snap index fd56844ab..9028486fd 100644 --- a/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__parse__tests__test_nameless_from_string_Strict.snap +++ b/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__parse__tests__test_nameless_from_string_Strict.snap @@ -3,7 +3,7 @@ source: crates/rattler_conda_types/src/match_spec/parse.rs expression: evaluated --- 2.7|>=3.6: - version: "==2.7|>=3.6" + error: "invalid version constraint: ambiguous. Do you mean ==2.7 or 2.7.*?" "https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2": url: "https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2" ~=1.2.3: @@ -40,14 +40,13 @@ expression: evaluated "==2.7.*.*|>=3.6": error: "invalid version constraint: regex constraints are not supported" "3.9": - version: "==3.9" + error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?" "*": version: "*" "[version=3.9]": - version: "==3.9" + error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?" "[version=3.9, subdir=linux-64]": - version: "==3.9" - subdir: linux-64 + error: "invalid version constraint: ambiguous. Do you mean ==3.9 or 3.9.*?" "==3.9[subdir=linux-64, build_number=\"0\"]": version: "==3.9" build_number: diff --git a/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__tests__serialize_matchspec.snap b/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__tests__serialize_matchspec.snap index b070cbff7..0f18d37ed 100644 --- a/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__tests__serialize_matchspec.snap +++ b/crates/rattler_conda_types/src/match_spec/snapshots/rattler_conda_types__match_spec__tests__serialize_matchspec.snap @@ -2,9 +2,9 @@ source: crates/rattler_conda_types/src/match_spec/mod.rs expression: "specs.into_iter().map(|s|\nMatchSpec::from_str(s,\nStrict).unwrap()).map(|s| s.to_string()).collect::>().join(\"\\n\")" --- -mamba ==1.0 py37_0 +mamba 1.0.* py37_0 conda-forge::pytest ==1.0[md5="dede6252c964db3f3e41c7d30d07f6bf", sha256="aaac4bc9c6916ecc0e33137431645b029ade22190c7144eead61446dcbcc6f97"] conda-forge/linux-64::pytest -conda-forge/linux-64::pytest ==1.0 -conda-forge/linux-64::pytest ==1.0 py37_0 +conda-forge/linux-64::pytest 1.0.* +conda-forge/linux-64::pytest 1.0.* py37_0 conda-forge/linux-64::pytest ==1.2.3 diff --git a/crates/rattler_conda_types/src/version_spec/constraint.rs b/crates/rattler_conda_types/src/version_spec/constraint.rs index 56154dc4b..bf6870bcb 100644 --- a/crates/rattler_conda_types/src/version_spec/constraint.rs +++ b/crates/rattler_conda_types/src/version_spec/constraint.rs @@ -279,7 +279,7 @@ mod test { #[rstest] fn test_exact(#[values(Lenient, Strict)] strictness: ParseStrictness) { assert_eq!( - Constraint::from_str("1.2.3", strictness), + Constraint::from_str("==1.2.3", strictness), Ok(Constraint::Exact( EqualityOperator::Equals, Version::from_str("1.2.3").unwrap(), diff --git a/crates/rattler_conda_types/src/version_spec/mod.rs b/crates/rattler_conda_types/src/version_spec/mod.rs index ea974ffbd..ba70b846c 100644 --- a/crates/rattler_conda_types/src/version_spec/mod.rs +++ b/crates/rattler_conda_types/src/version_spec/mod.rs @@ -350,15 +350,15 @@ mod tests { use crate::{ version_spec::{ parse::ParseConstraintError, EqualityOperator, LogicalOperator, ParseVersionSpecError, - RangeOperator, + RangeOperator, StrictRangeOperator, }, - ParseStrictness, Version, VersionSpec, + ParseStrictness, StrictVersion, Version, VersionSpec, }; #[test] fn test_simple() { assert_eq!( - VersionSpec::from_str("1.2.3", ParseStrictness::Strict), + VersionSpec::from_str("==1.2.3", ParseStrictness::Strict), Ok(VersionSpec::Exact( EqualityOperator::Equals, Version::from_str("1.2.3").unwrap(), @@ -371,6 +371,13 @@ mod tests { Version::from_str("1.2.3").unwrap(), )) ); + assert_eq!( + VersionSpec::from_str("=1.2.3", ParseStrictness::Strict), + Ok(VersionSpec::StrictRange( + StrictRangeOperator::StartsWith, + StrictVersion::from_str("1.2.3").unwrap(), + )) + ); } #[test] @@ -422,14 +429,14 @@ mod tests { let vs1 = VersionSpec::from_str(">=1.2.3,<2.0.0", ParseStrictness::Strict).unwrap(); assert!(!vs1.matches(&v1)); - let vs2 = VersionSpec::from_str("1.2", ParseStrictness::Strict).unwrap(); + let vs2 = VersionSpec::from_str("==1.2.0", ParseStrictness::Strict).unwrap(); assert!(vs2.matches(&v1)); let v2 = Version::from_str("1.2.3").unwrap(); assert!(vs1.matches(&v2)); assert!(!vs2.matches(&v2)); - let v3 = Version::from_str("1!1.2.3").unwrap(); + let v3 = Version::from_str("1!1.2.3.*").unwrap(); println!("{v3:?}"); assert!(!vs1.matches(&v3)); diff --git a/crates/rattler_conda_types/src/version_spec/parse.rs b/crates/rattler_conda_types/src/version_spec/parse.rs index 96ed27eaa..b3fb66bb5 100644 --- a/crates/rattler_conda_types/src/version_spec/parse.rs +++ b/crates/rattler_conda_types/src/version_spec/parse.rs @@ -411,7 +411,7 @@ mod test { #[rstest] fn parse_logical_constraint(#[values(Lenient, Strict)] strictness: ParseStrictness) { assert_eq!( - logical_constraint_parser(strictness)("3.1"), + logical_constraint_parser(strictness)("==3.1"), Ok(( "", Constraint::Exact(EqualityOperator::Equals, Version::from_str("3.1").unwrap()) @@ -520,7 +520,7 @@ mod test { #[test] fn pixi_issue_278() { - assert!(VersionSpec::from_str("1.8.1+g6b29558", Strict).is_ok()); + assert!(VersionSpec::from_str("=1.8.1+g6b29558", Strict).is_ok()); } #[test]