mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Run the test suite on windows in CI (#1262)
Run `cargo test` on windows in CI, pulling the switch on tier 1 windows support. These changes make the bootstrap script virtually required for running the tests. This gives us consistency between and CI, but it also locks our tests to python-build-standalone and an articificial `PATH`. I've deleted the shell bootstrap script in favor of only the python one, which also runs on windows. I've left the (sym)link creation of the bootstrap in place, even though it is not used by the tests anymore. I've reactivated the three tests that would previously stack overflow by doubling their stack sizes. The stack overflows only happen in debug mode, so this is neither a user facing problem nor an actual problem with our code and this workaround seems better than optimizing our code for case that the (release) compiler can optimize much better for. The handling of patch versions will be fixed in a follow-up PR. Closes #1160 Closes #1161 --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
parent
96276d9e3e
commit
1dc9904f8c
12 changed files with 228 additions and 357 deletions
|
@ -137,7 +137,7 @@ impl Interpreter {
|
|||
/// - If a python version is given: `pythonx.y`
|
||||
/// - `python3` (unix) or `python.exe` (windows)
|
||||
///
|
||||
/// If `PUFFIN_PYTHON_PATH` is set, we will not check for Python versions in the
|
||||
/// If `PUFFIN_TEST_PYTHON_PATH` is set, we will not check for Python versions in the
|
||||
/// global PATH, instead we will search using the provided path. Virtual environments
|
||||
/// will still be respected.
|
||||
///
|
||||
|
@ -220,7 +220,7 @@ impl Interpreter {
|
|||
pub fn find_executable<R: AsRef<OsStr> + Into<OsString> + Copy>(
|
||||
requested: R,
|
||||
) -> Result<PathBuf, Error> {
|
||||
if let Some(isolated) = std::env::var_os("PUFFIN_PYTHON_PATH") {
|
||||
if let Some(isolated) = std::env::var_os("PUFFIN_TEST_PYTHON_PATH") {
|
||||
if let Ok(cwd) = std::env::current_dir() {
|
||||
which::which_in(requested, Some(isolated), cwd)
|
||||
.map_err(|err| Error::from_which_error(requested.into(), err))
|
||||
|
|
|
@ -38,20 +38,30 @@ pub fn find_requested_python(request: &str) -> Result<PathBuf, Error> {
|
|||
let formatted = PathBuf::from(format!("python{request}"));
|
||||
Interpreter::find_executable(&formatted)
|
||||
} else if cfg!(windows) {
|
||||
if let Some(python_overwrite) = env::var_os("PUFFIN_PYTHON_PATH") {
|
||||
for path in env::split_paths(&python_overwrite) {
|
||||
if path
|
||||
.as_os_str()
|
||||
.to_str()
|
||||
// Good enough since we control the bootstrap directory
|
||||
.is_some_and(|path| path.contains(&format!("@{request}")))
|
||||
{
|
||||
return Ok(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let [major, minor] = versions.as_slice() {
|
||||
if let Some(python_overwrite) = env::var_os("PUFFIN_TEST_PYTHON_PATH") {
|
||||
let executable_dir = env::split_paths(&python_overwrite).find(|path| {
|
||||
path.as_os_str()
|
||||
.to_str()
|
||||
// Good enough since we control the bootstrap directory
|
||||
.is_some_and(|path| path.contains(&format!("@{request}")))
|
||||
});
|
||||
return if let Some(path) = executable_dir {
|
||||
Ok(path.join(if cfg!(unix) {
|
||||
"python3"
|
||||
} else if cfg!(windows) {
|
||||
"python.exe"
|
||||
} else {
|
||||
unimplemented!("Only Windows and Unix are supported")
|
||||
}))
|
||||
} else {
|
||||
Err(Error::NoSuchPython {
|
||||
major: *major,
|
||||
minor: *minor,
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
find_python_windows(*major, *minor)?.ok_or(Error::NoSuchPython {
|
||||
major: *major,
|
||||
minor: *minor,
|
||||
|
@ -73,21 +83,27 @@ pub fn find_requested_python(request: &str) -> Result<PathBuf, Error> {
|
|||
|
||||
/// Pick a sensible default for the python a user wants when they didn't specify a version.
|
||||
///
|
||||
/// We prefer the test overwrite `PUFFIN_PYTHON_PATH` if it is set, otherwise `python3`/`python` or
|
||||
/// We prefer the test overwrite `PUFFIN_TEST_PYTHON_PATH` if it is set, otherwise `python3`/`python` or
|
||||
/// `python.exe` respectively.
|
||||
#[instrument]
|
||||
pub fn find_default_python() -> Result<PathBuf, Error> {
|
||||
let current_dir = env::current_dir()?;
|
||||
let python = if cfg!(unix) {
|
||||
which::which_in("python3", env::var_os("PUFFIN_PYTHON_PATH"), current_dir)
|
||||
.or_else(|_| which::which("python"))
|
||||
.map_err(|_| Error::NoPythonInstalledUnix)?
|
||||
which::which_in(
|
||||
"python3",
|
||||
env::var_os("PUFFIN_TEST_PYTHON_PATH"),
|
||||
current_dir,
|
||||
)
|
||||
.or_else(|_| which::which("python"))
|
||||
.map_err(|_| Error::NoPythonInstalledUnix)?
|
||||
} else if cfg!(windows) {
|
||||
// TODO(konstin): Is that the right order, or should we look for `py --list-paths` first? With the current way
|
||||
// it works even if the python launcher is not installed.
|
||||
if let Ok(python) =
|
||||
which::which_in("python.exe", env::var_os("PUFFIN_PYTHON_PATH"), current_dir)
|
||||
{
|
||||
if let Ok(python) = which::which_in(
|
||||
"python.exe",
|
||||
env::var_os("PUFFIN_TEST_PYTHON_PATH"),
|
||||
current_dir,
|
||||
) {
|
||||
python
|
||||
} else {
|
||||
installed_pythons_windows()?
|
||||
|
@ -107,7 +123,7 @@ pub fn find_default_python() -> Result<PathBuf, Error> {
|
|||
/// The command takes 8ms on my machine. TODO(konstin): Implement <https://peps.python.org/pep-0514/> to read python
|
||||
/// installations from the registry instead.
|
||||
fn installed_pythons_windows() -> Result<Vec<(u8, u8, PathBuf)>, Error> {
|
||||
// TODO(konstin): We're not checking PUFFIN_PYTHON_PATH here, no test currently depends on it.
|
||||
// TODO(konstin): We're not checking PUFFIN_TEST_PYTHON_PATH here, no test currently depends on it.
|
||||
|
||||
// TODO(konstin): Special case the not found error
|
||||
let output = info_span!("py_list_paths")
|
||||
|
@ -148,6 +164,24 @@ fn installed_pythons_windows() -> Result<Vec<(u8, u8, PathBuf)>, Error> {
|
|||
}
|
||||
|
||||
pub(crate) fn find_python_windows(major: u8, minor: u8) -> Result<Option<PathBuf>, Error> {
|
||||
if let Some(python_overwrite) = env::var_os("PUFFIN_TEST_PYTHON_PATH") {
|
||||
let executable_dir = env::split_paths(&python_overwrite).find(|path| {
|
||||
path.as_os_str()
|
||||
.to_str()
|
||||
// Good enough since we control the bootstrap directory
|
||||
.is_some_and(|path| path.contains(&format!("@{major}.{minor}")))
|
||||
});
|
||||
return Ok(executable_dir.map(|path| {
|
||||
path.join(if cfg!(unix) {
|
||||
"python3"
|
||||
} else if cfg!(windows) {
|
||||
"python.exe"
|
||||
} else {
|
||||
unimplemented!("Only Windows and Unix are supported")
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
Ok(installed_pythons_windows()?
|
||||
.into_iter()
|
||||
.find(|(major_, minor_, _path)| *major_ == major && *minor_ == minor)
|
||||
|
@ -170,23 +204,20 @@ mod tests {
|
|||
.join("\n Caused by: ")
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn python312() {
|
||||
assert_eq!(
|
||||
find_requested_python("3.12").unwrap(),
|
||||
find_requested_python("python3.12").unwrap()
|
||||
fn no_such_python_version() {
|
||||
assert_snapshot!(
|
||||
format_err(find_requested_python("3.1000")),
|
||||
@"Couldn't find `3.1000` in PATH. Is this Python version installed?"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_such_python_version() {
|
||||
assert_snapshot!(format_err(find_requested_python("3.1000")), @"Couldn't find `3.1000` in PATH. Is this Python version installed?");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_such_python_binary() {
|
||||
assert_display_snapshot!(format_err(find_requested_python("python3.1000")), @"Couldn't find `python3.1000` in PATH. Is this Python version installed?");
|
||||
assert_display_snapshot!(
|
||||
format_err(find_requested_python("python3.1000")),
|
||||
@"Couldn't find `python3.1000` in PATH. Is this Python version installed?"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// The `unreachable_pub` is to silence false positives in RustRover.
|
||||
#![allow(dead_code, unreachable_pub)]
|
||||
|
||||
use std::borrow::BorrowMut;
|
||||
use std::env;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Output;
|
||||
|
||||
|
@ -9,8 +11,14 @@ use assert_cmd::Command;
|
|||
use assert_fs::assert::PathAssert;
|
||||
use assert_fs::fixture::PathChild;
|
||||
use assert_fs::TempDir;
|
||||
#[cfg(unix)]
|
||||
use fs_err::os::unix::fs::symlink as symlink_file;
|
||||
#[cfg(windows)]
|
||||
use fs_err::os::windows::fs::symlink_file;
|
||||
use regex::Regex;
|
||||
|
||||
use puffin_interpreter::find_requested_python;
|
||||
|
||||
// Exclude any packages uploaded after this date.
|
||||
pub static EXCLUDE_NEWER: &str = "2023-11-18T12:00:00Z";
|
||||
|
||||
|
@ -173,16 +181,50 @@ pub fn get_bin() -> PathBuf {
|
|||
PathBuf::from(env!("CARGO_BIN_EXE_puffin"))
|
||||
}
|
||||
|
||||
/// Create a directory with the requested Python binaries available.
|
||||
pub fn create_bin_with_executables(
|
||||
temp_dir: &assert_fs::TempDir,
|
||||
python_versions: &[&str],
|
||||
) -> anyhow::Result<PathBuf> {
|
||||
if let Some(bootstrapped_pythons) = bootstrapped_pythons() {
|
||||
let selected_pythons = bootstrapped_pythons.into_iter().filter(|path| {
|
||||
python_versions.iter().any(|python_version| {
|
||||
// Good enough since we control the directory
|
||||
path.to_str()
|
||||
.unwrap()
|
||||
.contains(&format!("@{python_version}"))
|
||||
})
|
||||
});
|
||||
return Ok(env::join_paths(selected_pythons)?.into());
|
||||
}
|
||||
|
||||
let bin = temp_dir.child("bin");
|
||||
fs_err::create_dir(&bin)?;
|
||||
for request in python_versions {
|
||||
let executable = find_requested_python(request)?;
|
||||
let name = executable
|
||||
.file_name()
|
||||
.expect("Discovered executable must have a filename");
|
||||
symlink_file(&executable, bin.child(name))?;
|
||||
}
|
||||
Ok(bin.canonicalize()?)
|
||||
}
|
||||
|
||||
/// Execute the command and format its output status, stdout and stderr into a snapshot string.
|
||||
///
|
||||
/// This function is derived from `insta_cmd`s `spawn_with_info`.
|
||||
pub fn run_and_format<'a>(
|
||||
command: &mut std::process::Command,
|
||||
mut command: impl BorrowMut<std::process::Command>,
|
||||
filters: impl AsRef<[(&'a str, &'a str)]>,
|
||||
windows_filters: bool,
|
||||
) -> (String, Output) {
|
||||
let program = command.get_program().to_string_lossy().to_string();
|
||||
let program = command
|
||||
.borrow_mut()
|
||||
.get_program()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
let output = command
|
||||
.borrow_mut()
|
||||
.output()
|
||||
.unwrap_or_else(|_| panic!("Failed to spawn {program}"));
|
||||
|
||||
|
|
|
@ -6,52 +6,17 @@
|
|||
#![cfg(all(feature = "python", feature = "pypi"))]
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
use anyhow::Result;
|
||||
use assert_cmd::assert::OutputAssertExt;
|
||||
use assert_fs::fixture::{FileWriteStr, PathChild};
|
||||
#[cfg(unix)]
|
||||
use fs_err::os::unix::fs::symlink as symlink_file;
|
||||
#[cfg(windows)]
|
||||
use fs_err::os::windows::fs::symlink_file;
|
||||
use predicates::prelude::predicate;
|
||||
|
||||
use common::{bootstrapped_pythons, get_bin, puffin_snapshot, TestContext, INSTA_FILTERS};
|
||||
use puffin_interpreter::find_requested_python;
|
||||
use common::{create_bin_with_executables, get_bin, puffin_snapshot, TestContext, INSTA_FILTERS};
|
||||
|
||||
mod common;
|
||||
|
||||
/// Create a directory with the requested Python binaries available.
|
||||
pub(crate) fn create_bin_with_executables(
|
||||
temp_dir: &assert_fs::TempDir,
|
||||
python_versions: &[&str],
|
||||
) -> Result<PathBuf> {
|
||||
if let Some(bootstrapped_pythons) = bootstrapped_pythons() {
|
||||
let selected_pythons = bootstrapped_pythons.into_iter().filter(|path| {
|
||||
python_versions.iter().any(|python_version| {
|
||||
// Good enough since we control the directory
|
||||
path.to_str()
|
||||
.unwrap()
|
||||
.contains(&format!("@{python_version}"))
|
||||
})
|
||||
});
|
||||
return Ok(env::join_paths(selected_pythons)?.into());
|
||||
}
|
||||
|
||||
let bin = temp_dir.child("bin");
|
||||
fs_err::create_dir(&bin)?;
|
||||
for request in python_versions {
|
||||
let executable = find_requested_python(request)?;
|
||||
let name = executable
|
||||
.file_name()
|
||||
.expect("Discovered executable must have a filename");
|
||||
symlink_file(&executable, bin.child(name))?;
|
||||
}
|
||||
Ok(bin.canonicalize()?)
|
||||
}
|
||||
|
||||
/// Provision python binaries and return a `pip compile` command with options shared across all scenarios.
|
||||
fn command(context: &TestContext, python_versions: &[&str]) -> Command {
|
||||
let bin = create_bin_with_executables(&context.temp_dir, python_versions)
|
||||
|
@ -67,7 +32,7 @@ fn command(context: &TestContext, python_versions: &[&str]) -> Command {
|
|||
.arg(context.cache_dir.path())
|
||||
.env("VIRTUAL_ENV", context.venv.as_os_str())
|
||||
.env("PUFFIN_NO_WRAP", "1")
|
||||
.env("PUFFIN_PYTHON_PATH", bin)
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&context.temp_dir);
|
||||
command
|
||||
}
|
||||
|
|
|
@ -664,14 +664,17 @@ fn install_no_index_version() {
|
|||
|
||||
/// Install a package without using pre-built wheels.
|
||||
#[test]
|
||||
#[cfg(not(all(windows, debug_assertions)))] // Stack overflow on debug on windows -.-
|
||||
fn install_no_binary() {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
puffin_snapshot!(command(&context)
|
||||
.arg("Flask")
|
||||
.arg("--no-binary")
|
||||
.arg("--strict"), @r###"
|
||||
let mut command = command(&context);
|
||||
command.arg("Flask").arg("--no-binary").arg("--strict");
|
||||
if cfg!(all(windows, debug_assertions)) {
|
||||
// TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the
|
||||
// default windows stack of 1MB
|
||||
command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
puffin_snapshot!(command, @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
@ -728,14 +731,18 @@ fn install_no_binary_subset() {
|
|||
|
||||
/// Install a package without using pre-built wheels.
|
||||
#[test]
|
||||
#[cfg(not(all(windows, debug_assertions)))] // Stack overflow on debug on windows -.-
|
||||
fn reinstall_no_binary() {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
// The first installation should use a pre-built wheel
|
||||
puffin_snapshot!(command(&context)
|
||||
.arg("Flask")
|
||||
.arg("--strict"), @r###"
|
||||
let mut command = command(&context);
|
||||
command.arg("Flask").arg("--strict");
|
||||
if cfg!(all(windows, debug_assertions)) {
|
||||
// TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the
|
||||
// default windows stack of 1MB
|
||||
command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
puffin_snapshot!(command, @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
@ -757,10 +764,15 @@ fn reinstall_no_binary() {
|
|||
context.assert_command("import flask").success();
|
||||
|
||||
// Running installation again with `--no-binary` should be a no-op
|
||||
puffin_snapshot!(command(&context)
|
||||
.arg("Flask")
|
||||
.arg("--no-binary")
|
||||
.arg("--strict"), @r###"
|
||||
// The first installation should use a pre-built wheel
|
||||
let mut command = crate::command(&context);
|
||||
command.arg("Flask").arg("--no-binary").arg("--strict");
|
||||
if cfg!(all(windows, debug_assertions)) {
|
||||
// TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the
|
||||
// default windows stack of 1MB
|
||||
command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
puffin_snapshot!(command, @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
@ -773,12 +785,29 @@ fn reinstall_no_binary() {
|
|||
context.assert_command("import flask").success();
|
||||
|
||||
// With `--reinstall`, `--no-binary` should have an affect
|
||||
puffin_snapshot!(command(&context)
|
||||
let filters = if cfg!(windows) {
|
||||
// Remove the colorama count on windows
|
||||
INSTA_FILTERS
|
||||
.iter()
|
||||
.copied()
|
||||
.chain([("Resolved 8 packages", "Resolved 7 packages")])
|
||||
.collect()
|
||||
} else {
|
||||
INSTA_FILTERS.to_vec()
|
||||
};
|
||||
let mut command = crate::command(&context);
|
||||
command
|
||||
.arg("Flask")
|
||||
.arg("--no-binary")
|
||||
.arg("--reinstall-package")
|
||||
.arg("Flask")
|
||||
.arg("--strict"), @r###"
|
||||
.arg("--strict");
|
||||
if cfg!(all(windows, debug_assertions)) {
|
||||
// TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the
|
||||
// default windows stack of 1MB
|
||||
command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
puffin_snapshot!(filters, command, @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
|
@ -10,7 +10,9 @@ use assert_fs::prelude::*;
|
|||
use indoc::indoc;
|
||||
use url::Url;
|
||||
|
||||
use common::{create_venv, puffin_snapshot, venv_to_interpreter, INSTA_FILTERS};
|
||||
use common::{
|
||||
create_bin_with_executables, create_venv, puffin_snapshot, venv_to_interpreter, INSTA_FILTERS,
|
||||
};
|
||||
use puffin_fs::NormalizedDisplay;
|
||||
|
||||
use crate::common::{get_bin, TestContext};
|
||||
|
@ -318,6 +320,8 @@ fn link() -> Result<()> {
|
|||
.success();
|
||||
|
||||
let venv2 = context.temp_dir.child(".venv2");
|
||||
let bin = create_bin_with_executables(&context.temp_dir, &["3.12"])
|
||||
.expect("Failed to create bin dir");
|
||||
Command::new(get_bin())
|
||||
.arg("venv")
|
||||
.arg(venv2.as_os_str())
|
||||
|
@ -325,6 +329,7 @@ fn link() -> Result<()> {
|
|||
.arg(context.cache_dir.path())
|
||||
.arg("--python")
|
||||
.arg("3.12")
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&context.temp_dir)
|
||||
.assert()
|
||||
.success();
|
||||
|
@ -805,7 +810,6 @@ fn install_numpy_py38() -> Result<()> {
|
|||
|
||||
/// Install a package without using pre-built wheels.
|
||||
#[test]
|
||||
#[cfg(not(all(windows, debug_assertions)))] // Stack overflow on debug on windows -.-
|
||||
fn install_no_binary() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
|
@ -813,10 +817,17 @@ fn install_no_binary() -> Result<()> {
|
|||
requirements_txt.touch()?;
|
||||
requirements_txt.write_str("MarkupSafe==2.1.3")?;
|
||||
|
||||
puffin_snapshot!(command(&context)
|
||||
let mut command = command(&context);
|
||||
command
|
||||
.arg("requirements.txt")
|
||||
.arg("--no-binary")
|
||||
.arg("--strict"), @r###"
|
||||
.arg("--strict");
|
||||
if cfg!(all(windows, debug_assertions)) {
|
||||
// TODO(konstin): Reduce stack usage in debug mode enough that the tests pass with the
|
||||
// default windows stack of 1MB
|
||||
command.env("PUFFIN_STACK_SIZE", (2 * 1024 * 1024).to_string());
|
||||
}
|
||||
puffin_snapshot!(command, @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
|
|
@ -7,7 +7,7 @@ use assert_fs::prelude::*;
|
|||
|
||||
use puffin_fs::NormalizedDisplay;
|
||||
|
||||
use crate::common::{get_bin, puffin_snapshot};
|
||||
use crate::common::{create_bin_with_executables, get_bin, puffin_snapshot};
|
||||
|
||||
mod common;
|
||||
|
||||
|
@ -15,6 +15,7 @@ mod common;
|
|||
fn create_venv() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
let cache_dir = assert_fs::TempDir::new()?;
|
||||
let bin = create_bin_with_executables(&temp_dir, &["3.12"]).expect("Failed to create bin dir");
|
||||
let venv = temp_dir.child(".venv");
|
||||
|
||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||
|
@ -32,6 +33,7 @@ fn create_venv() -> Result<()> {
|
|||
.arg("3.12")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
@ -52,6 +54,7 @@ fn create_venv() -> Result<()> {
|
|||
fn create_venv_defaults_to_cwd() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
let cache_dir = assert_fs::TempDir::new()?;
|
||||
let bin = create_bin_with_executables(&temp_dir, &["3.12"]).expect("Failed to create bin dir");
|
||||
let venv = temp_dir.child(".venv");
|
||||
|
||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||
|
@ -68,6 +71,7 @@ fn create_venv_defaults_to_cwd() -> Result<()> {
|
|||
.arg("3.12")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
@ -88,6 +92,7 @@ fn create_venv_defaults_to_cwd() -> Result<()> {
|
|||
fn seed() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
let cache_dir = assert_fs::TempDir::new()?;
|
||||
let bin = create_bin_with_executables(&temp_dir, &["3.12"]).expect("Failed to create bin dir");
|
||||
let venv = temp_dir.child(".venv");
|
||||
|
||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||
|
@ -106,6 +111,7 @@ fn seed() -> Result<()> {
|
|||
.arg("3.12")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
@ -129,6 +135,7 @@ fn seed() -> Result<()> {
|
|||
fn create_venv_unknown_python_minor() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
let cache_dir = assert_fs::TempDir::new()?;
|
||||
let bin = create_bin_with_executables(&temp_dir, &["3.12"]).expect("Failed to create bin dir");
|
||||
let venv = temp_dir.child(".venv");
|
||||
|
||||
let mut command = Command::new(get_bin());
|
||||
|
@ -139,6 +146,7 @@ fn create_venv_unknown_python_minor() -> Result<()> {
|
|||
.arg("3.15")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir);
|
||||
if cfg!(windows) {
|
||||
puffin_snapshot!(&mut command, @r###"
|
||||
|
@ -172,6 +180,7 @@ fn create_venv_unknown_python_minor() -> Result<()> {
|
|||
fn create_venv_unknown_python_patch() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
let cache_dir = assert_fs::TempDir::new()?;
|
||||
let bin = create_bin_with_executables(&temp_dir, &["3.12"]).expect("Failed to create bin dir");
|
||||
let venv = temp_dir.child(".venv");
|
||||
|
||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||
|
@ -189,6 +198,7 @@ fn create_venv_unknown_python_patch() -> Result<()> {
|
|||
.arg("3.8.0")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: false
|
||||
exit_code: 1
|
||||
|
@ -205,10 +215,13 @@ fn create_venv_unknown_python_patch() -> Result<()> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[ignore] // TODO(konstin): Switch patch version strategy
|
||||
#[cfg(unix)] // TODO(konstin): Support patch versions on Windows
|
||||
fn create_venv_python_patch() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
let cache_dir = assert_fs::TempDir::new()?;
|
||||
let bin =
|
||||
create_bin_with_executables(&temp_dir, &["3.12.1"]).expect("Failed to create bin dir");
|
||||
let venv = temp_dir.child(".venv");
|
||||
|
||||
let filter_venv = regex::escape(&venv.normalized_display().to_string());
|
||||
|
@ -223,6 +236,7 @@ fn create_venv_python_patch() -> Result<()> {
|
|||
.arg("3.12.1")
|
||||
.arg("--cache-dir")
|
||||
.arg(cache_dir.path())
|
||||
.env("PUFFIN_TEST_PYTHON_PATH", bin)
|
||||
.current_dir(&temp_dir), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue