安裝目錄linux
假設安裝目錄爲 /home/user/soft/git
$ export PATH=/home/user/soft/lua:$PATH $ cd /home/user/soft/ $ curl -R -O http://www.lua.org/ftp/lua-5.3.4.tar.gz $ tar zxf lua-5.3.4.tar.gz $ mv lua-5.3.4 lua $ cd lua $ make linux install INSTALL_TOP=../ $ lua
$ cd /home/user/soft/lua $ export PATH=/home/user/soft/lua:$PATH $ wget http://luarocks.org/releases/luarocks-2.4.2.tar.gz $ tar zxpf luarocks-2.4.2.tar.gz $ cd luarocks-2.4.2 $ export prefix=$(dirname $(dirname $(which lua))) $ ./configure --prefix=$prefix --sysconfdir=$prefix/luarocks --force-config --with-lua=$prefix $ make bootstrap $ luarocks
$ mkdir rocktest $ cd rocktest && mkdir -p src/spec $ luarocks write_rockspec --lua-version=5.3 rocktest 1.0.0 ./ # 上面這裏是新建了一個.rockspec配置文件,rocktest項目名稱,1.0.0版本號 $ touch src/first.lua && echo "print('hello');return {}" > src/first.lua $ vim *.rockspec # 若是要構建庫 modules = {first = "src/first.lua"} # 若是要構建可執行文件: ,install = { bin = { ['sometest'] = 'bin/sometest' } } $ mkdir bin && echo "require 'first' " > bin/sometest $ luarocks make
$ luarocks install busted $ touch rocktest/spec/test_spec.lua #以 _spec結尾
describe('Tests the busted pending functions through the commandline', function() it('is a test with a pending', function() pending('finish this test later') error('should never get here') end) pending('is a pending inside a describe', function() it('this test does not run', function() error('this should not run') end) end) end)
測試用例github
開始測試bootstrap
$ busted