mirror of
https://github.com/sagiegurari/cargo-make
synced 2026-06-08 17:20:03 +00:00
Fix: extend attribute didn't extend env variables #579
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
### v0.35.1
|
||||
|
||||
* Fix: extend attribute didn't extend env variables #579
|
||||
* Enhancement: Limit search to one result when searching for updates #574 (thanks @jayvdb)
|
||||
|
||||
### v0.35.0 (2021-07-10)
|
||||
|
||||
@@ -16,3 +16,14 @@ args = ["2"]
|
||||
[tasks.3]
|
||||
extend = "2"
|
||||
args = ["3"]
|
||||
|
||||
[tasks.task1]
|
||||
env = { Foo = "foo" }
|
||||
command = "echo"
|
||||
args = ["${Foo}"]
|
||||
|
||||
[tasks.task1.linux]
|
||||
env = { Foo = "foo-linux" }
|
||||
|
||||
[tasks.task2]
|
||||
extend = "task1"
|
||||
|
||||
@@ -82,6 +82,16 @@ fn get_optional_normalized_task(config: &Config, name: &str, support_alias: bool
|
||||
let mut extended_task =
|
||||
get_normalized_task(config, extended_task_name, support_alias);
|
||||
|
||||
if let Some(ref env) = normalized_task.env {
|
||||
if env.len() == 2
|
||||
&& env.contains_key("CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE")
|
||||
&& env.contains_key(
|
||||
"CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY",
|
||||
)
|
||||
{
|
||||
normalized_task.env = None;
|
||||
}
|
||||
}
|
||||
extended_task.extend(&normalized_task);
|
||||
|
||||
extended_task
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use crate::descriptor;
|
||||
use crate::types::{
|
||||
ConfigSection, CrateInfo, DependencyIdentifier, PlatformOverrideTask, Task, TaskWatchOptions,
|
||||
Workspace,
|
||||
@@ -1301,6 +1302,31 @@ fn create_noworkspace() {
|
||||
assert_eq!(execution_plan.steps[0].name, "test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn create_task_extends_empty_env_bug_verification() {
|
||||
let config = descriptor::load(
|
||||
"./src/lib/test/makefiles/task_extend.toml",
|
||||
true,
|
||||
None,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let execution_plan = create(&config, "task2", true, false, false, &None);
|
||||
|
||||
assert_eq!(execution_plan.steps.len(), 3);
|
||||
|
||||
let step = execution_plan.steps[1].clone();
|
||||
assert_eq!(step.name, "task2");
|
||||
|
||||
let env = step.config.env.unwrap();
|
||||
match env.get("Foo").unwrap() {
|
||||
EnvValue::Value(value) => assert_eq!(value, "foo"),
|
||||
_ => panic!("Invalid env type"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_skip_workspace_member_empty() {
|
||||
let skipped_members = HashSet::new();
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
[config]
|
||||
skip_core_tasks = true
|
||||
|
||||
[tasks.task1]
|
||||
env = { Foo = "foo" }
|
||||
command = "echo"
|
||||
args = ["${Foo}"]
|
||||
|
||||
[tasks.task2]
|
||||
extend = "task1"
|
||||
+1
-1
@@ -2110,7 +2110,7 @@ impl ExternalConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
#[derive(Serialize, Clone, Debug)]
|
||||
/// Execution plan step to execute
|
||||
pub struct Step {
|
||||
/// The task name
|
||||
|
||||
Reference in New Issue
Block a user