Skip to content

Commit

Permalink
add test for additional targets
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Feb 23, 2024
1 parent 2a9d083 commit 77cb04e
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
34 changes: 34 additions & 0 deletions tests/pixi_tomls/many_targets.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[project]
name = "pixi"
version = "0.14.0"
description = "Package management made easy!"
authors = ["Wolf Vollprecht <[email protected]>", "Bas Zalmstra <[email protected]>", "Tim de Jager <[email protected]>", "Ruben Arts <[email protected]>"]
channels = ["conda-forge"]
platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"]

[dependencies]
all = "*"

[target.linux-64.dependencies]
linux = "*"

[target.win-64.dependencies]
win = "*"

[target.osx-64.dependencies]
osx_64 = "*"

[target.osx-arm64.dependencies]
osx_arm64 = "*"

[target.linux.dependencies]
all_linux = "*"

[target.windows.dependencies]
all_win = "*"

[target.macos.dependencies]
all_macos = "*"

[target.unix.dependencies]
all_unix = "*"
23 changes: 22 additions & 1 deletion tests/project_tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
mod common;

use std::path::PathBuf;

use crate::{common::package_database::PackageDatabase, common::PixiControl};
use rattler_conda_types::{Channel, ChannelConfig};
use insta::assert_debug_snapshot;
use pixi::Project;
use rattler_conda_types::{Channel, ChannelConfig, Platform};
use tempfile::TempDir;
use url::Url;

Expand Down Expand Up @@ -45,3 +49,20 @@ async fn add_channel() {
.unwrap();
assert!(project.channels().contains(&local_channel));
}

#[tokio::test]
async fn parse_project() {
fn dependency_names(project: &Project, platform: Platform) -> Vec<String> {
project
.dependencies(None, Some(platform))
.iter()
.map(|dep| dep.0.as_normalized().to_string())
.collect()
}

let pixi_toml = include_str!("./pixi_tomls/many_targets.toml");
let project = Project::from_str(&PathBuf::from("./many"), pixi_toml).unwrap();
assert_debug_snapshot!(dependency_names(&project, Platform::Linux64));
assert_debug_snapshot!(dependency_names(&project, Platform::OsxArm64));
assert_debug_snapshot!(dependency_names(&project, Platform::Win64));
}
10 changes: 10 additions & 0 deletions tests/snapshots/project_tests__parse_project-2.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: tests/project_tests.rs
expression: "dependency_names(&project, Platform::OsxArm64)"
---
[
"all",
"osx_arm64",
"all_macos",
"all_unix",
]
9 changes: 9 additions & 0 deletions tests/snapshots/project_tests__parse_project-3.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: tests/project_tests.rs
expression: "dependency_names(&project, Platform::Win64)"
---
[
"all",
"win",
"all_win",
]
10 changes: 10 additions & 0 deletions tests/snapshots/project_tests__parse_project.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: tests/project_tests.rs
expression: "dependency_names(&project, Platform::Linux64)"
---
[
"all",
"linux",
"all_linux",
"all_unix",
]

0 comments on commit 77cb04e

Please sign in to comment.