diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-12-17 21:58:31 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-12-17 22:23:17 -0800 |
commit | 92fe487349d2903e2fd118215547fe2db1f8739f (patch) | |
tree | ad08f9f554b562bf0c5575258654d1b358da8b57 | |
parent | 580501b34210afa5c7685095aa530f272eb6e57c (diff) | |
download | teliva-92fe487349d2903e2fd118215547fe2db1f8739f.tar.gz |
experimental support for test errors
-rw-r--r-- | src/lua.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lua.c b/src/lua.c index 6fdcf41..94964cb 100644 --- a/src/lua.c +++ b/src/lua.c @@ -336,10 +336,15 @@ int run_tests(lua_State *L) { if (strncmp("test_", key, strlen("test_")) != 0) continue; if (!lua_isfunction(L, -1)) continue; int status = lua_pcall(L, 0, 0, 0); - if (status) + if (status) { printf("E%d: %s\n", status, lua_tostring(L, -1)); - else - lua_pushnil(L); /* just to undo loop update */ + lua_getglobal(L, "teliva_first_failure"); + int first_failure_clear = lua_isnil(L, -1); + lua_pop(L, 1); + if (first_failure_clear) + lua_setglobal(L, "teliva_first_failure"); + } + lua_pushnil(L); /* just to undo loop update */ } lua_pop(L, 1); lua_getglobal(L, "teliva_num_test_failures"); |