[grilo-plugins] lua-factory: fix syntax-check for lua-sources



commit 3c0e9a059cfc8f5fd5f69e11450014597559f1e9
Author: Victor Toso <me victortoso com>
Date:   Thu May 19 22:43:13 2016 +0200

    lua-factory: fix syntax-check for lua-sources
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764078

 src/lua-factory/grl-lua-library-operations.c       |   16 +++++++++++-----
 tests/lua-factory/test_lua_factory_source_errors.c |    5 +----
 2 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/lua-factory/grl-lua-library-operations.c b/src/lua-factory/grl-lua-library-operations.c
index 7b0397a..7bad46d 100644
--- a/src/lua-factory/grl-lua-library-operations.c
+++ b/src/lua-factory/grl-lua-library-operations.c
@@ -686,6 +686,8 @@ grl_lua_operations_pcall (lua_State *L,
                           OperationSpec *os,
                           GError **err)
 {
+  gint ret;
+
   g_assert_nonnull (os);
   g_assert_nonnull (err);
   g_assert_null (*err);
@@ -701,16 +703,20 @@ grl_lua_operations_pcall (lua_State *L,
 
   watchdog_operation_push (L, os->operation_id);
   grl_lua_operations_set_source_state (L, LUA_SOURCE_RUNNING, os);
-  if (lua_pcall (L, nargs + 1, 0, 0)) {
-    *err = g_error_new_literal (GRL_CORE_ERROR,
-                                os->error_code,
-                                lua_tolstring (L, -1, NULL));
+
+  ret = lua_pcall (L, nargs + 1, 0, 0);
+  if (ret != LUA_OK) {
+    const gchar *msg = lua_tolstring (L, -1, NULL);
     lua_pop (L, 1);
+
+    GRL_DEBUG ("lua_pcall failed: due %s (err %d)", msg, ret);
+    *err = g_error_new_literal (GRL_CORE_ERROR, os->error_code, msg);
+    grl_lua_operations_set_source_state (L, LUA_SOURCE_FINALIZED, os);
   }
 
   lua_gc (L, LUA_GCCOLLECT, 0);
   lua_gc (L, LUA_GCRESTART, 0);
-  return (*err == NULL);
+  return (ret == LUA_OK);
 }
 
 /*
diff --git a/tests/lua-factory/test_lua_factory_source_errors.c 
b/tests/lua-factory/test_lua_factory_source_errors.c
index 0f521a3..f47ebbb 100644
--- a/tests/lua-factory/test_lua_factory_source_errors.c
+++ b/tests/lua-factory/test_lua_factory_source_errors.c
@@ -139,10 +139,7 @@ test_correct_state_on_multiple_fetch (void)
 static void
 test_callback_after_end_of_operation (void)
 {
-  g_test_expect_message("Grilo", G_LOG_LEVEL_WARNING,
-      "*is on FINALIZED state and cannot be changed*");
-  g_test_expect_message("Grilo", G_LOG_LEVEL_WARNING,
-      "*Source is broken as callback was called after the operation has been finalized*");
+  g_test_expect_message("Grilo", G_LOG_LEVEL_WARNING, "*Can't retrieve current operation*");
   execute_resolve_test (TEST_CALLBACK_ON_FINISHED_OP);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]