From b518b06d75b56b4ec2e6fec93d79d8c3bc934130 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 3 Dec 2019 22:05:05 -0800 Subject: [PATCH] Lua test program is loaded successfully. --- tests/bindings/lua/main.c | 8 +++++++- tests/bindings/lua/test_upb.lua | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/bindings/lua/main.c b/tests/bindings/lua/main.c index 8a30d06d3d..379e6ded20 100644 --- a/tests/bindings/lua/main.c +++ b/tests/bindings/lua/main.c @@ -5,13 +5,19 @@ #include "upb/bindings/lua/upb.h" +const char *init = + "package.preload['lupb'] = ... " + "package.path = './?.lua;./third_party/lunit/?.lua'"; + int main() { int ret = 0; lua_State *L = luaL_newstate(); luaL_openlibs(L); lua_pushcfunction(L, luaopen_lupb); + ret = luaL_loadstring(L, init); + lua_pushcfunction(L, luaopen_lupb); - if (luaL_dostring(L, "package.preload['lupb'] = ...[1]") || + if (ret || lua_pcall(L, 1, LUA_MULTRET, 0) || luaL_dofile(L, "tests/bindings/lua/test_upb.lua")) { fprintf(stderr, "error testing Lua: %s\n", lua_tostring(L, -1)); ret = 1; diff --git a/tests/bindings/lua/test_upb.lua b/tests/bindings/lua/test_upb.lua index e4edda4003..0583aa9341 100644 --- a/tests/bindings/lua/test_upb.lua +++ b/tests/bindings/lua/test_upb.lua @@ -1,5 +1,5 @@ -local upb = require "upb" +local upb = require "lupb" local lunit = require "lunit" if _VERSION >= 'Lua 5.2' then