diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-04-06 20:24:23 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-04-07 15:12:51 +0200 |
commit | 7d7e95006fa70e3f348ce118e756207d57040d93 (patch) | |
tree | 4a71cabb1e4a18c47fb604e9974ff51d32aa35b6 | |
parent | df6b86173c4979aea636907b8f3fb4d0c855ea94 (diff) |
main: abort when failing to load a preload library
Do not continue loading other libraries or executing the main code if
loading one of the preload libraries fails.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | tests/cram/test_basic.t | 6 |
2 files changed, 9 insertions, 5 deletions
@@ -435,7 +435,7 @@ parse_library_load(char *opt, uc_vm_t *vm) ucv_put(lib); if (!ctx) - return false; + return vm->exception.type == EXCEPTION_NONE; ucv_object_add(uc_vm_scope_get(vm), name ? name : p, ctx); @@ -557,7 +557,11 @@ main(int argc, char **argv) break; case 'l': - parse_library_load(optarg, &vm); + if (!parse_library_load(optarg, &vm)) { + rv = 1; + goto out; + } + break; case 'c': diff --git a/tests/cram/test_basic.t b/tests/cram/test_basic.t index b85167f..7308002 100644 --- a/tests/cram/test_basic.t +++ b/tests/cram/test_basic.t @@ -79,19 +79,19 @@ check that ucode prints greetings: check that ucode provides proper error messages: - $ ucode -l foo + $ touch lib.uc; ucode -l lib Require either -e expression or source file [1] $ ucode -l foo -e ' ' Runtime error: No module named 'foo' could be found - [254] + [1] $ touch moo; ucode -l foo moo Runtime error: No module named 'foo' could be found - [254] + [1] check that ucode can load fs module: |