Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot be run in Resty CLI #11

Open
turbo opened this issue Oct 23, 2019 · 2 comments
Open

Cannot be run in Resty CLI #11

turbo opened this issue Oct 23, 2019 · 2 comments

Comments

@turbo
Copy link

turbo commented Oct 23, 2019

I use resty to run unit tests against an openresty project, but any files which require this shell module will fail with this message:

Error → /usr/local/openresty/lualib/ngx/pipe.lua @ 500
suite ./spec/util_spec.lua
/usr/local/openresty/lualib/ngx/pipe.lua:500: cannot change a protected metatable

stack traceback:
	/usr/local/openresty/lualib/ngx/pipe.lua:500: in main chunk

The fact that this is a test doesn't matter, even a simple require will crash the script. The trace points to this line:

local Proc = ffi.metatype("ngx_http_lua_ffi_pipe_proc_t", mt)
@Gerrard-YNWA
Copy link

hello, I also ran into this issue while writing unit test with resty cli and busted test framework,here is a minimial case:
prepare two unit test file spec/ dir simply require resty-shell lib and busted runner:
spec/1_spec.lua

describe("ut 1", function()
    it("ut 1", function()
        require("resty.shell")
    end)
end)

spec/2_spec.lua

describe("ut 2", function()
    it("ut 2", function()
        require("resty.shell")
    end)
end)

spec/busted_runner.lua

setmetatable(_G, nil)
require 'busted.runner'({standalone = false })

run the two test file with resty cli as follow:

/usr/local/openresty/bin/resty spec/busted_runner.lua -v spec/

the second file 2_spec.lua aborted with error:

[gerrard@gerrard ~]$ /usr/local/openresty/bin/resty spec/busted_runner.lua -v spec/
●✱
1 success / 0 failures / 1 error / 0 pending : 0.001975 seconds

Error → spec/2_spec.lua @ 16
ut 2 ut 2
/usr/local/openresty/lualib/ngx/pipe.lua:500: cannot change a protected metatable

stack traceback:
	/usr/local/openresty/lualib/ngx/pipe.lua:500: in main chunk

envirment on centos7:

[gerrard@gerrard ~]$ busted --version
2.0.0-0
[gerrard@gerrard ~]$ /usr/local/openresty/bin/resty  -v
resty 0.23
nginx version: openresty/1.15.8.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.1rc1 --add-module=../echo-nginx-module-0.61 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.15 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.7 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_ssl_module

@Gerrard-YNWA
Copy link

Gerrard-YNWA commented Apr 26, 2021

Use this patch lunarmodules/busted#631 resolves my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants