Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: manifest tests and run them in ci #1667

Merged
merged 4 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ jobs:
uses: rui314/setup-mold@v1

- name: "Cargo nextest"
run: |
# we don't have anymore vendored openssl so we need to use rustls
cargo nextest run --retries 2 --status-level skip --failure-output immediate-final --no-fail-fast --final-status-level slow --no-default-features --features rustls-tls --features slow_integration_tests

run: >-
cargo nextest run
--workspace
--retries 2
--no-default-features --features rustls-tls --features slow_integration_tests
--status-level skip --failure-output immediate-final --no-fail-fast --final-status-level slow

build:
name: Build Binary | ${{ matrix.name }}
Expand Down
6 changes: 4 additions & 2 deletions crates/pixi_manifest/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ impl Manifest {
}

/// Returns a mutable reference to the default feature.
fn default_feature_mut(&mut self) -> &mut Feature {
pub(crate) fn default_feature_mut(&mut self) -> &mut Feature {
self.parsed.default_feature_mut()
}

Expand Down Expand Up @@ -644,10 +644,12 @@ impl Manifest {

#[cfg(test)]
mod tests {
use indexmap::IndexMap;
use std::str::FromStr;

use insta::{assert_snapshot, assert_yaml_snapshot};
use insta::assert_snapshot;
use miette::NarratableReportHandler;
use rattler_conda_types::ParseStrictness::Strict;
use rattler_conda_types::{Channel, ChannelConfig, ParseStrictness};
use rattler_solve::ChannelPriority;
use rstest::*;
Expand Down
9 changes: 9 additions & 0 deletions crates/pixi_manifest/src/parsed_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,17 @@ mod tests {
use crate::parsed_manifest::ParsedManifest;
use crate::TargetSelector;
use insta::{assert_snapshot, assert_yaml_snapshot};
use itertools::Itertools;
use rattler_conda_types::{Channel, Platform};

const PROJECT_BOILERPLATE: &str = r#"
[project]
name = "foo"
version = "0.1.0"
channels = []
platforms = []
"#;

#[test]
fn test_target_specific() {
let contents = format!(
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---
[project]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---

[project]
name = "foo"
channels = []
Expand All @@ -21,4 +20,3 @@ boef = ">=2.3"

[feature.build.target.linux-64.build-dependencies]
cmake = ">=2.3"

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---

[project]
name = "foo"
version = "0.1.0"
Expand All @@ -22,5 +21,3 @@ feature_test = "echo feature_test"

[feature.test.target.linux-64.tasks]
feature_test_target_linux = "echo feature_test_target_linux"


Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---
[project]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---
[project]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---
[project]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---
[project]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---
[project]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---
[project]
Expand All @@ -26,4 +26,3 @@ feature_dep = "*"

[feature.test.target.linux-64.pypi-dependencies]
feature_target_dep = "*"

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---
[project]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/manifest.rs
expression: manifest.document.to_string()
---
[project]
Expand All @@ -26,4 +26,3 @@ feature_dep = "*"

[feature.test.target.linux-64.pypi-dependencies]
feature_target_dep = "*"

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: src/project/manifest/mod.rs
expression: "examples.into_iter().map(|example|\n ProjectManifest::from_toml_str(&example).unwrap_err().to_string()).collect::<Vec<_>>().join(\"\\n\")"
source: crates/pixi_manifest/src/parsed_manifest.rs
expression: "examples.into_iter().map(|example|\n ParsedManifest::from_toml_str(&example).unwrap_err().to_string()).collect::<Vec<_>>().join(\"\\n\")"
---
TOML parse error at line 8, column 2
|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: src/project/manifest/mod.rs
expression: "examples.into_iter().map(|example|\n ProjectManifest::from_toml_str(&format!(\"{PROJECT_BOILERPLATE}\\n{example}\")).unwrap_err().to_string()).collect::<Vec<_>>().join(\"\\n\")"
source: crates/pixi_manifest/src/parsed_manifest.rs
expression: "examples.into_iter().map(|example|\n ParsedManifest::from_toml_str(&format!(\"{PROJECT_BOILERPLATE}\\n{example}\")).unwrap_err().to_string()).collect::<Vec<_>>().join(\"\\n\")"
---
TOML parse error at line 8, column 9
|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: crates/pixi_manifest/src/parsed_manifest.rs
expression: "toml_edit::de::from_str::<ParsedManifest>(&contents).expect(\"parsing should succeed!\").project.pypi_options.clone().unwrap()"
---
index-url: "https://pypi.org/simple"
extra-index-urls:
- "https://pypi.org/simple2"
find-links:
- path: "../foo"
- url: "https://example.com/bar"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: src/project/manifest/mod.rs
source: crates/pixi_manifest/src/parsed_manifest.rs
expression: manifest.project.pypi_options.clone().unwrap()
---
index-url: ~
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
source: crates/pixi_manifest/src/parsed_manifest.rs
expression: "toml_edit::de::from_str::<ParsedManifest>(&contents).expect(\"parsing should succeed!\").default_feature().targets.default().pypi_dependencies.clone().into_iter().flat_map(|d|\n d.into_iter()).map(|(name, spec)|\n format!(\"{} = {}\", name.as_source(),\n toml_edit::Value::from(spec))).join(\"\\n\")"
---
foo = ">=3.12"
bar = { version = ">=3.12", extras = ["baz"] }
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/pixi_manifest/src/lib.rs
assertion_line: 1557
source: crates/pixi_manifest/src/parsed_manifest.rs
expression: "manifest.default_feature().targets.iter().flat_map(|(target, selector)|\n {\n let selector_name =\n selector.map_or_else(|| String::from(\"default\"),\n ToString::to_string);\n target.tasks.iter().filter_map(move |(name, task)|\n {\n Some(format!(\"{}/{} = {}\", &selector_name, name.as_str(),\n task.as_single_command()?))\n })\n }).join(\"\\n\")"
---
default/test = test multi
Expand Down
Loading
Loading