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

feat: impl path selector in the run API. #802

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions kclvm/api/src/capi_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ fn test_c_api_call_exec_program_with_include_schema_type_path() {
);
}

#[test]
fn test_c_api_call_exec_program_with_path_selector() {
test_c_api::<ExecProgramArgs, ExecProgramResult, _>(
"KclvmService.ExecProgram",
"exec-program-with-path-selector.json",
"exec-program-with-path-selector.response.json",
|res| res.escaped_time = "0".to_owned(),
);
}

#[test]
fn test_c_api_call_override_file() {
test_c_api_without_wrapper::<OverrideFileArgs, OverrideFileResult>(
Expand Down
9 changes: 9 additions & 0 deletions kclvm/api/src/testdata/exec-program-with-path-selector.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"work_dir" : "./src/testdata",
"k_filename_list": [
"test.k"
],
"path_selector": [
"alice"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"json_result": "[{\"age\": 18}]",
"yaml_result": "age: 18"
}
1 change: 0 additions & 1 deletion kclvm/runner/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub struct ExecProgramArgs {
// -O override_spec
pub overrides: Vec<ast::OverrideSpec>,
// -S path_selector
#[serde(skip)]
pub path_selector: Vec<String>,
pub disable_yaml_result: bool,
// Whether to apply overrides on the source code.
Expand Down
2 changes: 1 addition & 1 deletion kclvm/runner/src/test_datas/exec_prog_args/default.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"work_dir":null,"k_filename_list":[],"external_pkgs":[],"k_code_list":[],"args":[],"overrides":[],"disable_yaml_result":false,"print_override_ast":false,"strict_range_check":false,"disable_none":false,"verbose":0,"debug":0,"sort_keys":false,"include_schema_type_path":false,"compile_only":false}
{"work_dir":null,"k_filename_list":[],"external_pkgs":[],"k_code_list":[],"args":[],"overrides":[],"path_selector":[],"disable_yaml_result":false,"print_override_ast":false,"strict_range_check":false,"disable_none":false,"verbose":0,"debug":0,"sort_keys":false,"include_schema_type_path":false,"compile_only":false}
2 changes: 1 addition & 1 deletion kclvm/runner/src/test_datas/settings_file/settings.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"work_dir":null,"k_filename_list":["../main.k","./before/base.k","./main.k","./sub/sub.k"],"external_pkgs":[],"k_code_list":[],"args":[{"name":"app-name","value":"\"kclvm\""},{"name":"image","value":"\"kclvm:v0.0.1\""}],"overrides":[],"disable_yaml_result":false,"print_override_ast":false,"strict_range_check":false,"disable_none":false,"verbose":0,"debug":0,"sort_keys":false,"include_schema_type_path":false,"compile_only":false}
{"work_dir":null,"k_filename_list":["../main.k","./before/base.k","./main.k","./sub/sub.k"],"external_pkgs":[],"k_code_list":[],"args":[{"name":"app-name","value":"\"kclvm\""},{"name":"image","value":"\"kclvm:v0.0.1\""}],"overrides":[],"path_selector":[],"disable_yaml_result":false,"print_override_ast":false,"strict_range_check":false,"disable_none":false,"verbose":0,"debug":0,"sort_keys":false,"include_schema_type_path":false,"compile_only":false}
3 changes: 3 additions & 0 deletions kclvm/spec/gpyrpc/gpyrpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ message ExecProgram_Args {

// Whether only compiling the program
bool compile_only = 15;

// -S --path_selector
repeated string path_selector = 16;
}

message ExecProgram_Result {
Expand Down
Loading