uv/scripts/scenarios/templates/compile.mustache
konsti 1dc9904f8c
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>
2024-02-08 22:09:55 +01:00

99 lines
2.8 KiB
Text

//! DO NOT EDIT
//!
//! Generated with {{generated_with}}
//! Scenarios from <{{generated_from}}>
//!
#![cfg(all(feature = "python", feature = "pypi"))]
use std::env;
use std::process::Command;
use anyhow::Result;
use assert_cmd::assert::OutputAssertExt;
use assert_fs::fixture::{FileWriteStr, PathChild};
use predicates::prelude::predicate;
use common::{create_bin_with_executables, get_bin, puffin_snapshot, TestContext, INSTA_FILTERS};
mod common;
/// 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)
.expect("Failed to create bin dir");
let mut command = Command::new(get_bin());
command
.arg("pip")
.arg("compile")
.arg("requirements.in")
.arg("--extra-index-url")
.arg("https://test.pypi.org/simple")
.arg("--cache-dir")
.arg(context.cache_dir.path())
.env("VIRTUAL_ENV", context.venv.as_os_str())
.env("PUFFIN_NO_WRAP", "1")
.env("PUFFIN_TEST_PYTHON_PATH", bin)
.current_dir(&context.temp_dir);
command
}
{{#scenarios}}
/// {{name}}
///
{{#description_lines}}
/// {{.}}
{{/description_lines}}
///
/// ```text
/// {{version}}
{{#tree}}
/// {{.}}
{{/tree}}
/// ```
#[test]
fn {{module_name}}() -> Result<()> {
let context = TestContext::new("{{environment.python}}");
let python_versions = &[{{#environment.additional_python}}"{{.}}", {{/environment.additional_python}}];
// In addition to the standard filters, swap out package names for more realistic messages
let mut filters = INSTA_FILTERS.to_vec();
{{#packages}}
filters.push((r"{{name}}", "{{cute_name}}"));
{{/packages}}
filters.push((r"-{{version}}", ""));
let requirements_in = context.temp_dir.child("requirements.in");
{{#root.requires}}
requirements_in.write_str("{{requirement}}")?;
{{/root.requires}}
{{#expected.explanation_lines}}
// {{.}}
{{/expected.explanation_lines}}
let output = puffin_snapshot!(filters, command(&context, python_versions)
{{#environment.prereleases}}
.arg("--prerelease=allow")
{{/environment.prereleases}}
{{#resolver_options.python}}
.arg("--python-version={{.}}")
{{/resolver_options.python}}, @r###"<snapshot>
"###
);
output
.assert()
{{#expected.satisfiable}}
.success()
{{#expected.packages}}
.stdout(predicate::str::contains("{{name}}=={{version}}"))
{{/expected.packages}}
{{/expected.satisfiable}}
{{^expected.satisfiable}}
.failure()
{{/expected.satisfiable}}
;
Ok(())
}
{{/scenarios}}