aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Melnichuk <alexeymelnichuck@gmail.com>2018-09-05 07:59:44 +0300
committerGitHub <noreply@github.com>2018-09-05 07:59:44 +0300
commit53adf5621d285952d6f56be889262127741c26cb (patch)
tree1d626db1933134cc1f127d526ad5cdb30a9775b0
parent00ca97711b657c7d395d91212364a82dac1d4625 (diff)
parentd534bfc9586c1260d3255f949b7aa6f48511af3a (diff)
downloadlua-llthreads2-53adf5621d285952d6f56be889262127741c26cb.tar.gz
lua-llthreads2-53adf5621d285952d6f56be889262127741c26cb.tar.bz2
lua-llthreads2-53adf5621d285952d6f56be889262127741c26cb.zip
Merge pull request #17 from osch/master
avoid NULL as parameter to fputs()
-rw-r--r--.travis.yml1
-rw-r--r--appveyor.yml1
-rw-r--r--lakefile1
-rw-r--r--src/llthread.c2
-rw-r--r--test/test_error.lua41
5 files changed, 46 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
index 19f6f5b..1f52bf6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -58,6 +58,7 @@ script:
58 - lua test_threads_attr.lua 58 - lua test_threads_attr.lua
59 - lua test_integer.lua 59 - lua test_integer.lua
60 - lua test_interrupt.lua 60 - lua test_interrupt.lua
61 - lua test_error.lua
61 # - lua test_register_llthreads.lua 62 # - lua test_register_llthreads.lua
62 63
63notifications: 64notifications:
diff --git a/appveyor.yml b/appveyor.yml
index 46a3235..b405930 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -73,6 +73,7 @@ test_script:
73 - lua test_threads_attr.lua 73 - lua test_threads_attr.lua
74 - lua test_integer.lua 74 - lua test_integer.lua
75 - lua test_interrupt.lua 75 - lua test_interrupt.lua
76 - lua test_error.lua
76 # - lua test_register_llthreads.lua 77 # - lua test_register_llthreads.lua
77 78
78after_test: 79after_test:
diff --git a/lakefile b/lakefile
index af9661e..a5cb006 100644
--- a/lakefile
+++ b/lakefile
@@ -45,6 +45,7 @@ target('test', install, function()
45 run_test('test_threads_ex_opt_2.lua') 45 run_test('test_threads_ex_opt_2.lua')
46 run_test('test_threads_attr.lua') 46 run_test('test_threads_attr.lua')
47 run_test('test_interrupt.lua') 47 run_test('test_interrupt.lua')
48 run_test('test_error.lua')
48 49
49 50
50 if not test_summary() then 51 if not test_summary() then
diff --git a/src/llthread.c b/src/llthread.c
index 66efe7c..a3b3216 100644
--- a/src/llthread.c
+++ b/src/llthread.c
@@ -132,6 +132,8 @@ static int fail(lua_State *L, const char *msg){
132void llthread_log(lua_State *L, const char *hdr, const char *msg){ 132void llthread_log(lua_State *L, const char *hdr, const char *msg){
133 int top = lua_gettop(L); 133 int top = lua_gettop(L);
134 lua_rawgetp(L, LUA_REGISTRYINDEX, LLTHREAD_LOGGER_HOLDER); 134 lua_rawgetp(L, LUA_REGISTRYINDEX, LLTHREAD_LOGGER_HOLDER);
135 if (!msg)
136 msg = "(no error message)";
135 if(lua_isnil(L, -1)){ 137 if(lua_isnil(L, -1)){
136 lua_pop(L, 1); 138 lua_pop(L, 1);
137 fputs(hdr, stderr); 139 fputs(hdr, stderr);
diff --git a/test/test_error.lua b/test/test_error.lua
new file mode 100644
index 0000000..341105e
--- /dev/null
+++ b/test/test_error.lua
@@ -0,0 +1,41 @@
1local llthreads = require"llthreads"
2local utils = require "utils"
3
4local include = utils.thread_init .. [[
5local llthreads = require"llthreads"
6]]
7
8do
9 local thread = llthreads.new(include .. [[
10 error({})
11 ]])
12
13 thread:start()
14 local ok, err = thread:join()
15 print(ok, err)
16 assert(not ok)
17end
18do
19 local thread = llthreads.new(include .. [[
20 llthreads.set_logger(function(msg) print("XXX", msg) end)
21 error({})
22 ]])
23
24 thread:start()
25 local ok, err = thread:join()
26 print(ok, err)
27 assert(not ok)
28end
29do
30 local thread = llthreads.new(include .. [[
31 llthreads.set_logger(function(msg) end)
32 error({})
33 ]])
34
35 thread:start()
36 local ok, err = thread:join()
37 print(ok, err)
38 assert(not ok)
39end
40print("Done!")
41