Skip to content

Commit

Permalink
wip: add sorting test
Browse files Browse the repository at this point in the history
  • Loading branch information
lucab committed Sep 27, 2024
1 parent 78b2b96 commit f8cb188
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/uv-normalize/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,13 @@ mod tests {
assert!(is_normalized(input).is_err());
}
}

#[test]
fn sorting() {
let first = validate_and_normalize_ref("ansible").unwrap();
let second = validate_and_normalize_ref("ansible-core").unwrap();
assert_eq!(first, "ansible");
assert_eq!(second, "ansible-core");
assert!(first < second);
}
}
34 changes: 34 additions & 0 deletions crates/uv/src/commands/tool/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub(crate) fn remove_entrypoints(tool: &Tool) {
}

/// Installs tool executables for a given package and handles any conflicts.
#[allow(clippy::cmp_owned)]
pub(crate) fn install_executables(
environment: &PythonEnvironment,
tool_name: &PackageName,
Expand Down Expand Up @@ -92,6 +93,10 @@ pub(crate) fn install_executables(
installed_dist.version(),
)?;

// XXX
let _temp = entry_points.clone();
// XXX

// Determine the entry points targets. Use a sorted collection for deterministic output.
let target_entry_points = entry_points
.into_iter()
Expand All @@ -106,6 +111,35 @@ pub(crate) fn install_executables(
})
.collect::<BTreeSet<_>>();

// XXX
#[cfg(windows)]
{
assert!("ansible".to_string() < "ansible-config".to_string());
let mut test = BTreeSet::new();
test.insert("ansible".to_string());
test.insert("ansible-config".to_string());
if name == &PackageName::new("ansible-core".to_string()).unwrap() {
dbg!(&target_entry_points);
let sorted: BTreeSet<_> = _temp.clone().into_iter().collect();
dbg!(&sorted);
let sorted2: BTreeSet<_> = _temp.into_iter().map(|(name, _)| name).collect();
dbg!(&sorted2);
let mut newset = BTreeSet::new();
let mut newset2 = BTreeSet::new();
for entry in sorted2.clone() {
if entry == "ansible" || entry == "ansible-config" {
newset2.insert(entry.clone());
}
newset.insert(entry);
}
dbg!(&newset);
assert_eq!(newset, sorted2);
dbg!(&newset2);
dbg!(&test);
}
}
// XXX

if target_entry_points.is_empty() {
writeln!(
printer.stdout(),
Expand Down

0 comments on commit f8cb188

Please sign in to comment.