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 efcfd3e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ jobs:
- name: "Cargo test"
working-directory: ${{ env.UV_WORKSPACE }}
run: |
cargo nextest run --no-default-features --features python,pypi --workspace --status-level skip --failure-output immediate-final --no-fail-fast -j 20 --final-status-level slow
cargo nextest run --no-default-features --features python,pypi --workspace --status-level skip --failure-output immediate-final --no-fail-fast -j 20 --final-status-level slow tool_install_additional_entrypoints
- name: "Smoke test"
working-directory: ${{ env.UV_WORKSPACE }}
Expand Down
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);
}
}
38 changes: 38 additions & 0 deletions crates/uv/src/commands/tool/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{collections::BTreeSet, ffi::OsString};
use anyhow::{bail, Context};
use itertools::Itertools;
use owo_colors::OwoColorize;
use predicates::str;
use tracing::{debug, warn};

use distribution_types::{InstalledDist, Name};
Expand Down Expand Up @@ -62,6 +63,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 +94,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 +112,38 @@ 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();
let mut strbytes = vec![];
for entry in sorted2.clone() {
if entry == "ansible" || entry == "ansible-config" {
newset2.insert(entry.clone());
}
newset.insert(entry.clone());
strbytes.push(entry.into_bytes());
}
dbg!(&newset);
assert_eq!(newset, sorted2);
dbg!(&newset2);
dbg!(&test);
dbg!(&strbytes);
}
}
// XXX

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

0 comments on commit efcfd3e

Please sign in to comment.