From b4ef5661dbf06f55e556c2abd1f06fbae9d7137c Mon Sep 17 00:00:00 2001 From: shruti2522 Date: Sat, 4 May 2024 04:13:09 +0530 Subject: [PATCH] feat: added mkdir and delete module functions Signed-off-by: shruti2522 corrected formatting Signed-off-by: shruti2522 updated formatting Signed-off-by: shruti2522 feat: added mkdir and delete module functions Signed-off-by: shruti2522 updated linker.rs feat: added mkdir and delete module functions Signed-off-by: shruti2522 format checking Signed-off-by: shruti2522 `get_schema_type` function will now return `SchemaType` instances with base schema information included (#1272) * `get_schema_type` and `get_full_schema_type` will now return `SchemaType` instance Signed-off-by: utnim2 * added the recursive function Signed-off-by: utnim2 * fixed the types Signed-off-by: utnim2 --------- Signed-off-by: utnim2 feat: extend file module functions mkdir and delete Signed-off-by: shruti2522 feat: added mkdir and delete module functions Signed-off-by: shruti2522 tests added Signed-off-by: shruti2522 tests updated Signed-off-by: shruti2522 feat: added mkdir and delete module functions Signed-off-by: shruti2522 updated test cases Signed-off-by: shruti2522 updated kclvm loader snaps Signed-off-by: shruti2522 added stderr output Signed-off-by: shruti2522 feat: added mkdir and delete module functions Signed-off-by: shruti2522 --- kclvm/api/src/service/service_impl.rs | 6 +- .../kclvm_loader__tests__assign_stmt_0.snap | 2 +- .../kclvm_loader__tests__assign_stmt_1.snap | 2 +- .../kclvm_loader__tests__assign_stmt_2.snap | 2 +- .../kclvm_loader__tests__builtin_call_0.snap | 30 +++--- .../kclvm_loader__tests__builtin_call_1.snap | 92 +++++++++--------- .../kclvm_loader__tests__builtin_call_2.snap | 96 +++++++++---------- .../kclvm_loader__tests__import_stmt_0.snap | 2 +- .../kclvm_loader__tests__import_stmt_1.snap | 2 +- kclvm/runtime/src/_kclvm.h | 4 + kclvm/runtime/src/_kclvm.ll | 4 + kclvm/runtime/src/_kclvm.rs | 2 + kclvm/runtime/src/_kclvm_addr.rs | 2 + kclvm/runtime/src/_kclvm_api_spec.rs | 8 ++ kclvm/runtime/src/file/mod.rs | 52 ++++++++++ kclvm/sema/src/builtin/system_module.rs | 28 ++++++ test/grammar/builtins/file/delete/main.k | 6 ++ .../builtins/file/delete/stderr.golden | 1 + .../builtins/file/delete/stdout.golden | 1 + test/grammar/builtins/file/mkdir/main.k | 3 + .../grammar/builtins/file/mkdir/stderr.golden | 2 + .../grammar/builtins/file/mkdir/stdout.golden | 1 + 22 files changed, 231 insertions(+), 117 deletions(-) create mode 100644 test/grammar/builtins/file/delete/main.k create mode 100644 test/grammar/builtins/file/delete/stderr.golden create mode 100644 test/grammar/builtins/file/delete/stdout.golden create mode 100644 test/grammar/builtins/file/mkdir/main.k create mode 100644 test/grammar/builtins/file/mkdir/stderr.golden create mode 100644 test/grammar/builtins/file/mkdir/stdout.golden diff --git a/kclvm/api/src/service/service_impl.rs b/kclvm/api/src/service/service_impl.rs index 1126ab628..cd12a6825 100644 --- a/kclvm/api/src/service/service_impl.rs +++ b/kclvm/api/src/service/service_impl.rs @@ -176,9 +176,9 @@ impl KclvmServiceImpl { /// assert_eq!(result.type_errors.len(), 0); /// assert_eq!(result.symbols.len(), 12); /// assert_eq!(result.scopes.len(), 3); - /// assert_eq!(result.node_symbol_map.len(), 169); - /// assert_eq!(result.symbol_node_map.len(), 169); - /// assert_eq!(result.fully_qualified_name_map.len(), 178); + /// assert_eq!(result.node_symbol_map.len(), 171); + /// assert_eq!(result.symbol_node_map.len(), 171); + /// assert_eq!(result.fully_qualified_name_map.len(), 180); /// assert_eq!(result.pkg_scope_map.len(), 3); /// ``` #[inline] diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_0.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_0.snap index c5c4a3d41..7199e349c 100644 --- a/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_0.snap +++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_0.snap @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 157, + index: 159, generation: 0, }, kind: Value, diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_1.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_1.snap index 8bd99ab35..702f9b952 100644 --- a/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_1.snap +++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_1.snap @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 157, + index: 159, generation: 0, }, kind: Value, diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_2.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_2.snap index 9baf28c35..40c8de6e0 100644 --- a/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_2.snap +++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__assign_stmt_2.snap @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 157, + index: 159, generation: 0, }, kind: Value, diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_0.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_0.snap index 019e2db39..25838bc88 100644 --- a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_0.snap +++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_0.snap @@ -88,20 +88,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, ), attrs: [ - SymbolRef { - id: Index { - index: 128, - generation: 0, - }, - kind: Value, - }, - SymbolRef { - id: Index { - index: 129, - generation: 0, - }, - kind: Value, - }, SymbolRef { id: Index { index: 130, @@ -291,6 +277,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, kind: Value, }, + SymbolRef { + id: Index { + index: 157, + generation: 0, + }, + kind: Value, + }, + SymbolRef { + id: Index { + index: 158, + generation: 0, + }, + kind: Value, + }, ], is_global: false, }, @@ -330,4 +330,4 @@ expression: "format!(\"{:#?}\", p.symbols.values())" attrs: [], is_global: false, }, -] +] \ No newline at end of file diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_1.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_1.snap index e72d8f74f..7d7bcecb9 100644 --- a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_1.snap +++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_1.snap @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 157, + index: 159, generation: 0, }, kind: Value, @@ -180,20 +180,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, ), attrs: [ - SymbolRef { - id: Index { - index: 128, - generation: 0, - }, - kind: Value, - }, - SymbolRef { - id: Index { - index: 129, - generation: 0, - }, - kind: Value, - }, SymbolRef { id: Index { index: 130, @@ -383,6 +369,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, kind: Value, }, + SymbolRef { + id: Index { + index: 157, + generation: 0, + }, + kind: Value, + }, + SymbolRef { + id: Index { + index: 158, + generation: 0, + }, + kind: Value, + }, ], is_global: false, }, @@ -415,27 +415,13 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 158, + index: 160, generation: 0, }, kind: Value, }, ), attrs: [ - SymbolRef { - id: Index { - index: 128, - generation: 0, - }, - kind: Value, - }, - SymbolRef { - id: Index { - index: 129, - generation: 0, - }, - kind: Value, - }, SymbolRef { id: Index { index: 130, @@ -625,6 +611,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, kind: Value, }, + SymbolRef { + id: Index { + index: 157, + generation: 0, + }, + kind: Value, + }, + SymbolRef { + id: Index { + index: 158, + generation: 0, + }, + kind: Value, + }, ], is_global: false, }, @@ -664,20 +664,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, ), attrs: [ - SymbolRef { - id: Index { - index: 128, - generation: 0, - }, - kind: Value, - }, - SymbolRef { - id: Index { - index: 129, - generation: 0, - }, - kind: Value, - }, SymbolRef { id: Index { index: 130, @@ -867,6 +853,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, kind: Value, }, + SymbolRef { + id: Index { + index: 157, + generation: 0, + }, + kind: Value, + }, + SymbolRef { + id: Index { + index: 158, + generation: 0, + }, + kind: Value, + }, ], is_global: false, }, @@ -899,7 +899,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 159, + index: 161, generation: 0, }, kind: Value, @@ -982,4 +982,4 @@ expression: "format!(\"{:#?}\", p.symbols.values())" attrs: [], is_global: false, }, -] +] \ No newline at end of file diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_2.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_2.snap index 3d9153252..160a9d9a0 100644 --- a/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_2.snap +++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_2.snap @@ -99,7 +99,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 157, + index: 159, generation: 0, }, kind: Value, @@ -240,7 +240,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 158, + index: 160, generation: 0, }, kind: Value, @@ -337,7 +337,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 157, + index: 159, generation: 0, }, kind: Value, @@ -382,20 +382,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, ), attrs: [ - SymbolRef { - id: Index { - index: 128, - generation: 0, - }, - kind: Value, - }, - SymbolRef { - id: Index { - index: 129, - generation: 0, - }, - kind: Value, - }, SymbolRef { id: Index { index: 130, @@ -585,6 +571,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, kind: Value, }, + SymbolRef { + id: Index { + index: 157, + generation: 0, + }, + kind: Value, + }, + SymbolRef { + id: Index { + index: 158, + generation: 0, + }, + kind: Value, + }, ], is_global: false, }, @@ -617,27 +617,13 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 159, + index: 161, generation: 0, }, kind: Value, }, ), attrs: [ - SymbolRef { - id: Index { - index: 128, - generation: 0, - }, - kind: Value, - }, - SymbolRef { - id: Index { - index: 129, - generation: 0, - }, - kind: Value, - }, SymbolRef { id: Index { index: 130, @@ -827,6 +813,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, kind: Value, }, + SymbolRef { + id: Index { + index: 157, + generation: 0, + }, + kind: Value, + }, + SymbolRef { + id: Index { + index: 158, + generation: 0, + }, + kind: Value, + }, ], is_global: false, }, @@ -866,20 +866,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, ), attrs: [ - SymbolRef { - id: Index { - index: 128, - generation: 0, - }, - kind: Value, - }, - SymbolRef { - id: Index { - index: 129, - generation: 0, - }, - kind: Value, - }, SymbolRef { id: Index { index: 130, @@ -1069,6 +1055,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())" }, kind: Value, }, + SymbolRef { + id: Index { + index: 157, + generation: 0, + }, + kind: Value, + }, + SymbolRef { + id: Index { + index: 158, + generation: 0, + }, + kind: Value, + }, ], is_global: false, }, @@ -1101,7 +1101,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 160, + index: 162, generation: 0, }, kind: Value, @@ -1184,4 +1184,4 @@ expression: "format!(\"{:#?}\", p.symbols.values())" attrs: [], is_global: false, }, -] +] \ No newline at end of file diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_0.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_0.snap index 86c22cbd2..5a438aecf 100644 --- a/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_0.snap +++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_0.snap @@ -195,7 +195,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 157, + index: 159, generation: 0, }, kind: Value, diff --git a/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_1.snap b/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_1.snap index 9fb4cebbf..982515c7d 100644 --- a/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_1.snap +++ b/kclvm/loader/src/snapshots/kclvm_loader__tests__import_stmt_1.snap @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())" def: Some( SymbolRef { id: Index { - index: 157, + index: 159, generation: 0, }, kind: Value, diff --git a/kclvm/runtime/src/_kclvm.h b/kclvm/runtime/src/_kclvm.h index e36e0596e..74e7f962a 100644 --- a/kclvm/runtime/src/_kclvm.h +++ b/kclvm/runtime/src/_kclvm.h @@ -316,6 +316,10 @@ kclvm_value_ref_t* kclvm_file_read(kclvm_context_t* ctx, kclvm_value_ref_t* args kclvm_value_ref_t* kclvm_file_workdir(kclvm_context_t* ctx, kclvm_value_ref_t* _args, kclvm_value_ref_t* _kwargs); +kclvm_value_ref_t* kclvm_file_mkdir(kclvm_context_t* ctx, kclvm_value_ref_t* _args, kclvm_value_ref_t* _kwargs); + +kclvm_value_ref_t* kclvm_file_delete(kclvm_context_t* ctx, kclvm_value_ref_t* _args, kclvm_value_ref_t* _kwargs); + kclvm_value_ref_t* kclvm_iterator_cur_key(kclvm_iterator_t* p); kclvm_value_ref_t* kclvm_iterator_cur_value(kclvm_iterator_t* p); diff --git a/kclvm/runtime/src/_kclvm.ll b/kclvm/runtime/src/_kclvm.ll index 96913823d..53a707487 100644 --- a/kclvm/runtime/src/_kclvm.ll +++ b/kclvm/runtime/src/_kclvm.ll @@ -264,6 +264,10 @@ declare %kclvm_value_ref_t* @kclvm_file_read(%kclvm_context_t* %ctx, %kclvm_valu declare %kclvm_value_ref_t* @kclvm_file_workdir(%kclvm_context_t* %ctx, %kclvm_value_ref_t* %_args, %kclvm_value_ref_t* %_kwargs); +declare %kclvm_value_ref_t* @kclvm_file_mkdir(%kclvm_context_t* %ctx, %kclvm_value_ref_t* %_args, %kclvm_value_ref_t* %_kwargs); + +declare %kclvm_value_ref_t* @kclvm_file_delete(%kclvm_context_t* %ctx, %kclvm_value_ref_t* %_args, %kclvm_value_ref_t* %_kwargs); + declare %kclvm_value_ref_t* @kclvm_iterator_cur_key(%kclvm_iterator_t* %p); declare %kclvm_value_ref_t* @kclvm_iterator_cur_value(%kclvm_iterator_t* %p); diff --git a/kclvm/runtime/src/_kclvm.rs b/kclvm/runtime/src/_kclvm.rs index 261faf356..acfabb00b 100644 --- a/kclvm/runtime/src/_kclvm.rs +++ b/kclvm/runtime/src/_kclvm.rs @@ -143,6 +143,8 @@ pub enum ApiFunc { kclvm_file_modpath, kclvm_file_read, kclvm_file_workdir, + kclvm_file_mkdir, + kclvm_file_delete, kclvm_iterator_cur_key, kclvm_iterator_cur_value, kclvm_iterator_delete, diff --git a/kclvm/runtime/src/_kclvm_addr.rs b/kclvm/runtime/src/_kclvm_addr.rs index 5fde102c0..c8895c53f 100644 --- a/kclvm/runtime/src/_kclvm_addr.rs +++ b/kclvm/runtime/src/_kclvm_addr.rs @@ -144,6 +144,8 @@ pub fn _kclvm_get_fn_ptr_by_name(name: &str) -> u64 { "kclvm_dict_values" => crate::kclvm_dict_values as *const () as u64, "kclvm_file_abs" => crate::kclvm_file_abs as *const () as u64, "kclvm_file_exists" => crate::kclvm_file_exists as *const () as u64, + "kclvm_file_mkdir" => crate::kclvm_file_mkdir as *const () as u64, + "kclvm_file_delete" => crate::kclvm_file_delete as *const () as u64, "kclvm_file_glob" => crate::kclvm_file_glob as *const () as u64, "kclvm_file_modpath" => crate::kclvm_file_modpath as *const () as u64, "kclvm_file_read" => crate::kclvm_file_read as *const () as u64, diff --git a/kclvm/runtime/src/_kclvm_api_spec.rs b/kclvm/runtime/src/_kclvm_api_spec.rs index 18bca4ce0..b01b435a1 100644 --- a/kclvm/runtime/src/_kclvm_api_spec.rs +++ b/kclvm/runtime/src/_kclvm_api_spec.rs @@ -1222,6 +1222,14 @@ // api-spec(c): kclvm_value_ref_t* kclvm_file_abs(kclvm_context_t* ctx, kclvm_value_ref_t* args, kclvm_value_ref_t* kwargs); // api-spec(llvm): declare %kclvm_value_ref_t* @kclvm_file_abs(%kclvm_context_t* %ctx, %kclvm_value_ref_t* %args, %kclvm_value_ref_t* %kwargs); +// api-spec: kclvm_file_mkdir +// api-spec(c): kclvm_value_ref_t* kclvm_file_mkdir(kclvm_context_t* ctx, kclvm_value_ref_t* args, kclvm_value_ref_t* kwargs); +// api-spec(llvm): declare %kclvm_value_ref_t* @kclvm_file_mkdir(%kclvm_context_t* %ctx, %kclvm_value_ref_t* %args, %kclvm_value_ref_t* %kwargs); + +// api-spec: kclvm_file_delete +// api-spec(c): kclvm_value_ref_t* kclvm_file_delete(kclvm_context_t* ctx, kclvm_value_ref_t* args, kclvm_value_ref_t* kwargs); +// api-spec(llvm): declare %kclvm_value_ref_t* @kclvm_file_delete(%kclvm_context_t* %ctx, %kclvm_value_ref_t* %args, %kclvm_value_ref_t* %kwargs); + // api-spec: kclvm_template_execute // api-spec(c): kclvm_value_ref_t* kclvm_template_execute(kclvm_context_t* ctx, kclvm_value_ref_t* args, kclvm_value_ref_t* kwargs); // api-spec(llvm): declare %kclvm_value_ref_t* @kclvm_template_execute(%kclvm_context_t* %ctx, %kclvm_value_ref_t* %args, %kclvm_value_ref_t* %kwargs); diff --git a/kclvm/runtime/src/file/mod.rs b/kclvm/runtime/src/file/mod.rs index 7ed4aa512..fbd0ea374 100644 --- a/kclvm/runtime/src/file/mod.rs +++ b/kclvm/runtime/src/file/mod.rs @@ -120,3 +120,55 @@ pub extern "C" fn kclvm_file_abs( panic!("read() takes exactly one argument (0 given)"); } + +#[no_mangle] +#[runtime_fn] +pub extern "C" fn kclvm_file_mkdir( + ctx: *mut kclvm_context_t, + args: *const kclvm_value_ref_t, + kwargs: *const kclvm_value_ref_t, +) -> *const kclvm_value_ref_t { + let args = ptr_as_ref(args); + let kwargs = ptr_as_ref(kwargs); + let ctx = mut_ptr_as_ref(ctx); + + if let Some(path) = get_call_arg_str(args, kwargs, 0, Some("directory")) { + if let Err(e) = fs::create_dir(&path) { + panic!("Failed to create directory '{}': {}", path, e); + } + return ValueRef::none().into_raw(ctx); + } + + panic!("mkdir() takes exactly one argument (0 given)"); +} + +#[no_mangle] +#[runtime_fn] +pub extern "C" fn kclvm_file_delete( + ctx: *mut kclvm_context_t, + args: *const kclvm_value_ref_t, + kwargs: *const kclvm_value_ref_t, +) -> *const kclvm_value_ref_t { + let args = ptr_as_ref(args); + let kwargs = ptr_as_ref(kwargs); + let ctx = mut_ptr_as_ref(ctx); + + if let Some(path) = get_call_arg_str(args, kwargs, 0, Some("filepath")) { + if let Err(e) = fs::remove_file(&path) { + match e.kind() { + std::io::ErrorKind::NotFound => { + // if file not found, try to remove it as a directory + if let Err(e) = fs::remove_dir(&path) { + panic!("failed to delete '{}': {}", path, e); + } + } + _ => { + panic!("failed to delete '{}': {}", path, e); + } + } + } + return ValueRef::none().into_raw(ctx); + } + + panic!("delete() takes exactly one argument (0 given)"); +} diff --git a/kclvm/sema/src/builtin/system_module.rs b/kclvm/sema/src/builtin/system_module.rs index 52a0aa04b..62bc3facf 100644 --- a/kclvm/sema/src/builtin/system_module.rs +++ b/kclvm/sema/src/builtin/system_module.rs @@ -1638,6 +1638,34 @@ register_file_member! { false, None, ) + mkdir => Type::function( + None, + Type::any_ref(), + &[ + Parameter { + name: "directory".to_string(), + ty: Type::str_ref(), + has_default: false, + }, + ], + r#"Create a new directory at the specified path if it doesn't already exist."#, + false, + None, + ) + delete => Type::function( + None, + Type::any_ref(), + &[ + Parameter { + name: "filepath".to_string(), + ty: Type::str_ref(), + has_default: false, + }, + ], + r#"Delete a file or an empty directory at the specified path."#, + false, + None, + ) } // ------------------------------ diff --git a/test/grammar/builtins/file/delete/main.k b/test/grammar/builtins/file/delete/main.k new file mode 100644 index 000000000..92a78886b --- /dev/null +++ b/test/grammar/builtins/file/delete/main.k @@ -0,0 +1,6 @@ +import file + +file.delete("test_dir") + + + diff --git a/test/grammar/builtins/file/delete/stderr.golden b/test/grammar/builtins/file/delete/stderr.golden new file mode 100644 index 000000000..564eba2a0 --- /dev/null +++ b/test/grammar/builtins/file/delete/stderr.golden @@ -0,0 +1 @@ +delete: failed to delete 'test_dir': No such file or directory diff --git a/test/grammar/builtins/file/delete/stdout.golden b/test/grammar/builtins/file/delete/stdout.golden new file mode 100644 index 000000000..9ffb6d96b --- /dev/null +++ b/test/grammar/builtins/file/delete/stdout.golden @@ -0,0 +1 @@ +delete: '' diff --git a/test/grammar/builtins/file/mkdir/main.k b/test/grammar/builtins/file/mkdir/main.k new file mode 100644 index 000000000..d27fd493c --- /dev/null +++ b/test/grammar/builtins/file/mkdir/main.k @@ -0,0 +1,3 @@ +import file + +file.mkdir("test_dir") diff --git a/test/grammar/builtins/file/mkdir/stderr.golden b/test/grammar/builtins/file/mkdir/stderr.golden new file mode 100644 index 000000000..48ea2caa4 --- /dev/null +++ b/test/grammar/builtins/file/mkdir/stderr.golden @@ -0,0 +1,2 @@ +mkdir: failed to create directory 'test_dir': File exists + diff --git a/test/grammar/builtins/file/mkdir/stdout.golden b/test/grammar/builtins/file/mkdir/stdout.golden new file mode 100644 index 000000000..7069422ef --- /dev/null +++ b/test/grammar/builtins/file/mkdir/stdout.golden @@ -0,0 +1 @@ +mkdir: ''