OpenResty??????????
?????spacewander ???????[ 2016/10/25 15:31:41 ] ??????????????? OpenResty ???????
?????????????????г??????е??????????????????????????????????Э???????????У??????????????????? OpenResty ????????????????????
??????????
???????????? OpenResty ?????????? test-nginx???????????????????в??????????????????????????????????
?????? lua ?????????busted?????????????????????? OpenResty ????????????????? OpenResty ?? API??
????????????? OpenResty ???????????в?????????Щ API ??????á????????????????Щ API ?????????????? mock ???
?????????????????
???????? OpenResty ???? resty ?????й???????????????????????? OpenResty ?????????и????? lua ????
??????? resty ?? busted ?????????????????????? OpenResty ???????????? busted ????????
???????????????? lua5.1 ????? luarocks??luarocks ???? lua ?汾?? 5.2?? ????????????????????????????????????????????e?? OpenResty ??????? luajit??????????
????./configure --with-lua="/usr/" --lua-suffix="jit" --with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1/
??????? sudo luarocks install busted?? ??? busted??
???????????й??? busted ???????????????????????????
????#!/usr/bin/env lua
????-- Busted command-line runner
????require 'busted.runner'({ standalone = false })
????OK???????? resty ?????????????
????????????????£?
????..
?????????? src
?????? ?????? code.lua
?????????? test
?????????? test_spec.lua
??????????????????У?
????resty -I ../src -e 'require "busted.runner"({ standalone = false })' -- --verbose test_spec.lua
?????????£?-I ?????????????? lua ????·????-e ?????????????????е??????Σ?--
???????????????????????????????????? busted --verbose test_spec.lua??
??????? resty ?????? lua ???????????????????? ngx.timer ???????????д????????????????????????? OpenResty API
??????????????????????????????????????????????? ngx.location.capture????в????????????????
????Error → test_spec.lua @ 7
????topic feature
????test_spec.lua:15: API disabled in the current context
??????????????????????????????????????????????????????????????????????????? mock ?????????? mock????????busted ???????ο? busted ???????
???????????
??????????????????????????????????
?????????о??????????????????????????????д?????????Щ????????????????????
???????????????????????????????
????????????????????????????????????????????????????????????????????????д?????
????????????????????????????????????????????????????????????????????????ò????????????????????????????????
?????? lua ????????? luacov ???????????????????
?????????????????? luacov ???????????м???????????????????????????luacov ???????????????????
????luacov.stats.out ????С?
????busted????????? luacov ??????????????????????????
????????????? busted ??????? --coverage ???
????resty -I ../src -e 'require "busted.runner"({ standalone = false })' -- --coverage --verbose test_spec.lua
????????? luacov ???д????????棬??????? .luacov ???????
????tick = true
????????????????????????????????????????? luacov ???????????????д??????棬??????? openresty
???????????????????е???????? tick = true ??luacov ????????????檔???? tick?????????? .luacov
????????????? luacov ?????????
????http://keplerproject.github.i...
???????????????? luacov.stats.out ?????????????
????127:/usr/local/share/lua/5.1/busted/init.lua
????0 0 0 0 4 8 4 0 4 4 0 0 10 20 10 0 10 10 0 0 36 36 0 72 0 0 0 0 36 0 36 36 36 0 36 0 36 36 72 72 36 0 0 0 0 0 0 72 0 0 36 36 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
????0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 92
????49:/usr/local/share/lua/5.1/busted/languages/en.lua
????1 0 1 0 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1
????23:/usr/local/share/lua/5.1/busted/modules/files/lua.lua
????1 0 1 0 0 50 100 50 1 0 0 8 1 0 0 4 4 0 0 4 1 0 1
????107:/usr/local/share/lua/5.1/busted/modules/files/moonscript.lua
????1 0 2 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
????0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 1
????...
?????????????????????????汾??
???????????? luacov YOUR_SRC_DIR ????????? luacov.report.out ??
????????????????????????棺
????...
????****0 for c?? v in pairs(colorvalues) do
????****0 colors[c] = makecolor(v)
????end
????****0 return colors
????==============================================================================
????Summary
????==============================================================================
????File Hits Missed Coverage
????...
??????????????????“?????????”??????? luacov ?????????????????????????????? reporter??
????https://github.com/keplerproj...
??????????????????????????????? reporter ?????
????????????????????????luacov ???? reporter ???
????????????·???д??????????????? luacov.report.out ??????棬??????????????汾??????????е? CI ????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11