Skip to content

Commit d658378

Browse files
Fix clippy warnings (#253)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
1 parent d3a1a5d commit d658378

File tree

19 files changed

+105
-95
lines changed

19 files changed

+105
-95
lines changed

crates/pet-conda/tests/ci_test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
3+
#![cfg(unix)]
34

45
use serde::Deserialize;
56
use std::path::PathBuf;
@@ -387,7 +388,7 @@ fn create_conda_env(mode: &CondaCreateEnvNameOrPath, python_version: Option<Stri
387388
.expect("Failed to execute command");
388389
}
389390

390-
fn get_version(value: &String) -> String {
391+
fn get_version(value: &str) -> String {
391392
// Regex to extract just the d.d.d version from the full version string
392393
let re = regex::Regex::new(r"\d+\.\d+\.\d+").unwrap();
393394
let captures = re.captures(value).unwrap();

crates/pet-conda/tests/common.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,29 @@ pub struct TestEnvironment {
4646
root: Option<PathBuf>,
4747
globals_locations: Vec<PathBuf>,
4848
}
49+
50+
impl Environment for TestEnvironment {
51+
fn get_env_var(&self, key: String) -> Option<String> {
52+
self.vars.get(&key).cloned()
53+
}
54+
fn get_root(&self) -> Option<PathBuf> {
55+
self.root.clone()
56+
}
57+
fn get_user_home(&self) -> Option<PathBuf> {
58+
self.home.clone()
59+
}
60+
fn get_know_global_search_locations(&self) -> Vec<PathBuf> {
61+
self.globals_locations.clone()
62+
}
63+
}
64+
4965
#[allow(dead_code)]
5066
pub fn create_test_environment(
5167
vars: HashMap<String, String>,
5268
home: Option<PathBuf>,
5369
globals_locations: Vec<PathBuf>,
5470
root: Option<PathBuf>,
5571
) -> TestEnvironment {
56-
impl Environment for TestEnvironment {
57-
fn get_env_var(&self, key: String) -> Option<String> {
58-
self.vars.get(&key).cloned()
59-
}
60-
fn get_root(&self) -> Option<PathBuf> {
61-
self.root.clone()
62-
}
63-
fn get_user_home(&self) -> Option<PathBuf> {
64-
self.home.clone()
65-
}
66-
fn get_know_global_search_locations(&self) -> Vec<PathBuf> {
67-
self.globals_locations.clone()
68-
}
69-
}
7072
TestEnvironment {
7173
vars,
7274
home,

crates/pet-conda/tests/environments_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
3+
#![cfg(unix)]
34

45
mod common;
56
use common::resolve_test_path;

crates/pet-conda/tests/package_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
3+
#![cfg(unix)]
34

45
mod common;
56
use pet_conda::package::{self, CondaPackageInfo};

crates/pet-conda/tests/utils_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
3+
#![cfg(unix)]
34

45
mod common;
56
use common::resolve_test_path;

crates/pet-core/src/python_environment.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,10 @@ pub fn get_environment_key(env: &PythonEnvironment) -> Option<PathBuf> {
416416

417417
#[cfg(test)]
418418
mod tests {
419-
use super::*;
419+
#[cfg(windows)]
420+
use super::{get_shortest_executable, PythonEnvironmentKind};
421+
#[cfg(windows)]
422+
use std::path::PathBuf;
420423

421424
#[test]
422425
#[cfg(windows)]

crates/pet-homebrew/src/environments.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,11 @@ fn get_prefix(_resolved_file: &Path) -> Option<PathBuf> {
147147
None
148148
}
149149

150-
#[cfg(test)]
150+
#[cfg(all(test, unix))]
151151
mod tests {
152152
use super::*;
153153

154154
#[test]
155-
#[cfg(unix)]
156155
fn extract_version() {
157156
assert_eq!(
158157
get_version(&PathBuf::from(

crates/pet-poetry/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ regex = "1.10.4"
2121
sha2 = "0.10.6"
2222
base64 = "0.22.0"
2323
toml = "0.8.14"
24+
25+
[features]
26+
ci = []

crates/pet-poetry/tests/common.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,27 @@ pub struct TestEnvironment {
3535
home: Option<PathBuf>,
3636
root: Option<PathBuf>,
3737
}
38+
39+
impl Environment for TestEnvironment {
40+
fn get_env_var(&self, key: String) -> Option<String> {
41+
self.vars.get(&key).cloned()
42+
}
43+
fn get_root(&self) -> Option<PathBuf> {
44+
self.root.clone()
45+
}
46+
fn get_user_home(&self) -> Option<PathBuf> {
47+
self.home.clone()
48+
}
49+
fn get_know_global_search_locations(&self) -> Vec<PathBuf> {
50+
vec![]
51+
}
52+
}
53+
3854
#[allow(dead_code)]
3955
pub fn create_test_environment(
4056
vars: HashMap<String, String>,
4157
home: Option<PathBuf>,
4258
root: Option<PathBuf>,
4359
) -> TestEnvironment {
44-
impl Environment for TestEnvironment {
45-
fn get_env_var(&self, key: String) -> Option<String> {
46-
self.vars.get(&key).cloned()
47-
}
48-
fn get_root(&self) -> Option<PathBuf> {
49-
self.root.clone()
50-
}
51-
fn get_user_home(&self) -> Option<PathBuf> {
52-
self.home.clone()
53-
}
54-
fn get_know_global_search_locations(&self) -> Vec<PathBuf> {
55-
vec![]
56-
}
57-
}
5860
TestEnvironment { vars, home, root }
5961
}

crates/pet-poetry/tests/config_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ fn global_config_with_specific_values() {
8383
#[cfg(unix)]
8484
#[cfg_attr(any(feature = "ci",), test)]
8585
#[allow(dead_code)]
86-
8786
fn local_config_with_specific_values() {
8887
use std::path::PathBuf;
8988

0 commit comments

Comments
 (0)