Skip to content

Commit

Permalink
fix: sort keys flag and lsp hover tests (#1074)
Browse files Browse the repository at this point in the history
* fix: sort keys flag

Signed-off-by: peefy <[email protected]>

* fix: lsp hover tests

Signed-off-by: peefy <[email protected]>

* chore: change unit test to workspace

Signed-off-by: peefy <[email protected]>

---------

Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy authored Feb 21, 2024
1 parent 19c5eee commit 0ae3fe2
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $bin_path = Join-Path $PSScriptRoot 'scripts\build-windows\_output\kclvm-windows
$env:Path += ";$bin_path"
# rust unit test
Set-Location .\kclvm
cargo test -p kclvm-*
cargo test --workspace -r -- --nocapture
Set-Location $PSScriptRoot
# rust runtime test
Set-Location .\kclvm\tests\test_units
Expand Down
2 changes: 1 addition & 1 deletion kclvm/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fix:

# Unit tests without code cov
test:
cargo test -p kclvm-* -r -- --nocapture
cargo test --workspace -r -- --nocapture

# Unit tests with code cov (Requires rust 1.60+)
codecov:
Expand Down
3 changes: 2 additions & 1 deletion kclvm/runner/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ impl KclLibRunner {
disable_schema_check: 0, // todo
list_option_mode: 0, // todo
disable_empty_list: 0,
show_hidden: args.show_hidden as i32, // todo
sort_keys: args.sort_keys as i32,
show_hidden: args.show_hidden as i32,
debug_mode: args.debug,
include_schema_type_path: args.include_schema_type_path as i32,
};
Expand Down
2 changes: 2 additions & 0 deletions kclvm/runtime/src/_kcl_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub struct FFIRunOptions {
pub list_option_mode: i32,
pub debug_mode: i32,
pub show_hidden: i32,
pub sort_keys: i32,
pub include_schema_type_path: i32,
pub disable_empty_list: i32,
}
Expand All @@ -72,6 +73,7 @@ fn new_ctx_with_opts(opts: FFIRunOptions, path_selector: &[String]) -> Context {
// Plan options
ctx.plan_opts.disable_none = opts.disable_none != 0;
ctx.plan_opts.show_hidden = opts.show_hidden != 0;
ctx.plan_opts.sort_keys = opts.sort_keys != 0;
ctx.plan_opts.include_schema_type_path = opts.include_schema_type_path != 0;
ctx.plan_opts.disable_empty_list = opts.disable_empty_list != 0;
ctx.plan_opts.query_paths = path_selector.to_vec();
Expand Down
2 changes: 1 addition & 1 deletion kclvm/tools/src/LSP/src/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ mod tests {
assert_eq!(s, "fn print() -> NoneType");
}
if let MarkedString::String(s) = vec[1].clone() {
assert_eq!(s, "Prints the values to a stream, or to sys.stdout by default.\n\n Optional keyword arguments:\n\n sep: string inserted between values, default a space.\n\n end: string appended after the last value, default a newline.");
assert_eq!(s, "Prints the values to a stream, or to the system stdout by default.\n\nOptional keyword arguments:\n\nsep: string inserted between values, default a space.\n\nend: string appended after the last value, default a newline.");
}
}
_ => unreachable!("test error"),
Expand Down
4 changes: 4 additions & 0 deletions test/grammar/sort_keys/config/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
c = {
b = 1
a = 2
}
1 change: 1 addition & 0 deletions test/grammar/sort_keys/config/settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kcl_options: -d --sort_keys
3 changes: 3 additions & 0 deletions test/grammar/sort_keys/config/stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
c:
a: 2
b: 1
8 changes: 8 additions & 0 deletions test/grammar/sort_keys/schema/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
schema X:
b: int
a: int

c = X {
b = 1
a = 2
}
1 change: 1 addition & 0 deletions test/grammar/sort_keys/schema/settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kcl_options: -d --sort_keys
3 changes: 3 additions & 0 deletions test/grammar/sort_keys/schema/stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
c:
a: 2
b: 1

0 comments on commit 0ae3fe2

Please sign in to comment.