Skip to content

Commit

Permalink
fix: trim() the spec for overrideFile() (#1256)
Browse files Browse the repository at this point in the history
fix: trim() the spac for overrideFile()

Signed-off-by: zongz <[email protected]>
  • Loading branch information
zong-zhe authored Apr 29, 2024
1 parent c41b8f3 commit bb416e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kclvm/query/src/override.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub fn apply_override_on_module(
pub fn parse_override_spec(spec: &str) -> Result<ast::OverrideSpec> {
if spec.contains('=') {
// Create or update the override value.
let split_values = spec.splitn(2, '=').collect::<Vec<&str>>();
let split_values = spec.splitn(2, '=').map(|s| s.trim()).collect::<Vec<&str>>();
let path = split_values
.first()
.ok_or_else(|| invalid_spec_error(spec))?;
Expand Down
3 changes: 3 additions & 0 deletions kclvm/query/src/test_data/test_override_file/expect.k
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ _access = test.ServiceAccess {
TestStr = ["${test_str}"]
ports = [80, 443]
booltest = True
mergedattr = 1
}

b = {"c": 2}
Expand All @@ -24,3 +25,5 @@ _access3 = test.ServiceAccess {
_access5 = {iType = "dddddd"}

a = b

_access6 = "a6"
2 changes: 2 additions & 0 deletions kclvm/query/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ fn test_overridefile_insert() {
r#"_access.iType="kkkkkkk""#.to_string(),
r#"_access5.iType="dddddd""#.to_string(),
r#"a=b"#.to_string(),
r#"_access6 ="a6""#.to_string(),
r#"_access.mergedattr=1"#.to_string(),
];

let simple_path = get_test_dir("test_override_file/main.k".to_string());
Expand Down

0 comments on commit bb416e9

Please sign in to comment.