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

test: running cuda env and using those tasks. #764

Merged
Merged
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
44 changes: 41 additions & 3 deletions src/task/task_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,22 +366,23 @@ pub enum TaskGraphError {
#[cfg(test)]
mod test {
use crate::task::task_graph::TaskGraph;
use crate::Project;
use crate::{EnvironmentName, Project};
use rattler_conda_types::Platform;
use std::path::Path;

fn commands_in_order(
project_str: &str,
run_args: &[&str],
platform: Option<Platform>,
environment_name: Option<EnvironmentName>,
) -> Vec<String> {
let project = Project::from_str(Path::new(""), project_str).unwrap();

let environment = environment_name.map(|name| project.environment(&name).unwrap());
let graph = TaskGraph::from_cmd_args(
&project,
run_args.into_iter().map(|arg| arg.to_string()).collect(),
platform,
None,
environment,
)
.unwrap();

Expand Down Expand Up @@ -409,6 +410,7 @@ mod test {
top = {cmd="echo top", depends_on=["task1","task2"]}
"#,
&["top", "--test"],
None,
None
),
vec!["echo root", "echo task1", "echo task2", "echo top --test"]
Expand All @@ -431,6 +433,7 @@ mod test {
top = {cmd="echo top", depends_on=["task1","task2"]}
"#,
&["top"],
None,
None
),
vec!["echo root", "echo task1", "echo task2", "echo top"]
Expand All @@ -456,6 +459,7 @@ mod test {
"#,
&["top"],
Some(Platform::Linux64),
None
),
vec!["echo linux", "echo task1", "echo task2", "echo top",]
);
Expand All @@ -473,6 +477,7 @@ mod test {
"#,
&["echo bla"],
None,
None
),
vec![r#""echo bla""#]
);
Expand All @@ -496,6 +501,7 @@ mod test {
"#,
&["build"],
None,
None
),
vec![r#"echo build"#]
);
Expand All @@ -522,8 +528,40 @@ mod test {
"#,
&["start"],
None,
None
),
vec![r#"hello world"#]
);
}

#[test]
fn test_multi_env_cuda() {
assert_eq!(
commands_in_order(
r#"
[project]
name = "pixi"
channels = ["conda-forge"]
platforms = ["linux-64"]

[tasks]
train = "python train.py"
test = "python test.py"
start = {depends_on = ["train", "test"]}

[feature.cuda.tasks]
train = "python train.py --cuda"
test = "python test.py --cuda"

[environments]
cuda = ["cuda"]

"#,
&["start"],
None,
Some(EnvironmentName::Named("cuda".to_string()))
),
vec![r#"python train.py --cuda"#, r#"python test.py --cuda"#]
);
}
}
Loading