Fix: extend attribute didn't extend env variables #579

This commit is contained in:
sagie gur ari
2021-08-28 07:21:51 +00:00
parent ff210eeed7
commit a539aa3431
6 changed files with 60 additions and 1 deletions
+1
View File
@@ -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)
+11
View File
@@ -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"
+10
View File
@@ -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
+26
View File
@@ -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();
+11
View File
@@ -0,0 +1,11 @@
[config]
skip_core_tasks = true
[tasks.task1]
env = { Foo = "foo" }
command = "echo"
args = ["${Foo}"]
[tasks.task2]
extend = "task1"
+1 -1
View File
@@ -2110,7 +2110,7 @@ impl ExternalConfig {
}
}
#[derive(Serialize, Debug)]
#[derive(Serialize, Clone, Debug)]
/// Execution plan step to execute
pub struct Step {
/// The task name