diff options
| author | Hisham <hisham@gobolinux.org> | 2016-10-14 16:38:51 -0700 |
|---|---|---|
| committer | Hisham <hisham@gobolinux.org> | 2016-10-14 16:38:51 -0700 |
| commit | 075196e8b5d315888a8ae110fa9a18089044ae3b (patch) | |
| tree | eca3eb78c23f8d85dbe625564a2d66966d6281f1 | |
| parent | dbca97cdcc15e386554b2631a0ae7aca02500abf (diff) | |
| parent | 1fea0e3a0972bcc6b4319cd3d9e79834562486bc (diff) | |
| download | luarocks-075196e8b5d315888a8ae110fa9a18089044ae3b.tar.gz luarocks-075196e8b5d315888a8ae110fa9a18089044ae3b.tar.bz2 luarocks-075196e8b5d315888a8ae110fa9a18089044ae3b.zip | |
Merge branch 'master' into luarocks-3
34 files changed, 780 insertions, 781 deletions
diff --git a/.appveyor/build.bat b/.appveyor/build.bat deleted file mode 100644 index a4ff6378..00000000 --- a/.appveyor/build.bat +++ /dev/null | |||
| @@ -1,111 +0,0 @@ | |||
| 1 | @echo off | ||
| 2 | Setlocal EnableDelayedExpansion EnableExtensions | ||
| 3 | |||
| 4 | cd %APPVEYOR_BUILD_FOLDER% | ||
| 5 | |||
| 6 | :: ========================================================= | ||
| 7 | :: Make sure some environment variables are set | ||
| 8 | if not defined LUA_VER call :die LUA_VER is not defined | ||
| 9 | if not defined LUA call :die LUA is not defined | ||
| 10 | if not defined LUA_SHORTV call :die LUA_SHORTV is not defined | ||
| 11 | if not defined LUA_DIR call :die LUA_DIR is not defined | ||
| 12 | |||
| 13 | :: ========================================================= | ||
| 14 | :: Set some defaults. Infer some variables. | ||
| 15 | :: | ||
| 16 | if not defined LUAROCKS_VER set LUAROCKS_VER=2.2.1 | ||
| 17 | |||
| 18 | set LUAROCKS_SHORTV=%LUAROCKS_VER:~0,3% | ||
| 19 | |||
| 20 | if not defined LR_EXTERNAL set LR_EXTERNAL=c:\external | ||
| 21 | if not defined LR_ROOT set LR_ROOT=%LUA_DIR%\LuaRocks | ||
| 22 | if not defined LR_SYSTREE set LR_SYSTREE=%LR_ROOT%\systree | ||
| 23 | |||
| 24 | :: | ||
| 25 | :: ========================================================= | ||
| 26 | |||
| 27 | |||
| 28 | if not exist %LUA_DIR%\bin\%LUA%.exe call :die "Missing Lua interpreter at %LUA_DIR%\bin\%LUA%.exe" | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | :: ========================================================= | ||
| 33 | :: LuaRocks | ||
| 34 | :: ========================================================= | ||
| 35 | |||
| 36 | cd %APPVEYOR_BUILD_FOLDER% | ||
| 37 | call install.bat /LUA %LUA_DIR% /Q /LV %LUA_SHORTV% /P "%LR_ROOT%" /TREE "%LR_SYSTREE%" | ||
| 38 | |||
| 39 | if not exist "%LR_ROOT%" call :die "LuaRocks not found at %LR_ROOT%" | ||
| 40 | |||
| 41 | set PATH=%LR_ROOT%;%LR_SYSTREE%\bin;%PATH% | ||
| 42 | |||
| 43 | :: Lua will use just the system rocks | ||
| 44 | set LUA_PATH=%LR_ROOT%\lua\?.lua;%LR_ROOT%\lua\?\init.lua | ||
| 45 | set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?.lua | ||
| 46 | set LUA_PATH=%LUA_PATH%;%LR_SYSTREE%\share\lua\%LUA_SHORTV%\?\init.lua | ||
| 47 | set LUA_CPATH=%LR_SYSTREE%\lib\lua\%LUA_SHORTV%\?.dll | ||
| 48 | |||
| 49 | call luarocks --version || call :die "Error with LuaRocks installation" | ||
| 50 | call luarocks list | ||
| 51 | |||
| 52 | |||
| 53 | if not exist "%LR_EXTERNAL%" ( | ||
| 54 | mkdir "%LR_EXTERNAL%" | ||
| 55 | mkdir "%LR_EXTERNAL%\lib" | ||
| 56 | mkdir "%LR_EXTERNAL%\include" | ||
| 57 | ) | ||
| 58 | |||
| 59 | set PATH=%LR_EXTERNAL%;%PATH% | ||
| 60 | |||
| 61 | :: Exports the following variables: | ||
| 62 | :: (beware of whitespace between & and ^ below) | ||
| 63 | endlocal & set PATH=%PATH%&^ | ||
| 64 | set LR_SYSTREE=%LR_SYSTREE%&^ | ||
| 65 | set LUA_PATH=%LUA_PATH%&^ | ||
| 66 | set LUA_CPATH=%LUA_CPATH%&^ | ||
| 67 | set LR_EXTERNAL=%LR_EXTERNAL% | ||
| 68 | |||
| 69 | echo. | ||
| 70 | echo ====================================================== | ||
| 71 | echo Installation of LuaRocks %LUAROCKS_VER% done. | ||
| 72 | echo . | ||
| 73 | echo LUA_PATH - %LUA_PATH% | ||
| 74 | echo LUA_CPATH - %LUA_CPATH% | ||
| 75 | echo. | ||
| 76 | echo LR_EXTERNAL - %LR_EXTERNAL% | ||
| 77 | echo ====================================================== | ||
| 78 | echo. | ||
| 79 | |||
| 80 | goto :eof | ||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | |||
| 90 | |||
| 91 | |||
| 92 | |||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | |||
| 99 | :: This blank space is intentional. If you see errors like "The system cannot find the batch label specified 'foo'" | ||
| 100 | :: then try adding or removing blank lines lines above. | ||
| 101 | :: Yes, really. | ||
| 102 | :: http://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e | ||
| 103 | |||
| 104 | :: helper functions: | ||
| 105 | |||
| 106 | :: for bailing out when an error occurred | ||
| 107 | :die %1 | ||
| 108 | echo %1 | ||
| 109 | exit /B 1 | ||
| 110 | goto :eof | ||
| 111 | |||
diff --git a/.appveyor/install.bat b/.appveyor/install.bat deleted file mode 100644 index a2aefdd2..00000000 --- a/.appveyor/install.bat +++ /dev/null | |||
| @@ -1,154 +0,0 @@ | |||
| 1 | @echo off | ||
| 2 | |||
| 3 | cd %APPVEYOR_BUILD_FOLDER% | ||
| 4 | |||
| 5 | :: ========================================================= | ||
| 6 | :: Set some defaults. Infer some variables. | ||
| 7 | :: | ||
| 8 | :: These are set globally | ||
| 9 | if "%LUA_VER%" NEQ "" ( | ||
| 10 | set LUA=lua | ||
| 11 | set LUA_SHORTV=%LUA_VER:~0,3% | ||
| 12 | ) else ( | ||
| 13 | set LUA=luajit | ||
| 14 | set LJ_SHORTV=%LJ_VER:~0,3% | ||
| 15 | set LUA_SHORTV=5.1 | ||
| 16 | ) | ||
| 17 | |||
| 18 | :: unless we specify a platform on appveyor.yaml, we won't get this variable | ||
| 19 | if not defined platform set platform=x86 | ||
| 20 | |||
| 21 | :: defines LUA_DIR so Cmake can find this Lua install | ||
| 22 | if "%LUA%"=="luajit" ( | ||
| 23 | set LUA_DIR=c:\lua\%platform%\lj%LJ_SHORTV% | ||
| 24 | ) else ( | ||
| 25 | set LUA_DIR=c:\lua\%platform%\%LUA_VER% | ||
| 26 | ) | ||
| 27 | |||
| 28 | :: Now we declare a scope | ||
| 29 | Setlocal EnableDelayedExpansion EnableExtensions | ||
| 30 | |||
| 31 | if not defined LUA_URL set LUA_URL=http://www.lua.org/ftp | ||
| 32 | if not defined LUAJIT_GIT_REPO set LUAJIT_GIT_REPO=http://luajit.org/git/luajit-2.0.git | ||
| 33 | if not defined LUAJIT_URL set LUAJIT_URL=http://luajit.org/download | ||
| 34 | |||
| 35 | if not defined SEVENZIP set SEVENZIP=7z | ||
| 36 | :: | ||
| 37 | :: ========================================================= | ||
| 38 | |||
| 39 | :: first create some necessary directories: | ||
| 40 | mkdir downloads 2>NUL | ||
| 41 | |||
| 42 | :: Download and compile Lua (or LuaJIT) | ||
| 43 | if "%LUA%"=="luajit" ( | ||
| 44 | if not exist %LUA_DIR% ( | ||
| 45 | if "%LJ_SHORTV%"=="2.1" ( | ||
| 46 | :: Clone repository and checkout 2.1 branch | ||
| 47 | set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER% | ||
| 48 | if not exist !lj_source_folder! ( | ||
| 49 | echo Cloning git repo %LUAJIT_GIT_REPO% !lj_source_folder! | ||
| 50 | git clone %LUAJIT_GIT_REPO% !lj_source_folder! || call :die "Failed to clone repository" | ||
| 51 | ) | ||
| 52 | cd !lj_source_folder!\src | ||
| 53 | git checkout v2.1 || call :die | ||
| 54 | ) else ( | ||
| 55 | set lj_source_folder=%APPVEYOR_BUILD_FOLDER%\downloads\luajit-%LJ_VER% | ||
| 56 | if not exist !lj_source_folder! ( | ||
| 57 | echo Downloading... %LUAJIT_URL%/LuaJIT-%LJ_VER%.tar.gz | ||
| 58 | curl --silent --fail --max-time 120 --connect-timeout 30 %LUAJIT_URL%/LuaJIT-%LJ_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads | ||
| 59 | ) | ||
| 60 | cd !lj_source_folder!\src | ||
| 61 | ) | ||
| 62 | :: Compiles LuaJIT | ||
| 63 | call msvcbuild.bat | ||
| 64 | |||
| 65 | mkdir %LUA_DIR% 2> NUL | ||
| 66 | for %%a in (bin include lib) do ( mkdir "%LUA_DIR%\%%a" ) | ||
| 67 | |||
| 68 | for %%a in (luajit.exe lua51.dll) do ( move "!lj_source_folder!\src\%%a" "%LUA_DIR%\bin" ) | ||
| 69 | |||
| 70 | move "!lj_source_folder!\src\lua51.lib" "%LUA_DIR%\lib" | ||
| 71 | for %%a in (lauxlib.h lua.h lua.hpp luaconf.h lualib.h luajit.h) do ( | ||
| 72 | copy "!lj_source_folder!\src\%%a" "%LUA_DIR%\include" | ||
| 73 | ) | ||
| 74 | |||
| 75 | ) else ( | ||
| 76 | echo LuaJIT %LJ_VER% already installed at %LUA_DIR% | ||
| 77 | ) | ||
| 78 | ) else ( | ||
| 79 | if not exist %LUA_DIR% ( | ||
| 80 | :: Download and compile Lua | ||
| 81 | if not exist downloads\lua-%LUA_VER% ( | ||
| 82 | curl --silent --fail --max-time 120 --connect-timeout 30 %LUA_URL%/lua-%LUA_VER%.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% x -si -ttar -aoa -odownloads | ||
| 83 | ) | ||
| 84 | |||
| 85 | mkdir downloads\lua-%LUA_VER%\etc 2> NUL | ||
| 86 | if not exist downloads\lua-%LUA_VER%\etc\winmake.bat ( | ||
| 87 | curl --silent --location --insecure --fail --max-time 120 --connect-timeout 30 https://github.com/Tieske/luawinmake/archive/master.tar.gz | %SEVENZIP% x -si -so -tgzip | %SEVENZIP% e -si -ttar -aoa -odownloads\lua-%LUA_VER%\etc luawinmake-master\etc\winmake.bat | ||
| 88 | ) | ||
| 89 | |||
| 90 | cd downloads\lua-%LUA_VER% | ||
| 91 | call etc\winmake | ||
| 92 | call etc\winmake install %LUA_DIR% | ||
| 93 | ) else ( | ||
| 94 | echo Lua %LUA_VER% already installed at %LUA_DIR% | ||
| 95 | ) | ||
| 96 | ) | ||
| 97 | |||
| 98 | if not exist %LUA_DIR%\bin\%LUA%.exe call :die "Missing Lua interpreter at %LUA_DIR%\bin\%LUA%.exe" | ||
| 99 | |||
| 100 | set PATH=%LUA_DIR%\bin;%PATH% | ||
| 101 | call %LUA% -v | ||
| 102 | |||
| 103 | |||
| 104 | |||
| 105 | :: Exports the following variables: | ||
| 106 | endlocal & set PATH=%PATH% | ||
| 107 | |||
| 108 | echo. | ||
| 109 | echo ====================================================== | ||
| 110 | if "%LUA%"=="luajit" ( | ||
| 111 | echo Installation of LuaJIT %LJ_VER% done. | ||
| 112 | ) else ( | ||
| 113 | echo Installation of Lua %LUA_VER% done. | ||
| 114 | ) | ||
| 115 | echo Platform - %platform% | ||
| 116 | echo LUA - %LUA% | ||
| 117 | echo LUA_SHORTV - %LUA_SHORTV% | ||
| 118 | echo LJ_SHORTV - %LJ_SHORTV% | ||
| 119 | echo. | ||
| 120 | echo ====================================================== | ||
| 121 | echo. | ||
| 122 | |||
| 123 | goto :eof | ||
| 124 | |||
| 125 | |||
| 126 | |||
| 127 | |||
| 128 | |||
| 129 | |||
| 130 | |||
| 131 | |||
| 132 | |||
| 133 | |||
| 134 | |||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 | |||
| 139 | |||
| 140 | |||
| 141 | |||
| 142 | :: This blank space is intentional. If you see errors like "The system cannot find the batch label specified 'foo'" | ||
| 143 | :: then try adding or removing blank lines lines above. | ||
| 144 | :: Yes, really. | ||
| 145 | :: http://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e | ||
| 146 | |||
| 147 | :: helper functions: | ||
| 148 | |||
| 149 | :: for bailing out when an error occurred | ||
| 150 | :die %1 | ||
| 151 | echo %1 | ||
| 152 | exit /B 1 | ||
| 153 | goto :eof | ||
| 154 | |||
diff --git a/.travis.yml b/.travis.yml index 86f7bbad..4f32d3a2 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -55,8 +55,8 @@ script: | |||
| 55 | - busted -Xhelper travis,env=full --verbose | 55 | - busted -Xhelper travis,env=full --verbose |
| 56 | 56 | ||
| 57 | after_success: | 57 | after_success: |
| 58 | - luacov-coveralls -c $TRAVIS_BUILD_DIR/test/luacov.config --exclude $TRAVIS_BUILD_DIR/test/ | ||
| 59 | - luacov -c $TRAVIS_BUILD_DIR/test/luacov.config | 58 | - luacov -c $TRAVIS_BUILD_DIR/test/luacov.config |
| 59 | - cd $TRAVIS_BUILD_DIR/test/ && bash <(curl -s https://codecov.io/bash) | ||
| 60 | - grep "Summary" -B1 -A1000 $TRAVIS_BUILD_DIR/test/luacov.report.out | 60 | - grep "Summary" -B1 -A1000 $TRAVIS_BUILD_DIR/test/luacov.report.out |
| 61 | 61 | ||
| 62 | notifications: | 62 | notifications: |
| @@ -2,7 +2,8 @@ | |||
| 2 | include config.unix | 2 | include config.unix |
| 3 | 3 | ||
| 4 | .PHONY: all build dev build_bins luadoc check_makefile cleanup_bins clean \ | 4 | .PHONY: all build dev build_bins luadoc check_makefile cleanup_bins clean \ |
| 5 | install_site_config write_sysconfig install bootstrap install_rock | 5 | install_site_config write_sysconfig install bootstrap install_rock \ |
| 6 | run_luarocks | ||
| 6 | 7 | ||
| 7 | ROCKS_TREE ?= $(PREFIX) | 8 | ROCKS_TREE ?= $(PREFIX) |
| 8 | SYSCONFDIR ?= $(PREFIX)/etc/luarocks | 9 | SYSCONFDIR ?= $(PREFIX)/etc/luarocks |
| @@ -124,6 +125,9 @@ cleanup_bins: | |||
| 124 | clean: cleanup_bins | 125 | clean: cleanup_bins |
| 125 | rm -f src/luarocks/site_config.lua | 126 | rm -f src/luarocks/site_config.lua |
| 126 | 127 | ||
| 128 | run_luarocks: | ||
| 129 | '$(LUA_BINDIR)/lua$(LUA_SUFFIX)' -e "package.path=[[$(SAFEPWD)/src/?.lua;]]..package.path" src/bin/luarocks make rockspec --tree="$(PREFIX)" | ||
| 130 | |||
| 127 | install_site_config: src/luarocks/site_config.lua | 131 | install_site_config: src/luarocks/site_config.lua |
| 128 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" | 132 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" |
| 129 | cp src/luarocks/site_config.lua "$(DESTDIR)$(LUADIR)/luarocks" | 133 | cp src/luarocks/site_config.lua "$(DESTDIR)$(LUADIR)/luarocks" |
| @@ -144,8 +148,7 @@ write_sysconfig: | |||
| 144 | 148 | ||
| 145 | install: install_bins install_luas install_site_config write_sysconfig | 149 | install: install_bins install_luas install_site_config write_sysconfig |
| 146 | 150 | ||
| 147 | bootstrap: src/luarocks/site_config.lua install_site_config write_sysconfig cleanup_bins | 151 | bootstrap: src/luarocks/site_config.lua run_luarocks install_site_config write_sysconfig cleanup_bins |
| 148 | '$(LUA_BINDIR)/lua$(LUA_SUFFIX)' -e "package.path=[[$(SAFEPWD)/src/?.lua;]]..package.path" src/bin/luarocks make rockspec --tree="$(PREFIX)" | ||
| 149 | 152 | ||
| 150 | install_rock: install_bins install_luas | 153 | install_rock: install_bins install_luas |
| 151 | 154 | ||
diff --git a/Makefile.luarocks b/Makefile.luarocks index 1eecfeae..20ede467 100644 --- a/Makefile.luarocks +++ b/Makefile.luarocks | |||
| @@ -12,4 +12,4 @@ install: install_bins install_luas copy_site_config | |||
| 12 | copy_site_config: | 12 | copy_site_config: |
| 13 | luaver="$(LUA_VERSION)" && [ -n "$$luaver" ] || luaver=`$(LUA) -e 'print(_VERSION:sub(5))'`; \ | 13 | luaver="$(LUA_VERSION)" && [ -n "$$luaver" ] || luaver=`$(LUA) -e 'print(_VERSION:sub(5))'`; \ |
| 14 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"; \ | 14 | mkdir -p "$(DESTDIR)$(LUADIR)/luarocks"; \ |
| 15 | cp $(LUAROCKS_PREFIX)/share/lua/$$luaver/luarocks/site_config.lua "$(DESTDIR)$(LUADIR)/luarocks" | 15 | lprefix=`echo "$(LUADIR)" | sed 's,/lib/luarocks/.*,,'`; sed "s,LUAROCKS_PREFIX=.*,LUAROCKS_PREFIX=[[$$lprefix]],g" $(LUAROCKS_PREFIX)/share/lua/$$luaver/luarocks/site_config.lua > "$(DESTDIR)$(LUADIR)/luarocks/site_config.lua" |
| @@ -2,9 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | A package manager for Lua modules. | 3 | A package manager for Lua modules. |
| 4 | 4 | ||
| 5 | [](https://travis-ci.org/keplerproject/luarocks) | 5 | [](https://travis-ci.org/keplerproject/luarocks) |
| 6 | [](https://ci.appveyor.com/project/hishamhm/luarocks/branch/master) | 6 | [](https://ci.appveyor.com/project/hishamhm/luarocks/branch/master) |
| 7 | [](https://coveralls.io/r/keplerproject/luarocks?branch=master) | 7 | [](https://codecov.io/gh/keplerproject/luarocks/branch/master) |
| 8 | [](https://gitter.im/keplerproject/luarocks?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
| 8 | 9 | ||
| 9 | Main website: [luarocks.org](http://www.luarocks.org) | 10 | Main website: [luarocks.org](http://www.luarocks.org) |
| 10 | 11 | ||
diff --git a/appveyor.yml b/appveyor.yml index d95ea952..32dc3e14 100644 --- a/appveyor.yml +++ b/appveyor.yml | |||
| @@ -6,25 +6,50 @@ environment: | |||
| 6 | LUAROCKS_VER: 3.0.0 | 6 | LUAROCKS_VER: 3.0.0 |
| 7 | 7 | ||
| 8 | matrix: | 8 | matrix: |
| 9 | - LUA_VER: 5.1.5 | 9 | - LUA: "lua 5.1" |
| 10 | - LUA_VER: 5.2.4 | 10 | COMPILER: "vs" |
| 11 | - LUA_VER: 5.3.1 | 11 | - LUA: "lua 5.1" |
| 12 | - LJ_VER: 2.0.4 | 12 | COMPILER: "mingw" |
| 13 | - LJ_VER: 2.1 | 13 | - LUA: "lua 5.2" |
| 14 | COMPILER: "vs" | ||
| 15 | - LUA: "lua 5.2" | ||
| 16 | COMPILER: "mingw" | ||
| 17 | - LUA: "lua 5.3" | ||
| 18 | COMPILER: "vs" | ||
| 19 | - LUA: "lua 5.3" | ||
| 20 | COMPILER: "mingw" | ||
| 21 | - LUA: "luajit 2.0" | ||
| 22 | COMPILER: "vs" | ||
| 23 | - LUA: "luajit 2.0" | ||
| 24 | COMPILER: "mingw" | ||
| 25 | - LUA: "luajit 2.1" | ||
| 26 | COMPILER: "vs" | ||
| 27 | - LUA: "luajit 2.1" | ||
| 28 | COMPILER: "mingw" | ||
| 29 | |||
| 14 | 30 | ||
| 15 | init: | 31 | init: |
| 16 | # Setup Lua development/build environment | 32 | # Setup Lua development/build environment |
| 17 | # Make VS 2015 command line tools available | 33 | # Make VS 2015 command line tools available |
| 18 | - call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %platform% | 34 | - call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %platform% |
| 35 | # Add MinGW compiler to the path | ||
| 36 | - set PATH=C:\MinGW\bin;%PATH% | ||
| 19 | 37 | ||
| 20 | install: | 38 | before_build: |
| 21 | # Setup Lua development/build environment | 39 | - set PATH=C:\Python27\Scripts;%PATH% # Add directory containing 'pip' to PATH |
| 22 | - call .appveyor\install.bat | 40 | - pip install hererocks |
| 41 | - hererocks env --%LUA% -rlatest --target=%COMPILER% | ||
| 42 | - call env\bin\activate | ||
| 23 | 43 | ||
| 24 | build_script: | 44 | build_script: |
| 25 | - call .appveyor\build.bat | 45 | - luarocks install busted 1> NUL 2> NUL |
| 26 | 46 | ||
| 27 | test_script: | 47 | test_script: |
| 28 | - echo "Testing..." | 48 | - busted --lpath=.//?.lua --exclude-tags=ssh,unix,mock -Xhelper appveyor,%COMPILER% |
| 29 | - cd test | 49 | |
| 30 | - call testing.bat | 50 | after_test: |
| 51 | - if "%LUA%"=="lua 5.1" (luarocks show bit32 || luarocks install bit32) | ||
| 52 | - luarocks install luacov | ||
| 53 | - pip install codecov | ||
| 54 | - luacov -c test/luacov.config | ||
| 55 | - cd test && codecov \ No newline at end of file | ||
diff --git a/install.bat b/install.bat index 3deb3d14..7c0f8b73 100644 --- a/install.bat +++ b/install.bat | |||
| @@ -24,10 +24,6 @@ vars.LUA_LIBDIR = nil | |||
| 24 | vars.LUA_LIBNAME = nil | 24 | vars.LUA_LIBNAME = nil |
| 25 | vars.LUA_VERSION = "5.1" | 25 | vars.LUA_VERSION = "5.1" |
| 26 | vars.LUA_SHORTV = nil -- "51" | 26 | vars.LUA_SHORTV = nil -- "51" |
| 27 | -- MinGW does not generate .lib, nor needs it to link, but MSVC does | ||
| 28 | -- so .lib must be listed first to ensure they are found first if present. | ||
| 29 | -- To prevent MSVC trying to link to a .dll, which won't work. | ||
| 30 | vars.LUA_LIB_NAMES = "lua5.1.lib lua51.lib lua5.1.dll lua51.dll liblua.dll.a" | ||
| 31 | vars.LUA_RUNTIME = nil | 27 | vars.LUA_RUNTIME = nil |
| 32 | vars.UNAME_M = nil | 28 | vars.UNAME_M = nil |
| 33 | vars.COMPILER_ENV_CMD = nil | 29 | vars.COMPILER_ENV_CMD = nil |
| @@ -42,6 +38,8 @@ local NOADMIN = false | |||
| 42 | local PROMPT = true | 38 | local PROMPT = true |
| 43 | local SELFCONTAINED = false | 39 | local SELFCONTAINED = false |
| 44 | 40 | ||
| 41 | local lua_version_set = false | ||
| 42 | |||
| 45 | --- | 43 | --- |
| 46 | -- Some helpers | 44 | -- Some helpers |
| 47 | -- | 45 | -- |
| @@ -55,32 +53,6 @@ local function die(message) | |||
| 55 | os.exit(1) | 53 | os.exit(1) |
| 56 | end | 54 | end |
| 57 | 55 | ||
| 58 | local function split_string(str, delim, maxNb) | ||
| 59 | -- Eliminate bad cases... | ||
| 60 | if string.find(str, delim) == nil then | ||
| 61 | return { str } | ||
| 62 | end | ||
| 63 | if maxNb == nil or maxNb < 1 then | ||
| 64 | maxNb = 0 -- No limit | ||
| 65 | end | ||
| 66 | local result = {} | ||
| 67 | local pat = "(.-)" .. delim .. "()" | ||
| 68 | local nb = 0 | ||
| 69 | local lastPos | ||
| 70 | for part, pos in string.gmatch(str, pat) do | ||
| 71 | nb = nb + 1 | ||
| 72 | result[nb] = part | ||
| 73 | lastPos = pos | ||
| 74 | if nb == maxNb then break end | ||
| 75 | end | ||
| 76 | -- Handle the last field | ||
| 77 | if nb ~= maxNb then | ||
| 78 | result[nb + 1] = string.sub(str, lastPos) | ||
| 79 | end | ||
| 80 | return result | ||
| 81 | end | ||
| 82 | |||
| 83 | |||
| 84 | local function exec(cmd) | 56 | local function exec(cmd) |
| 85 | --print(cmd) | 57 | --print(cmd) |
| 86 | local status = os.execute("type NUL && "..cmd) | 58 | local status = os.execute("type NUL && "..cmd) |
| @@ -149,7 +121,7 @@ Configuring the destinations: | |||
| 149 | 121 | ||
| 150 | Configuring the Lua interpreter: | 122 | Configuring the Lua interpreter: |
| 151 | /LV [version] Lua version to use; either 5.1, 5.2, or 5.3. | 123 | /LV [version] Lua version to use; either 5.1, 5.2, or 5.3. |
| 152 | Default is 5.1 | 124 | Default is auto-detected. |
| 153 | /LUA [dir] Location where Lua is installed - e.g. c:\lua\5.1\ | 125 | /LUA [dir] Location where Lua is installed - e.g. c:\lua\5.1\ |
| 154 | If not provided, the installer will search the system | 126 | If not provided, the installer will search the system |
| 155 | path and some default locations for a valid Lua | 127 | path and some default locations for a valid Lua |
| @@ -220,6 +192,7 @@ local function parse_options(args) | |||
| 220 | vars.TREE_CMODULE = option.value | 192 | vars.TREE_CMODULE = option.value |
| 221 | elseif name == "/LV" then | 193 | elseif name == "/LV" then |
| 222 | vars.LUA_VERSION = option.value | 194 | vars.LUA_VERSION = option.value |
| 195 | lua_version_set = true | ||
| 223 | elseif name == "/L" then | 196 | elseif name == "/L" then |
| 224 | INSTALL_LUA = true | 197 | INSTALL_LUA = true |
| 225 | elseif name == "/MW" then | 198 | elseif name == "/MW" then |
| @@ -270,14 +243,8 @@ local function check_flags() | |||
| 270 | die("Bundled Lua version is 5.1, cannot install "..vars.LUA_VERSION) | 243 | die("Bundled Lua version is 5.1, cannot install "..vars.LUA_VERSION) |
| 271 | end | 244 | end |
| 272 | end | 245 | end |
| 273 | if vars.LUA_VERSION ~= "5.1" then | 246 | if not vars.LUA_VERSION:match("^5%.[123]$") then |
| 274 | if vars.LUA_VERSION == "5.2" then | 247 | die("Bad argument: /LV must either be 5.1, 5.2, or 5.3") |
| 275 | vars.LUA_LIB_NAMES = vars.LUA_LIB_NAMES:gsub("5([%.]?)1", "5%12") | ||
| 276 | elseif vars.LUA_VERSION == "5.3" then | ||
| 277 | vars.LUA_LIB_NAMES = vars.LUA_LIB_NAMES:gsub("5([%.]?)1", "5%13") | ||
| 278 | else | ||
| 279 | die("Bad argument: /LV must either be 5.1, 5.2, or 5.3") | ||
| 280 | end | ||
| 281 | end | 248 | end |
| 282 | if USE_MSVC_MANUAL and USE_MINGW then | 249 | if USE_MSVC_MANUAL and USE_MINGW then |
| 283 | die("Cannot combine option /MSVC and /MW") | 250 | die("Cannot combine option /MSVC and /MW") |
| @@ -287,111 +254,130 @@ end | |||
| 287 | -- *********************************************************** | 254 | -- *********************************************************** |
| 288 | -- Detect Lua | 255 | -- Detect Lua |
| 289 | -- *********************************************************** | 256 | -- *********************************************************** |
| 290 | local function look_for_interpreter (directory) | 257 | local function detect_lua_version(interpreter_path) |
| 291 | if vars.LUA_BINDIR then | 258 | local handler = io.popen(('type NUL && "%s" -e "io.stdout:write(_VERSION)" 2>NUL'):format(interpreter_path), "r") |
| 292 | -- if LUA_BINDIR is specified, it must be there, otherwise we fail | 259 | if not handler then |
| 293 | if exists( S"$LUA_BINDIR\\lua$LUA_VERSION.exe" ) then | 260 | return nil, "interpreter does not work" |
| 294 | vars.LUA_INTERPRETER = S"lua$LUA_VERSION.exe" | ||
| 295 | print(S" Found $LUA_BINDIR\\$LUA_INTERPRETER") | ||
| 296 | return true | ||
| 297 | elseif exists( S"$LUA_BINDIR\\lua$LUA_SHORTV.exe" ) then | ||
| 298 | vars.LUA_INTERPRETER = S"lua$LUA_SHORTV.exe" | ||
| 299 | print(S" Found $LUA_BINDIR\\$LUA_INTERPRETER") | ||
| 300 | return true | ||
| 301 | elseif exists(S"$LUA_BINDIR\\lua.exe") then | ||
| 302 | vars.LUA_INTERPRETER = "lua.exe" | ||
| 303 | print(S" Found $LUA_BINDIR\\$LUA_INTERPRETER") | ||
| 304 | return true | ||
| 305 | elseif exists(S"$LUA_BINDIR\\luajit.exe") then | ||
| 306 | vars.LUA_INTERPRETER = "luajit.exe" | ||
| 307 | print(S" Found $LUA_BINDIR\\$LUA_INTERPRETER") | ||
| 308 | return true | ||
| 309 | end | ||
| 310 | die(S"Lua executable lua.exe, luajit.exe, lua$LUA_SHORTV.exe or lua$LUA_VERSION.exe not found in $LUA_BINDIR") | ||
| 311 | end | 261 | end |
| 262 | local full_version = handler:read("*a") | ||
| 263 | handler:close() | ||
| 312 | 264 | ||
| 313 | for _, e in ipairs{ [[\]], [[\bin\]] } do | 265 | local version = full_version:match("^Lua (5%.[123])$") |
| 314 | if exists(directory..e.."\\lua"..vars.LUA_VERSION..".exe") then | 266 | if not version then |
| 315 | vars.LUA_INTERPRETER = S"lua$LUA_VERSION.exe" | 267 | return nil, "unknown interpreter version '" .. full_version .. "'" |
| 316 | vars.LUA_BINDIR = directory .. e | 268 | end |
| 317 | print(" Found ."..e..vars.LUA_INTERPRETER) | 269 | return version |
| 318 | return true | 270 | end |
| 319 | 271 | ||
| 320 | elseif exists(directory..e.."\\lua"..vars.LUA_SHORTV..".exe") then | 272 | local function look_for_interpreter(directory) |
| 321 | vars.LUA_INTERPRETER = S"lua$LUA_SHORTV.exe" | 273 | local names |
| 322 | vars.LUA_BINDIR = directory .. e | 274 | if lua_version_set then |
| 323 | print(" Found ."..e..vars.LUA_INTERPRETER) | 275 | names = {S"lua$LUA_VERSION.exe", S"lua$LUA_SHORTV.exe"} |
| 324 | return true | 276 | else |
| 277 | names = {"lua5.3.exe", "lua53.exe", "lua5.2.exe", "lua52.exe", "lua5.1.exe", "lua51.exe"} | ||
| 278 | end | ||
| 279 | table.insert(names, "lua.exe") | ||
| 280 | table.insert(names, "luajit.exe") | ||
| 325 | 281 | ||
| 326 | elseif exists(directory..e.."\\lua.exe") then | 282 | local directories |
| 327 | vars.LUA_INTERPRETER = "lua.exe" | 283 | if vars.LUA_BINDIR then |
| 328 | vars.LUA_BINDIR = directory..e | 284 | -- If LUA_BINDIR is specified, look only in that directory. |
| 329 | print(" Found ."..e..vars.LUA_INTERPRETER) | 285 | directories = {vars.LUA_BINDIR} |
| 330 | return true | 286 | else |
| 287 | -- Try candidate directory and its `bin` subdirectory. | ||
| 288 | directories = {directory, directory .. "\\bin"} | ||
| 289 | end | ||
| 331 | 290 | ||
| 332 | elseif exists(directory..e.."\\luajit.exe") then | 291 | for _, dir in ipairs(directories) do |
| 333 | vars.LUA_INTERPRETER = "luajit.exe" | 292 | for _, name in ipairs(names) do |
| 334 | vars.LUA_BINDIR = directory..e | 293 | local full_name = dir .. "\\" .. name |
| 335 | print(" Found ."..e..vars.LUA_INTERPRETER) | 294 | if exists(full_name) then |
| 336 | return true | 295 | print(" Found " .. name .. ", testing it...") |
| 296 | local version, err = detect_lua_version(full_name) | ||
| 297 | if not version then | ||
| 298 | print(" Error: " .. err) | ||
| 299 | else | ||
| 300 | if version ~= vars.LUA_VERSION then | ||
| 301 | if lua_version_set then | ||
| 302 | die("Version of interpreter clashes with the value of /LV. Please check your configuration.") | ||
| 303 | else | ||
| 304 | vars.LUA_VERSION = version | ||
| 305 | vars.LUA_SHORTV = version:gsub("%.", "") | ||
| 306 | end | ||
| 307 | end | ||
| 308 | |||
| 309 | vars.LUA_INTERPRETER = name | ||
| 310 | vars.LUA_BINDIR = dir | ||
| 311 | return true | ||
| 312 | end | ||
| 313 | end | ||
| 337 | end | 314 | end |
| 338 | end | 315 | end |
| 339 | --print(" No Lua interpreter found") | 316 | |
| 317 | if vars.LUA_BINDIR then | ||
| 318 | die(("Working Lua executable (one of %s) not found in %s"):format(table.concat(names, ", "), vars.LUA_BINDIR)) | ||
| 319 | end | ||
| 340 | return false | 320 | return false |
| 341 | end | 321 | end |
| 342 | 322 | ||
| 343 | local function look_for_link_libraries (directory) | 323 | local function look_for_link_libraries(directory) |
| 324 | -- MinGW does not generate .lib, nor needs it to link, but MSVC does, | ||
| 325 | -- so .lib must be listed first to ensure they are found first if present, | ||
| 326 | -- to prevent MSVC trying to link to a .dll, which won't work. | ||
| 327 | local names = {S"lua$LUA_VERSION.lib", S"lua$LUA_SHORTV.lib", S"lua$LUA_VERSION.dll", S"lua$LUA_SHORTV.dll", "liblua.dll.a"} | ||
| 328 | local directories | ||
| 344 | if vars.LUA_LIBDIR then | 329 | if vars.LUA_LIBDIR then |
| 345 | for name in vars.LUA_LIB_NAMES:gmatch("[^%s]+") do | 330 | directories = {vars.LUA_LIBDIR} |
| 346 | print(S" checking for $LUA_LIBDIR\\"..name) | 331 | else |
| 347 | if exists(vars.LUA_LIBDIR.."\\"..name) then | 332 | directories = {directory, directory .. "\\lib", directory .. "\\bin"} |
| 348 | vars.LUA_LIBNAME = name | ||
| 349 | print(" Found "..name) | ||
| 350 | return true | ||
| 351 | end | ||
| 352 | end | ||
| 353 | die(S"link library (one of; $LUA_LIB_NAMES) not found in $LUA_LIBDIR") | ||
| 354 | end | 333 | end |
| 355 | 334 | ||
| 356 | for _, e in ipairs{ [[\]], [[\lib\]], [[\bin\]]} do | 335 | for _, dir in ipairs(directories) do |
| 357 | for name in vars.LUA_LIB_NAMES:gmatch("[^%s]+") do | 336 | for _, name in ipairs(names) do |
| 358 | print(" checking for "..directory..e.."\\"..name) | 337 | local full_name = dir .. "\\" .. name |
| 359 | if exists(directory..e.."\\"..name) then | 338 | print(" checking for " .. full_name) |
| 360 | vars.LUA_LIBDIR = directory .. e | 339 | if exists(full_name) then |
| 340 | vars.LUA_LIBDIR = dir | ||
| 361 | vars.LUA_LIBNAME = name | 341 | vars.LUA_LIBNAME = name |
| 362 | print(" Found "..name) | 342 | print(" Found " .. name) |
| 363 | return true | 343 | return true |
| 364 | end | 344 | end |
| 365 | end | 345 | end |
| 366 | end | 346 | end |
| 347 | |||
| 348 | if vars.LUA_LIBDIR then | ||
| 349 | die(("Link library (one of %s) not found in %s"):format(table.concat(names, ", "), vars.LUA_LIBDIR)) | ||
| 350 | end | ||
| 367 | return false | 351 | return false |
| 368 | end | 352 | end |
| 369 | 353 | ||
| 370 | local function look_for_headers (directory) | 354 | local function look_for_headers(directory) |
| 355 | local directories | ||
| 371 | if vars.LUA_INCDIR then | 356 | if vars.LUA_INCDIR then |
| 372 | print(S" checking for $LUA_INCDIR\\lua.h") | 357 | directories = {vars.LUA_INCDIR} |
| 373 | if exists(S"$LUA_INCDIR\\lua.h") then | 358 | else |
| 374 | print(" Found lua.h") | 359 | directories = { |
| 375 | return true | 360 | directory .. S"\\include\\lua\\$LUA_VERSION", |
| 376 | end | 361 | directory .. S"\\include\\lua$LUA_SHORTV", |
| 377 | die(S"lua.h not found in $LUA_INCDIR") | 362 | directory .. S"\\include\\lua$LUA_VERSION", |
| 363 | directory .. "\\include", | ||
| 364 | directory | ||
| 365 | } | ||
| 378 | end | 366 | end |
| 379 | 367 | ||
| 380 | for _, e in ipairs{ | 368 | for _, dir in ipairs(directories) do |
| 381 | S([[\include\lua\$LUA_VERSION]]), | 369 | local full_name = dir .. "\\lua.h" |
| 382 | S([[\include\lua$LUA_SHORTV]]), | 370 | print(" checking for " .. full_name) |
| 383 | S([[\include\lua$LUA_VERSION]]), | 371 | if exists(full_name) then |
| 384 | S([[\include\$LUA_VERSION]]), | 372 | vars.LUA_INCDIR = dir |
| 385 | [[\include\]], | ||
| 386 | [[\]], | ||
| 387 | } do | ||
| 388 | print(" checking for "..directory..e.."\\lua.h") | ||
| 389 | if exists(directory..e.."\\lua.h") then | ||
| 390 | vars.LUA_INCDIR = directory..e | ||
| 391 | print(" Found lua.h") | 373 | print(" Found lua.h") |
| 392 | return true | 374 | return true |
| 393 | end | 375 | end |
| 394 | end | 376 | end |
| 377 | |||
| 378 | if vars.LUA_INCDIR then | ||
| 379 | die(S"lua.h not found in $LUA_INCDIR") | ||
| 380 | end | ||
| 395 | return false | 381 | return false |
| 396 | end | 382 | end |
| 397 | 383 | ||
| @@ -548,51 +534,46 @@ local function get_msvc_env_setup_cmd() | |||
| 548 | return "" | 534 | return "" |
| 549 | end | 535 | end |
| 550 | 536 | ||
| 551 | local function look_for_lua_install () | 537 | local function get_possible_lua_directories() |
| 552 | print("Looking for Lua interpreter") | ||
| 553 | local directories | ||
| 554 | if vars.LUA_PREFIX then | 538 | if vars.LUA_PREFIX then |
| 555 | directories = { vars.LUA_PREFIX } | 539 | return {vars.LUA_PREFIX} |
| 556 | else | 540 | end |
| 557 | -- no prefix given, so use path | 541 | |
| 558 | directories = (os.getenv("PATH",";") or "") | 542 | -- No prefix given, so use PATH. |
| 559 | directories = directories:gsub(";+", ";") --remove all doubles | 543 | local path = os.getenv("PATH") or "" |
| 560 | directories = split_string(directories,";") | 544 | local directories = {} |
| 561 | -- if a path element ends with "\bin\" then remove it, as the searcher will check there anyway | 545 | for dir in path:gmatch("[^;]+") do |
| 562 | for i, val in ipairs(directories) do | 546 | -- Remove trailing backslashes, but not from a drive letter like `C:\`. |
| 563 | -- remove trailing backslash | 547 | dir = dir:gsub("([^:])\\+$", "%1") |
| 564 | while val:sub(-1,-1) == "\\" and val:sub(-2,-1) ~= ":\\" do | 548 | -- Remove trailing `bin` subdirectory, the searcher will check there anyway. |
| 565 | val = val:sub(1,-2) | 549 | if dir:upper():match("[:\\]BIN$") then |
| 566 | end | 550 | dir = dir:sub(1, -5) |
| 567 | -- remove trailing 'bin' | ||
| 568 | if val:upper():sub(-4,-1) == "\\BIN" or val:upper():sub(-4,-1) == ":BIN" then | ||
| 569 | val = val:sub(1,-5) | ||
| 570 | end | ||
| 571 | directories[i] = val | ||
| 572 | end | 551 | end |
| 573 | -- finaly add some other default paths | 552 | table.insert(directories, dir) |
| 574 | table.insert(directories, [[c:\lua5.1.2]]) | ||
| 575 | table.insert(directories, [[c:\lua]]) | ||
| 576 | table.insert(directories, [[c:\kepler\1.1]]) | ||
| 577 | end | 553 | end |
| 554 | -- Finally add some other default paths. | ||
| 555 | table.insert(directories, [[c:\lua5.1.2]]) | ||
| 556 | table.insert(directories, [[c:\lua]]) | ||
| 557 | table.insert(directories, [[c:\kepler\1.1]]) | ||
| 558 | return directories | ||
| 559 | end | ||
| 560 | |||
| 561 | local function look_for_lua_install () | ||
| 562 | print("Looking for Lua interpreter") | ||
| 578 | if vars.LUA_BINDIR and vars.LUA_LIBDIR and vars.LUA_INCDIR then | 563 | if vars.LUA_BINDIR and vars.LUA_LIBDIR and vars.LUA_INCDIR then |
| 579 | if look_for_interpreter(vars.LUA_BINDIR) and | 564 | if look_for_interpreter(vars.LUA_BINDIR) and |
| 580 | look_for_link_libraries(vars.LUA_LIBDIR) and | 565 | look_for_link_libraries(vars.LUA_LIBDIR) and |
| 581 | look_for_headers(vars.LUA_INCDIR) | 566 | look_for_headers(vars.LUA_INCDIR) |
| 582 | then | 567 | then |
| 583 | if get_runtime() then | 568 | if get_runtime() then |
| 584 | print("Runtime check completed, now testing interpreter...") | 569 | print("Runtime check completed.") |
| 585 | if exec(S[["$LUA_BINDIR\$LUA_INTERPRETER" -v 2>NUL]]) then | 570 | return true |
| 586 | print(" Ok") | ||
| 587 | return true | ||
| 588 | end | ||
| 589 | print(" Interpreter returned an error, not ok") | ||
| 590 | end | 571 | end |
| 591 | end | 572 | end |
| 592 | return false | 573 | return false |
| 593 | end | 574 | end |
| 594 | 575 | ||
| 595 | for _, directory in ipairs(directories) do | 576 | for _, directory in ipairs(get_possible_lua_directories()) do |
| 596 | print(" checking " .. directory) | 577 | print(" checking " .. directory) |
| 597 | if exists(directory) then | 578 | if exists(directory) then |
| 598 | if look_for_interpreter(directory) then | 579 | if look_for_interpreter(directory) then |
| @@ -602,12 +583,8 @@ local function look_for_lua_install () | |||
| 602 | if look_for_headers(directory) then | 583 | if look_for_headers(directory) then |
| 603 | print("Headers found, checking runtime to use...") | 584 | print("Headers found, checking runtime to use...") |
| 604 | if get_runtime() then | 585 | if get_runtime() then |
| 605 | print("Runtime check completed, now testing interpreter...") | 586 | print("Runtime check completed.") |
| 606 | if exec(S[["$LUA_BINDIR\$LUA_INTERPRETER" -v 2>NUL]]) then | 587 | return true |
| 607 | print(" Ok") | ||
| 608 | return true | ||
| 609 | end | ||
| 610 | print(" Interpreter returned an error, not ok") | ||
| 611 | end | 588 | end |
| 612 | end | 589 | end |
| 613 | end | 590 | end |
| @@ -752,9 +729,6 @@ vars.INCDIR = S"$PREFIX\\include" | |||
| 752 | vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "") | 729 | vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "") |
| 753 | 730 | ||
| 754 | if INSTALL_LUA then | 731 | if INSTALL_LUA then |
| 755 | if vars.LUA_VERSION ~= "5.1" then | ||
| 756 | die("Cannot install own copy of Lua because only 5.1 is bundled") | ||
| 757 | end | ||
| 758 | vars.LUA_INTERPRETER = "lua5.1" | 732 | vars.LUA_INTERPRETER = "lua5.1" |
| 759 | vars.LUA_BINDIR = vars.BINDIR | 733 | vars.LUA_BINDIR = vars.BINDIR |
| 760 | vars.LUA_LIBDIR = vars.LIBDIR | 734 | vars.LUA_LIBDIR = vars.LIBDIR |
| @@ -993,7 +967,7 @@ if FORCE_CONFIG then | |||
| 993 | f:write("site_config.LUAROCKS_FORCE_CONFIG=true\n") | 967 | f:write("site_config.LUAROCKS_FORCE_CONFIG=true\n") |
| 994 | end | 968 | end |
| 995 | if vars.SYSCONFFORCE then -- only write this value when explcitly given, otherwise rely on defaults | 969 | if vars.SYSCONFFORCE then -- only write this value when explcitly given, otherwise rely on defaults |
| 996 | f:write(S("site_config.LUAROCKS_SYSCONFIG=[[$CONFIG_FILE]]\n")) | 970 | f:write(S("site_config.LUAROCKS_SYSCONFDIR=[[$SYSCONFDIR]]\n")) |
| 997 | end | 971 | end |
| 998 | f:write("return site_config\n") | 972 | f:write("return site_config\n") |
| 999 | f:close() | 973 | f:close() |
diff --git a/spec/add_spec.lua b/spec/add_spec.lua index dca6f850..d42a97d0 100644 --- a/spec/add_spec.lua +++ b/spec/add_spec.lua | |||
| @@ -5,8 +5,8 @@ local testing_paths = test_env.testing_paths | |||
| 5 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 6 | 6 | ||
| 7 | local extra_rocks = { | 7 | local extra_rocks = { |
| 8 | "/luasocket-3.0rc1-1.src.rock", | 8 | "/luasocket-3.0rc1-2.src.rock", |
| 9 | "/luasocket-3.0rc1-1.rockspec" | 9 | "/luasocket-3.0rc1-2.rockspec" |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | describe("LuaRocks add tests #blackbox #b_add", function() | 12 | describe("LuaRocks add tests #blackbox #b_add", function() |
| @@ -25,20 +25,20 @@ describe("LuaRocks add tests #blackbox #b_add", function() | |||
| 25 | end) | 25 | end) |
| 26 | 26 | ||
| 27 | it("LuaRocks-admin add invalid server", function() | 27 | it("LuaRocks-admin add invalid server", function() |
| 28 | assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) | 28 | assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock")) |
| 29 | end) | 29 | end) |
| 30 | 30 | ||
| 31 | it("LuaRocks-admin add invalid server #ssh", function() | 31 | it("LuaRocks-admin add invalid server #ssh", function() |
| 32 | assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) | 32 | assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock")) |
| 33 | end) | 33 | end) |
| 34 | 34 | ||
| 35 | --TODO This test fails, sftp not implemented | 35 | --TODO This test fails, sftp support not yet implemented |
| 36 | it("LuaRocks-admin add invalid server", function() --? | 36 | it("LuaRocks-admin add invalid server", function() |
| 37 | assert.is_false(run.luarocks_admin_bool("--server=testing add luasocket-3.0rc1-1.src.rock", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_sftp.lua" } )) | 37 | assert.is_false(run.luarocks_admin_bool("--server=testing add luasocket-3.0rc1-2.src.rock", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_sftp.lua" } )) |
| 38 | end) | 38 | end) |
| 39 | 39 | ||
| 40 | it("LuaRocks-admin add, split server url", function() | 40 | it("LuaRocks-admin add, split server url", function() |
| 41 | assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "luasocket-3.0rc1-1.src.rock")) | 41 | assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock")) |
| 42 | end) | 42 | end) |
| 43 | end) | 43 | end) |
| 44 | end) | 44 | end) |
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 2ede5211..2ff7cbe6 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
| @@ -12,15 +12,16 @@ local extra_rocks = { | |||
| 12 | "/lmathx-20120430.52-1.rockspec", | 12 | "/lmathx-20120430.52-1.rockspec", |
| 13 | "/lmathx-20150505-1.src.rock", | 13 | "/lmathx-20150505-1.src.rock", |
| 14 | "/lmathx-20150505-1.rockspec", | 14 | "/lmathx-20150505-1.rockspec", |
| 15 | "/lpeg-0.12-1.src.rock", | 15 | "/lpeg-1.0.0-1.rockspec", |
| 16 | "/lpeg-1.0.0-1.src.rock", | ||
| 16 | "/lpty-1.0.1-1.src.rock", | 17 | "/lpty-1.0.1-1.src.rock", |
| 17 | "/luadoc-3.0.1-1.src.rock", | 18 | "/luadoc-3.0.1-1.src.rock", |
| 18 | "/luafilesystem-1.6.3-1.src.rock", | 19 | "/luafilesystem-1.6.3-1.src.rock", |
| 19 | "/lualogging-1.3.0-1.src.rock", | 20 | "/lualogging-1.3.0-1.src.rock", |
| 20 | "/luarepl-0.4-1.src.rock", | 21 | "/luarepl-0.4-1.src.rock", |
| 21 | "/luasec-0.6-1.rockspec", | 22 | "/luasec-0.6-1.rockspec", |
| 22 | "/luasocket-3.0rc1-1.src.rock", | 23 | "/luasocket-3.0rc1-2.src.rock", |
| 23 | "/luasocket-3.0rc1-1.rockspec", | 24 | "/luasocket-3.0rc1-2.rockspec", |
| 24 | "/lxsh-0.8.6-2.src.rock", | 25 | "/lxsh-0.8.6-2.src.rock", |
| 25 | "/lxsh-0.8.6-2.rockspec", | 26 | "/lxsh-0.8.6-2.rockspec", |
| 26 | "/stdlib-41.0.0-1.src.rock", | 27 | "/stdlib-41.0.0-1.src.rock", |
| @@ -57,63 +58,82 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
| 57 | end) | 58 | end) |
| 58 | 59 | ||
| 59 | it("LuaRocks build lpeg verbose", function() | 60 | it("LuaRocks build lpeg verbose", function() |
| 60 | assert.is.truthy(run.luarocks("build --verbose lpeg")) | 61 | assert.is_true(run.luarocks_bool("build --verbose lpeg")) |
| 61 | end) | 62 | end) |
| 62 | 63 | ||
| 63 | it("LuaRocks build lpeg branch=master", function() | 64 | it("LuaRocks build lpeg branch=master", function() |
| 64 | assert.is_true(run.luarocks_bool("build --branch=master lpeg")) | 65 | assert.is_true(run.luarocks_bool("build --branch=master lpeg")) |
| 65 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 66 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 66 | end) | 67 | end) |
| 67 | 68 | ||
| 68 | it("LuaRocks build lpeg deps-mode=123", function() | 69 | it("LuaRocks build lpeg deps-mode=123", function() |
| 69 | assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg")) | 70 | assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg --verbose")) |
| 70 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 71 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 71 | end) | 72 | end) |
| 72 | 73 | ||
| 73 | it("LuaRocks build lpeg only-sources example", function() | 74 | it("LuaRocks build lpeg only-sources example", function() |
| 74 | assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg")) | 75 | assert.is_true(run.luarocks_bool("download --rockspec lpeg")) |
| 75 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 76 | assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.rockspec")) |
| 77 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) | ||
| 78 | |||
| 79 | assert.is_true(run.luarocks_bool("download --source lpeg")) | ||
| 80 | assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.src.rock")) | ||
| 81 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) | ||
| 82 | |||
| 83 | assert.is_true(os.remove("lpeg-1.0.0-1.rockspec")) | ||
| 84 | assert.is_true(os.remove("lpeg-1.0.0-1.src.rock")) | ||
| 76 | end) | 85 | end) |
| 77 | 86 | ||
| 78 | it("LuaRocks build lpeg with empty tree", function() | 87 | it("LuaRocks build lpeg with empty tree", function() |
| 79 | assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg")) | 88 | assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg")) |
| 80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 89 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 81 | end) | 90 | end) |
| 82 | end) | 91 | end) |
| 83 | 92 | ||
| 84 | describe("LuaRocks build - basic builds", function() | 93 | describe("LuaRocks build - basic builds", function() |
| 85 | it("LuaRocks build luadoc", function() | 94 | it("LuaRocks build luadoc", function() |
| 86 | assert.is_true(run.luarocks_bool(test_env.quiet("build luadoc"))) | 95 | assert.is_true(run.luarocks_bool("build luadoc")) |
| 87 | end) | 96 | end) |
| 88 | 97 | ||
| 89 | it("LuaRocks build luacov diff version", function() | 98 | it("LuaRocks build luacov diff version", function() |
| 90 | assert.is_true(run.luarocks_bool("build luacov 0.11.0-1")) | 99 | assert.is_true(run.luarocks_bool("build luacov 0.11.0-1")) |
| 91 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov")) | 100 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov/0.11.0-1/luacov-0.11.0-1.rockspec")) |
| 92 | end) | 101 | end) |
| 93 | 102 | ||
| 94 | it("LuaRocks build command stdlib", function() | 103 | it("LuaRocks build command stdlib", function() |
| 95 | assert.is_true(run.luarocks_bool("build stdlib")) | 104 | assert.is_true(run.luarocks_bool("build stdlib")) |
| 96 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib")) | 105 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec")) |
| 97 | end) | 106 | end) |
| 98 | 107 | ||
| 99 | it("LuaRocks build install bin luarepl", function() | 108 | it("LuaRocks build install bin luarepl", function() |
| 100 | assert.is_true(run.luarocks_bool("build luarepl")) | 109 | assert.is_true(run.luarocks_bool("build luarepl")) |
| 101 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl")) | 110 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl/0.4-1/luarepl-0.4-1.rockspec")) |
| 102 | end) | 111 | end) |
| 103 | 112 | ||
| 104 | it("LuaRocks build supported platforms lpty", function() | 113 | it("LuaRocks build supported platforms lpty", function() |
| 105 | assert.is_true(run.luarocks_bool(test_env.quiet("build lpty"))) | 114 | if test_env.TEST_TARGET_OS == "windows" then |
| 106 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty")) | 115 | assert.is_false(run.luarocks_bool("build lpty")) --Error: This rockspec for lpty does not support win32, windows platforms |
| 116 | else | ||
| 117 | assert.is_true(run.luarocks_bool("build lpty")) | ||
| 118 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty/1.0.1-1/lpty-1.0.1-1.rockspec")) | ||
| 119 | end | ||
| 107 | end) | 120 | end) |
| 108 | 121 | ||
| 109 | it("LuaRocks build luasec with skipping dependency checks", function() | 122 | it("LuaRocks build luasec with skipping dependency checks", function() |
| 110 | assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --nodeps"))) | 123 | assert.is_true(run.luarocks_bool("build luasec " .. test_env.OPENSSL_DIRS .. " --nodeps")) |
| 111 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | 124 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) |
| 112 | end) | 125 | end) |
| 113 | 126 | ||
| 114 | it("LuaRocks build lmathx deps partial match", function() | 127 | it("LuaRocks build lmathx deps partial match", function() |
| 115 | assert.is_true(run.luarocks_bool("build lmathx")) | 128 | assert.is_true(run.luarocks_bool("build lmathx")) |
| 116 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx")) | 129 | |
| 130 | if test_env.LUA_V == "5.1" or test_env.LUAJIT_V then | ||
| 131 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20120430.51-1/lmathx-20120430.51-1.rockspec")) | ||
| 132 | elseif test_env.LUA_V == "5.2" then | ||
| 133 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20120430.52-1/lmathx-20120430.52-1.rockspec")) | ||
| 134 | elseif test_env.LUA_V == "5.3" then | ||
| 135 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20150505-1/lmathx-20150505-1.rockspec")) | ||
| 136 | end | ||
| 117 | end) | 137 | end) |
| 118 | end) | 138 | end) |
| 119 | 139 | ||
| @@ -126,17 +146,17 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
| 126 | end | 146 | end |
| 127 | 147 | ||
| 128 | it("LuaRocks build luasec only deps", function() | 148 | it("LuaRocks build luasec only deps", function() |
| 129 | assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --only-deps"))) | 149 | assert.is_true(run.luarocks_bool("build luasec " .. test_env.OPENSSL_DIRS .. " --only-deps")) |
| 130 | assert.is_false(run.luarocks_bool("show luasec")) | 150 | assert.is_false(run.luarocks_bool("show luasec")) |
| 131 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | 151 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) |
| 132 | end) | 152 | end) |
| 133 | 153 | ||
| 134 | it("LuaRocks build only deps of downloaded rockspec of lxsh", function() | 154 | it("LuaRocks build only deps of downloaded rockspec of lxsh", function() |
| 135 | assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2")) | 155 | assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2")) |
| 136 | assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.rockspec --only-deps")) | 156 | assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.rockspec --only-deps")) |
| 137 | assert.is_false(run.luarocks_bool("show lxsh")) | 157 | assert.is_false(run.luarocks_bool("show lxsh")) |
| 138 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 158 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 139 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 159 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 140 | assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) | 160 | assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) |
| 141 | end) | 161 | end) |
| 142 | 162 | ||
| @@ -144,8 +164,8 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
| 144 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) | 164 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) |
| 145 | assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.src.rock --only-deps")) | 165 | assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.src.rock --only-deps")) |
| 146 | assert.is_false(run.luarocks_bool("show lxsh")) | 166 | assert.is_false(run.luarocks_bool("show lxsh")) |
| 147 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 167 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 148 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 168 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 149 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | 169 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) |
| 150 | end) | 170 | end) |
| 151 | 171 | ||
| @@ -154,19 +174,18 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
| 154 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | 174 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) |
| 155 | 175 | ||
| 156 | assert.is.truthy(run.luarocks("show validate-args")) | 176 | assert.is.truthy(run.luarocks("show validate-args")) |
| 157 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) | 177 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args/1.5.4-1/validate-args-1.5.4-1.rockspec")) |
| 158 | 178 | ||
| 159 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | 179 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) |
| 160 | end) | 180 | end) |
| 161 | 181 | ||
| 162 | it("LuaRocks build with https", function() | 182 | it("LuaRocks build with https", function() |
| 163 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | 183 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) |
| 164 | assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) | 184 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) |
| 185 | |||
| 165 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | 186 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) |
| 166 | |||
| 167 | assert.is.truthy(run.luarocks("show validate-args")) | 187 | assert.is.truthy(run.luarocks("show validate-args")) |
| 168 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) | 188 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args/1.5.4-1/validate-args-1.5.4-1.rockspec")) |
| 169 | |||
| 170 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | 189 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) |
| 171 | end) | 190 | end) |
| 172 | 191 | ||
diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 0dee8620..4a7f4aea 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua | |||
| @@ -2,6 +2,7 @@ local test_env = require("test/test_environment") | |||
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | 3 | local run = test_env.run |
| 4 | local testing_paths = test_env.testing_paths | 4 | local testing_paths = test_env.testing_paths |
| 5 | local env_variables = test_env.env_variables | ||
| 5 | local site_config | 6 | local site_config |
| 6 | 7 | ||
| 7 | test_env.unload_luarocks() | 8 | test_env.unload_luarocks() |
| @@ -21,12 +22,20 @@ describe("LuaRocks config tests #blackbox #b_config", function() | |||
| 21 | 22 | ||
| 22 | it("LuaRocks config include dir", function() | 23 | it("LuaRocks config include dir", function() |
| 23 | local output = run.luarocks("config --lua-incdir") | 24 | local output = run.luarocks("config --lua-incdir") |
| 24 | assert.are.same(output, site_config.LUA_INCDIR) | 25 | if test_env.TEST_TARGET_OS == "windows" then |
| 26 | assert.are.same(output, site_config.LUA_INCDIR:gsub("\\","/")) | ||
| 27 | else | ||
| 28 | assert.are.same(output, site_config.LUA_INCDIR) | ||
| 29 | end | ||
| 25 | end) | 30 | end) |
| 26 | 31 | ||
| 27 | it("LuaRocks config library dir", function() | 32 | it("LuaRocks config library dir", function() |
| 28 | local output = run.luarocks("config --lua-libdir") | 33 | local output = run.luarocks("config --lua-libdir") |
| 29 | assert.are.same(output, site_config.LUA_LIBDIR) | 34 | if test_env.TEST_TARGET_OS == "windows" then |
| 35 | assert.are.same(output, site_config.LUA_LIBDIR:gsub("\\","/")) | ||
| 36 | else | ||
| 37 | assert.are.same(output, site_config.LUA_LIBDIR) | ||
| 38 | end | ||
| 30 | end) | 39 | end) |
| 31 | 40 | ||
| 32 | it("LuaRocks config lua version", function() | 41 | it("LuaRocks config lua version", function() |
| @@ -53,38 +62,61 @@ describe("LuaRocks config tests #blackbox #b_config", function() | |||
| 53 | end) | 62 | end) |
| 54 | 63 | ||
| 55 | describe("LuaRocks config - more complex tests", function() | 64 | describe("LuaRocks config - more complex tests", function() |
| 65 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
| 66 | local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" | ||
| 67 | local scname = scdir .. "/config.lua" | ||
| 68 | |||
| 69 | local configfile | ||
| 70 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 71 | configfile = versioned_scname | ||
| 72 | else | ||
| 73 | configfile = scname | ||
| 74 | end | ||
| 75 | |||
| 56 | it("LuaRocks fail system config", function() | 76 | it("LuaRocks fail system config", function() |
| 57 | os.remove(testing_paths.testing_lrprefix .. "/etc/luarocks/config.lua") | 77 | os.rename(configfile, configfile .. ".bak") |
| 58 | assert.is_false(run.luarocks_bool("config --system-config;")) | 78 | assert.is_false(run.luarocks_bool("config --system-config")) |
| 79 | os.rename(configfile .. ".bak", configfile) | ||
| 59 | end) | 80 | end) |
| 60 | 81 | ||
| 61 | it("LuaRocks system config", function() | 82 | it("LuaRocks system config", function() |
| 62 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
| 63 | lfs.mkdir(testing_paths.testing_lrprefix) | 83 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 64 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 84 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 65 | lfs.mkdir(scdir) | 85 | lfs.mkdir(scdir) |
| 66 | 86 | ||
| 67 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | 87 | if test_env.TEST_TARGET_OS == "windows" then |
| 68 | sysconfig:write(" ") | 88 | local output = run.luarocks("config --system-config") |
| 69 | sysconfig:close() | 89 | assert.are.same(output, configfile) |
| 70 | 90 | else | |
| 71 | local output = run.luarocks("config --system-config;") | 91 | local sysconfig = io.open(configfile, "w+") |
| 72 | assert.are.same(output, scdir .. "/config.lua") | 92 | sysconfig:write(" ") |
| 73 | test_env.remove_dir(testing_paths.testing_lrprefix) | 93 | sysconfig:close() |
| 94 | |||
| 95 | local output = run.luarocks("config --system-config") | ||
| 96 | assert.are.same(output, configfile) | ||
| 97 | os.remove(configfile) | ||
| 98 | end | ||
| 74 | end) | 99 | end) |
| 75 | 100 | ||
| 76 | it("LuaRocks fail system config invalid", function() | 101 | it("LuaRocks fail system config invalid", function() |
| 77 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
| 78 | lfs.mkdir(testing_paths.testing_lrprefix) | 102 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 79 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 103 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 80 | lfs.mkdir(scdir) | 104 | lfs.mkdir(scdir) |
| 81 | 105 | ||
| 82 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | 106 | if test_env.TEST_TARGET_OS == "windows" then |
| 83 | sysconfig:write("if if if") | 107 | test_env.copy(configfile, "configfile_temp") |
| 84 | sysconfig:close() | 108 | local sysconfig = io.open(configfile, "w+") |
| 85 | 109 | sysconfig:write("if if if") | |
| 86 | assert.is_false(run.luarocks_bool("config --system-config;")) | 110 | sysconfig:close() |
| 87 | test_env.remove_dir(testing_paths.testing_lrprefix) | 111 | assert.is_false(run.luarocks_bool("config --system-config")) |
| 112 | test_env.copy("configfile_temp", configfile) | ||
| 113 | else | ||
| 114 | local sysconfig = io.open(configfile, "w+") | ||
| 115 | sysconfig:write("if if if") | ||
| 116 | sysconfig:close() | ||
| 117 | assert.is_false(run.luarocks_bool("config --system-config")) | ||
| 118 | os.remove(configfile) | ||
| 119 | end | ||
| 88 | end) | 120 | end) |
| 89 | end) | 121 | end) |
| 90 | end) | 122 | end) |
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua index c1bd404d..e453c9a1 100644 --- a/spec/deps_spec.lua +++ b/spec/deps_spec.lua | |||
| @@ -8,9 +8,9 @@ test_env.unload_luarocks() | |||
| 8 | local extra_rocks = { | 8 | local extra_rocks = { |
| 9 | "/lxsh-0.8.6-2.src.rock", | 9 | "/lxsh-0.8.6-2.src.rock", |
| 10 | "/lxsh-0.8.6-2.rockspec", | 10 | "/lxsh-0.8.6-2.rockspec", |
| 11 | "/luasocket-3.0rc1-1.src.rock", | 11 | "/luasocket-3.0rc1-2.src.rock", |
| 12 | "/luasocket-3.0rc1-1.rockspec", | 12 | "/luasocket-3.0rc1-2.rockspec", |
| 13 | "/lpeg-0.12-1.src.rock" | 13 | "/lpeg-1.0.0-1.src.rock", |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | describe("LuaRocks deps tests #blackbox #b_deps", function() | 16 | describe("LuaRocks deps tests #blackbox #b_deps", function() |
| @@ -23,59 +23,59 @@ describe("LuaRocks deps tests #blackbox #b_deps", function() | |||
| 23 | assert.is_true(run.luarocks_bool("build --tree=system lpeg")) | 23 | assert.is_true(run.luarocks_bool("build --tree=system lpeg")) |
| 24 | assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh")) | 24 | assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh")) |
| 25 | 25 | ||
| 26 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | 26 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 27 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 27 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 28 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | 28 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 29 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 29 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 30 | end) | 30 | end) |
| 31 | 31 | ||
| 32 | it("LuaRocks deps mode order", function() | 32 | it("LuaRocks deps mode order", function() |
| 33 | assert.is_true(run.luarocks_bool("build --tree=system lpeg")) | 33 | assert.is_true(run.luarocks_bool("build --tree=system lpeg")) |
| 34 | assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_tree .. " lxsh")) | 34 | assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_tree .. " lxsh")) |
| 35 | 35 | ||
| 36 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | 36 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 37 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 37 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 38 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | 38 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 39 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 39 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 40 | end) | 40 | end) |
| 41 | 41 | ||
| 42 | it("LuaRocks deps mode order sys", function() | 42 | it("LuaRocks deps mode order sys", function() |
| 43 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | 43 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) |
| 44 | assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) | 44 | assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) |
| 45 | 45 | ||
| 46 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | 46 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 47 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 47 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 48 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | 48 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 49 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 49 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 50 | end) | 50 | end) |
| 51 | 51 | ||
| 52 | it("LuaRocks deps mode all sys", function() | 52 | it("LuaRocks deps mode all sys", function() |
| 53 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | 53 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) |
| 54 | assert.is_true(run.luarocks_bool("build --deps-mode=all --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) | 54 | assert.is_true(run.luarocks_bool("build --deps-mode=all --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) |
| 55 | 55 | ||
| 56 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | 56 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 57 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 57 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 58 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | 58 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 59 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 59 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 60 | end) | 60 | end) |
| 61 | 61 | ||
| 62 | it("LuaRocks deps mode none", function() | 62 | it("LuaRocks deps mode none", function() |
| 63 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | 63 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) |
| 64 | assert.is_true(run.luarocks_bool("build --deps-mode=none lxsh")) | 64 | assert.is_true(run.luarocks_bool("build --deps-mode=none lxsh")) |
| 65 | 65 | ||
| 66 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | 66 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 67 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 67 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 68 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | 68 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 69 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 69 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 70 | end) | 70 | end) |
| 71 | 71 | ||
| 72 | it("LuaRocks nodeps alias", function() | 72 | it("LuaRocks nodeps alias", function() |
| 73 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " --nodeps lxsh")) | 73 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " --nodeps lxsh")) |
| 74 | 74 | ||
| 75 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | 75 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 76 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 76 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 77 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | 77 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 78 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 78 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 79 | end) | 79 | end) |
| 80 | 80 | ||
| 81 | it("LuaRocks deps mode make order", function() | 81 | it("LuaRocks deps mode make order", function() |
| @@ -89,10 +89,10 @@ describe("LuaRocks deps tests #blackbox #b_deps", function() | |||
| 89 | test_env.remove_dir("lxsh-0.8.6-2") | 89 | test_env.remove_dir("lxsh-0.8.6-2") |
| 90 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | 90 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) |
| 91 | 91 | ||
| 92 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | 92 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 93 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 93 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 94 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | 94 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 95 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 95 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 96 | end) | 96 | end) |
| 97 | 97 | ||
| 98 | it("LuaRocks deps mode make order sys", function() | 98 | it("LuaRocks deps mode make order sys", function() |
| @@ -106,9 +106,9 @@ describe("LuaRocks deps tests #blackbox #b_deps", function() | |||
| 106 | test_env.remove_dir("lxsh-0.8.6-2") | 106 | test_env.remove_dir("lxsh-0.8.6-2") |
| 107 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | 107 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) |
| 108 | 108 | ||
| 109 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | 109 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 110 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | 110 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 111 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | 111 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 112 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 112 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 113 | end) | 113 | end) |
| 114 | end) | 114 | end) |
diff --git a/spec/help_spec.lua b/spec/help_spec.lua index 88aa5030..71b1b9f6 100644 --- a/spec/help_spec.lua +++ b/spec/help_spec.lua | |||
| @@ -10,7 +10,7 @@ describe("LuaRocks help tests #blackbox #b_help", function() | |||
| 10 | end) | 10 | end) |
| 11 | 11 | ||
| 12 | it("LuaRocks help with no flags/arguments", function() | 12 | it("LuaRocks help with no flags/arguments", function() |
| 13 | assert.is_true(run.luarocks_bool(test_env.quiet("help"))) | 13 | assert.is_true(run.luarocks_bool("help")) |
| 14 | end) | 14 | end) |
| 15 | 15 | ||
| 16 | it("LuaRocks help invalid argument", function() | 16 | it("LuaRocks help invalid argument", function() |
| @@ -18,7 +18,7 @@ describe("LuaRocks help tests #blackbox #b_help", function() | |||
| 18 | end) | 18 | end) |
| 19 | 19 | ||
| 20 | it("LuaRocks help config", function() | 20 | it("LuaRocks help config", function() |
| 21 | assert.is_true(run.luarocks_bool(test_env.quiet("help config"))) | 21 | assert.is_true(run.luarocks_bool("help config")) |
| 22 | end) | 22 | end) |
| 23 | 23 | ||
| 24 | it("LuaRocks-admin help with no flags/arguments", function() | 24 | it("LuaRocks-admin help with no flags/arguments", function() |
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index bd480c21..8857e4bd 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
| @@ -12,8 +12,8 @@ local extra_rocks = { | |||
| 12 | "/lpeg-0.12-1.src.rock", | 12 | "/lpeg-0.12-1.src.rock", |
| 13 | "/luasec-0.6-1.rockspec", | 13 | "/luasec-0.6-1.rockspec", |
| 14 | "/luassert-1.7.0-1.src.rock", | 14 | "/luassert-1.7.0-1.src.rock", |
| 15 | "/luasocket-3.0rc1-1.src.rock", | 15 | "/luasocket-3.0rc1-2.src.rock", |
| 16 | "/luasocket-3.0rc1-1.rockspec", | 16 | "/luasocket-3.0rc1-2.rockspec", |
| 17 | "/lxsh-0.8.6-2.src.rock", | 17 | "/lxsh-0.8.6-2.src.rock", |
| 18 | "/lxsh-0.8.6-2.rockspec", | 18 | "/lxsh-0.8.6-2.rockspec", |
| 19 | "/say-1.2-1.src.rock", | 19 | "/say-1.2-1.src.rock", |
| @@ -44,8 +44,8 @@ describe("LuaRocks install tests #blackbox #b_install", function() | |||
| 44 | assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) | 44 | assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) |
| 45 | end) | 45 | end) |
| 46 | 46 | ||
| 47 | it("LuaRocks install with local flag as root", function() | 47 | it("LuaRocks install with local flag as root #unix", function() |
| 48 | assert.is_false(run.luarocks_bool("install --local luasocket", { USER = "root" } )) | 48 | assert.is_false(run.luarocks_bool("install --local luasocket ", { USER = "root" } )) |
| 49 | end) | 49 | end) |
| 50 | 50 | ||
| 51 | it("LuaRocks install not a zip file", function() | 51 | it("LuaRocks install not a zip file", function() |
| @@ -66,15 +66,15 @@ describe("LuaRocks install tests #blackbox #b_install", function() | |||
| 66 | end) | 66 | end) |
| 67 | 67 | ||
| 68 | it("LuaRocks install luasec and show luasocket (dependency)", function() | 68 | it("LuaRocks install luasec and show luasocket (dependency)", function() |
| 69 | assert.is_true(run.luarocks_bool("install luasec")) | 69 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) |
| 70 | assert.is_true(run.luarocks_bool("show luasocket")) | 70 | assert.is_true(run.luarocks_bool("show luasocket")) |
| 71 | end) | 71 | end) |
| 72 | end) | 72 | end) |
| 73 | 73 | ||
| 74 | describe("LuaRocks install - more complex tests", function() | 74 | describe("LuaRocks install - more complex tests", function() |
| 75 | it('LuaRocks install luasec with skipping dependency checks', function() | 75 | it('LuaRocks install luasec with skipping dependency checks', function() |
| 76 | run.luarocks_bool(test_env.quiet(" install luasec --nodeps")) | 76 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS .. " --nodeps")) |
| 77 | assert.is_true(run.luarocks_bool(test_env.quiet("show luasec"))) | 77 | assert.is_true(run.luarocks_bool("show luasec")) |
| 78 | if env_variables.TYPE_TEST_ENV == "minimal" then | 78 | if env_variables.TYPE_TEST_ENV == "minimal" then |
| 79 | assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) | 79 | assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) |
| 80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | 80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) |
| @@ -83,21 +83,21 @@ describe("LuaRocks install tests #blackbox #b_install", function() | |||
| 83 | end) | 83 | end) |
| 84 | 84 | ||
| 85 | it("LuaRocks install only-deps of luasocket packed rock", function() | 85 | it("LuaRocks install only-deps of luasocket packed rock", function() |
| 86 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) | 86 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) |
| 87 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock") | 87 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") |
| 88 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") | 88 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-2") |
| 89 | assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 89 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
| 90 | end) | 90 | end) |
| 91 | 91 | ||
| 92 | it("LuaRocks install reinstall", function() | 92 | it("LuaRocks install reinstall", function() |
| 93 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) | 93 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) |
| 94 | assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 94 | assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
| 95 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 95 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
| 96 | assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 96 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
| 97 | end) | 97 | end) |
| 98 | 98 | ||
| 99 | it("LuaRocks install binary rock of cprint", function() | 99 | it("LuaRocks install binary rock of cprint", function() |
| 100 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock cprint"))) | 100 | assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) |
| 101 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) | 101 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) |
| 102 | assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) | 102 | assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) |
| 103 | end) | 103 | end) |
diff --git a/spec/make_manifest_spec.lua b/spec/make_manifest_spec.lua index 1c7f5bf8..3e998cbf 100644 --- a/spec/make_manifest_spec.lua +++ b/spec/make_manifest_spec.lua | |||
| @@ -4,7 +4,7 @@ local run = test_env.run | |||
| 4 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 5 | 5 | ||
| 6 | describe("LuaRocks make_manifest tests #blackbox #b_make_manifest", function() | 6 | describe("LuaRocks make_manifest tests #blackbox #b_make_manifest", function() |
| 7 | 7 | ||
| 8 | before_each(function() | 8 | before_each(function() |
| 9 | test_env.setup_specs() | 9 | test_env.setup_specs() |
| 10 | end) | 10 | end) |
diff --git a/spec/make_spec.lua b/spec/make_spec.lua index e684033a..ae79a29c 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua | |||
| @@ -6,9 +6,9 @@ local testing_paths = test_env.testing_paths | |||
| 6 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 7 | 7 | ||
| 8 | local extra_rocks = { | 8 | local extra_rocks = { |
| 9 | "/lpeg-0.12-1.src.rock", | 9 | "lpeg-1.0.0-1.rockspec", |
| 10 | "/luasocket-3.0rc1-1.src.rock", | 10 | "/luasocket-3.0rc1-2.src.rock", |
| 11 | "/luasocket-3.0rc1-1.rockspec", | 11 | "/luasocket-3.0rc1-2.rockspec", |
| 12 | "/lxsh-0.8.6-2.src.rock", | 12 | "/lxsh-0.8.6-2.src.rock", |
| 13 | "/lxsh-0.8.6-2.rockspec" | 13 | "/lxsh-0.8.6-2.rockspec" |
| 14 | } | 14 | } |
| @@ -27,19 +27,19 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
| 27 | 27 | ||
| 28 | it("LuaRocks make with rockspec", function() | 28 | it("LuaRocks make with rockspec", function() |
| 29 | -- make luasocket | 29 | -- make luasocket |
| 30 | assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-1")) | 30 | assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2")) |
| 31 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-1.src.rock")) | 31 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) |
| 32 | lfs.chdir("luasocket-3.0rc1-1/luasocket-3.0-rc1/") | 32 | lfs.chdir("luasocket-3.0rc1-2/luasocket-3.0-rc1/") |
| 33 | assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-1.rockspec"))) | 33 | assert.is_true(run.luarocks_bool("make luasocket-3.0rc1-2.rockspec")) |
| 34 | 34 | ||
| 35 | -- test it | 35 | -- test it |
| 36 | assert.is_true(run.luarocks_bool(test_env.quiet("show luasocket"))) | 36 | assert.is_true(run.luarocks_bool("show luasocket")) |
| 37 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | 37 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) |
| 38 | 38 | ||
| 39 | -- delete downloaded and unpacked files | 39 | -- delete downloaded and unpacked files |
| 40 | lfs.chdir(testing_paths.luarocks_dir) | 40 | lfs.chdir(testing_paths.luarocks_dir) |
| 41 | test_env.remove_dir("luasocket-3.0rc1-1") | 41 | test_env.remove_dir("luasocket-3.0rc1-2") |
| 42 | assert.is_true(os.remove("luasocket-3.0rc1-1.src.rock")) | 42 | assert.is_true(os.remove("luasocket-3.0rc1-2.src.rock")) |
| 43 | end) | 43 | end) |
| 44 | 44 | ||
| 45 | describe("LuaRocks making rockspecs (using lxsh)", function() | 45 | describe("LuaRocks making rockspecs (using lxsh)", function() |
| @@ -61,37 +61,40 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
| 61 | assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) | 61 | assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) |
| 62 | assert.is_true(run.luarocks_bool("make")) | 62 | assert.is_true(run.luarocks_bool("make")) |
| 63 | 63 | ||
| 64 | assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh"))) | 64 | assert.is_true(run.luarocks_bool("show lxsh")) |
| 65 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 65 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-3/lxsh-0.8.6-3.rockspec")) |
| 66 | end) | 66 | end) |
| 67 | 67 | ||
| 68 | it("LuaRocks make unnamed rockspec", function() | 68 | it("LuaRocks make unnamed rockspec", function() |
| 69 | os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs | 69 | test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec") |
| 70 | assert.is_true(run.luarocks_bool("make")) | 70 | assert.is_true(run.luarocks_bool("make")) |
| 71 | 71 | ||
| 72 | assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh"))) | 72 | assert.is_true(run.luarocks_bool("show lxsh")) |
| 73 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 73 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 74 | os.remove("rockspec") | ||
| 74 | end) | 75 | end) |
| 75 | 76 | ||
| 76 | it("LuaRocks make ambiguous rockspec", function() | 77 | it("LuaRocks make ambiguous rockspec", function() |
| 77 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) | 78 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) |
| 78 | assert.is_false(run.luarocks_bool("make")) | 79 | local output = run.luarocks("make") |
| 80 | assert.is.truthy(output:match("Error: Inconsistency between rockspec filename")) | ||
| 79 | 81 | ||
| 80 | assert.is_false(run.luarocks_bool("show lxsh")) | 82 | assert.is_false(run.luarocks_bool("show lxsh")) |
| 81 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 83 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 82 | end) | 84 | end) |
| 83 | 85 | ||
| 84 | it("LuaRocks make ambiguous unnamed rockspec", function() | 86 | it("LuaRocks make ambiguous unnamed rockspec", function() |
| 85 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec")) | 87 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec")) |
| 86 | os.execute("cp 1_rockspec 2_rockspec") --rewrite with lfs | 88 | test_env.copy("1_rockspec", "2_rockspec") |
| 87 | assert.is_false(run.luarocks_bool("make")) | 89 | local output = run.luarocks("make") |
| 90 | assert.is.truthy(output:match("Error: Please specify which rockspec file to use")) | ||
| 88 | 91 | ||
| 89 | assert.is_false(run.luarocks_bool("show lxsh")) | 92 | assert.is_false(run.luarocks_bool("show lxsh")) |
| 90 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | 93 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) |
| 91 | end) | 94 | end) |
| 92 | 95 | ||
| 93 | it("LuaRocks make pack binary rock", function() | 96 | it("LuaRocks make pack binary rock", function() |
| 94 | assert.is_true(run.luarocks_bool(test_env.quiet("make --deps-mode=none --pack-binary-rock"))) | 97 | assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) |
| 95 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) | 98 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) |
| 96 | end) | 99 | end) |
| 97 | end) | 100 | end) |
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 0e5b31c6..0c6dd8f2 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua | |||
| @@ -6,9 +6,10 @@ local testing_paths = test_env.testing_paths | |||
| 6 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 7 | 7 | ||
| 8 | local extra_rocks = { | 8 | local extra_rocks = { |
| 9 | "/luasec-0.6-1.rockspec", | 9 | "/luasec-0.6-1.rockspec", |
| 10 | "/luasocket-3.0rc1-1.src.rock", | 10 | "/luassert-1.7.0-1.src.rock", |
| 11 | "/luasocket-3.0rc1-1.rockspec", | 11 | "/luasocket-3.0rc1-2.src.rock", |
| 12 | "/luasocket-3.0rc1-2.rockspec", | ||
| 12 | "/say-1.2-1.src.rock", | 13 | "/say-1.2-1.src.rock", |
| 13 | "/say-1.0-1.src.rock" | 14 | "/say-1.0-1.src.rock" |
| 14 | } | 15 | } |
| @@ -24,7 +25,7 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() | |||
| 24 | end) | 25 | end) |
| 25 | 26 | ||
| 26 | it("LuaRocks pack basic", function() | 27 | it("LuaRocks pack basic", function() |
| 27 | assert.is_true(run.luarocks_bool(test_env.quiet("pack luacov"))) | 28 | assert.is_true(run.luarocks_bool("pack luacov")) |
| 28 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) | 29 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) |
| 29 | end) | 30 | end) |
| 30 | 31 | ||
| @@ -40,18 +41,19 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() | |||
| 40 | assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif")) | 41 | assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif")) |
| 41 | end) | 42 | end) |
| 42 | 43 | ||
| 43 | it("LuaRocks pack specify which version of rock", function() | 44 | it("LuaRocks pack detects latest version version of rock", function() |
| 44 | assert.is_true(run.luarocks_bool("install say 1.2")) | 45 | assert.is_true(run.luarocks_bool("install say 1.2")) |
| 45 | assert.is_true(run.luarocks_bool("install luassert")) | 46 | assert.is_true(run.luarocks_bool("install luassert")) |
| 46 | assert.is_true(run.luarocks_bool("install say 1.0")) | 47 | assert.is_true(run.luarocks_bool("install say 1.0")) |
| 47 | 48 | assert.is_true(run.luarocks_bool("pack say")) | |
| 48 | assert.is_false(run.luarocks_bool("pack say")) | 49 | assert.is_truthy(lfs.attributes("say-1.2-1.all.rock")) |
| 50 | assert.is_true(test_env.remove_files(lfs.currentdir(), "say-")) | ||
| 49 | end) | 51 | end) |
| 50 | 52 | ||
| 51 | it("LuaRocks pack src", function() | 53 | it("LuaRocks pack src", function() |
| 52 | assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) | 54 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) |
| 53 | assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-1")) | 55 | assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2")) |
| 54 | assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-1.rockspec")) | 56 | assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec")) |
| 55 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) | 57 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) |
| 56 | end) | 58 | end) |
| 57 | end) | 59 | end) |
diff --git a/spec/refresh_cache_spec.lua b/spec/refresh_cache_spec.lua index c20771ab..09f5645e 100644 --- a/spec/refresh_cache_spec.lua +++ b/spec/refresh_cache_spec.lua | |||
| @@ -4,7 +4,7 @@ local run = test_env.run | |||
| 4 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 5 | 5 | ||
| 6 | describe("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function() | 6 | describe("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function() |
| 7 | 7 | ||
| 8 | before_each(function() | 8 | before_each(function() |
| 9 | test_env.setup_specs() | 9 | test_env.setup_specs() |
| 10 | end) | 10 | end) |
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index 7bf1bb10..3d321e30 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua | |||
| @@ -8,8 +8,8 @@ test_env.unload_luarocks() | |||
| 8 | local extra_rocks = { | 8 | local extra_rocks = { |
| 9 | "/abelhas-1.0-1.rockspec", | 9 | "/abelhas-1.0-1.rockspec", |
| 10 | "/lualogging-1.3.0-1.src.rock", | 10 | "/lualogging-1.3.0-1.src.rock", |
| 11 | "/luasocket-3.0rc1-1.src.rock", | 11 | "/luasocket-3.0rc1-2.src.rock", |
| 12 | "/luasocket-3.0rc1-1.rockspec" | 12 | "/luasocket-3.0rc1-2.rockspec" |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | describe("LuaRocks remove tests #blackbox #b_remove", function() | 15 | describe("LuaRocks remove tests #blackbox #b_remove", function() |
| @@ -76,7 +76,7 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() | |||
| 76 | end) | 76 | end) |
| 77 | 77 | ||
| 78 | it("LuaRocks-admin remove #ssh", function() | 78 | it("LuaRocks-admin remove #ssh", function() |
| 79 | assert.is_true(run.luarocks_admin_bool("--server=testing remove luasocket-3.0rc1-1.src.rock")) | 79 | assert.is_true(run.luarocks_admin_bool("--server=testing remove luasocket-3.0rc1-2.src.rock")) |
| 80 | end) | 80 | end) |
| 81 | 81 | ||
| 82 | it("LuaRocks-admin remove missing", function() | 82 | it("LuaRocks-admin remove missing", function() |
diff --git a/spec/search_spec.lua b/spec/search_spec.lua index b31624b8..04f84eeb 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua | |||
| @@ -30,7 +30,6 @@ describe("LuaRocks search tests #blackbox #b_search", function() | |||
| 30 | end) | 30 | end) |
| 31 | 31 | ||
| 32 | it("LuaRocks search with flag all", function() | 32 | it("LuaRocks search with flag all", function() |
| 33 | assert.is_true(run.luarocks_bool(test_env.quiet("search --all"))) | 33 | assert.is_true(run.luarocks_bool("search --all")) |
| 34 | end) | 34 | end) |
| 35 | |||
| 36 | end) | 35 | end) |
diff --git a/spec/show_spec.lua b/spec/show_spec.lua index f528a6de..b2cdc07e 100644 --- a/spec/show_spec.lua +++ b/spec/show_spec.lua | |||
| @@ -20,10 +20,12 @@ describe("LuaRocks show tests #blackbox #b_show", function() | |||
| 20 | 20 | ||
| 21 | it("LuaRocks show luacov", function() | 21 | it("LuaRocks show luacov", function() |
| 22 | local output = run.luarocks("show luacov") | 22 | local output = run.luarocks("show luacov") |
| 23 | assert.is.truthy(output:match("LuaCov")) | ||
| 23 | end) | 24 | end) |
| 24 | 25 | ||
| 25 | it("LuaRocks show modules of luacov", function() | 26 | it("LuaRocks show modules of luacov", function() |
| 26 | local output = run.luarocks("show --modules luacov") | 27 | local output = run.luarocks("show --modules luacov") |
| 28 | assert.is.truthy(output:match("luacovluacov.defaultsluacov.reporterluacov.reporter.defaultluacov.runnerluacov.statsluacov.tick")) | ||
| 27 | end) | 29 | end) |
| 28 | 30 | ||
| 29 | it("LuaRocks show dependencies of luacov", function() | 31 | it("LuaRocks show dependencies of luacov", function() |
| @@ -32,10 +34,12 @@ describe("LuaRocks show tests #blackbox #b_show", function() | |||
| 32 | 34 | ||
| 33 | it("LuaRocks show rockspec of luacov", function() | 35 | it("LuaRocks show rockspec of luacov", function() |
| 34 | local output = run.luarocks("show --rockspec luacov") | 36 | local output = run.luarocks("show --rockspec luacov") |
| 37 | assert.is.truthy(output:match("luacov--0.11.0--1.rockspec")) | ||
| 35 | end) | 38 | end) |
| 36 | 39 | ||
| 37 | it("LuaRocks show mversion of luacov", function() | 40 | it("LuaRocks show mversion of luacov", function() |
| 38 | local output = run.luarocks("show --mversion luacov") | 41 | local output = run.luarocks("show --mversion luacov") |
| 42 | assert.is.truthy(output:match("0.11.0--1")) | ||
| 39 | end) | 43 | end) |
| 40 | 44 | ||
| 41 | it("LuaRocks show rock tree of luacov", function() | 45 | it("LuaRocks show rock tree of luacov", function() |
| @@ -49,6 +53,6 @@ describe("LuaRocks show tests #blackbox #b_show", function() | |||
| 49 | 53 | ||
| 50 | it("LuaRocks show old version of luacov", function() | 54 | it("LuaRocks show old version of luacov", function() |
| 51 | run.luarocks("install luacov 0.11.0") | 55 | run.luarocks("install luacov 0.11.0") |
| 52 | run.luarocks("show luacov 0.11.0") | 56 | run.luarocks_bool("show luacov 0.11.0") |
| 53 | end) | 57 | end) |
| 54 | end) | 58 | end) |
diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua index 8db779c3..a0fc370d 100644 --- a/spec/unpack_spec.lua +++ b/spec/unpack_spec.lua | |||
| @@ -1,14 +1,12 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | 2 | local run = test_env.run |
| 3 | local testing_paths = test_env.testing_paths | 3 | local testing_paths = test_env.testing_paths |
| 4 | local lfs = require("lfs") | ||
| 5 | 4 | ||
| 6 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 7 | 6 | ||
| 8 | local extra_rocks = { | 7 | local extra_rocks = { |
| 9 | "/cprint-0.1-2.src.rock", | 8 | "/cprint-0.1-2.src.rock", |
| 10 | "/cprint-0.1-2.rockspec", | 9 | "/cprint-0.1-2.rockspec" |
| 11 | "/luazip-1.2.4-1.rockspec" | ||
| 12 | } | 10 | } |
| 13 | 11 | ||
| 14 | describe("LuaRocks unpack tests #blackbox #b_unpack", function() | 12 | describe("LuaRocks unpack tests #blackbox #b_unpack", function() |
| @@ -21,9 +19,11 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function() | |||
| 21 | it("LuaRocks unpack with no flags/arguments", function() | 19 | it("LuaRocks unpack with no flags/arguments", function() |
| 22 | assert.is_false(run.luarocks_bool("unpack")) | 20 | assert.is_false(run.luarocks_bool("unpack")) |
| 23 | end) | 21 | end) |
| 22 | |||
| 24 | it("LuaRocks unpack with invalid rockspec", function() | 23 | it("LuaRocks unpack with invalid rockspec", function() |
| 25 | assert.is_false(run.luarocks_bool("unpack invalid.rockspec")) | 24 | assert.is_false(run.luarocks_bool("unpack invalid.rockspec")) |
| 26 | end) | 25 | end) |
| 26 | |||
| 27 | it("LuaRocks unpack with invalid patch", function() | 27 | it("LuaRocks unpack with invalid patch", function() |
| 28 | assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | 28 | assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) |
| 29 | end) | 29 | end) |
| @@ -34,19 +34,22 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function() | |||
| 34 | assert.is_true(run.luarocks_bool("unpack cprint")) | 34 | assert.is_true(run.luarocks_bool("unpack cprint")) |
| 35 | test_env.remove_dir("cprint-0.1-2") | 35 | test_env.remove_dir("cprint-0.1-2") |
| 36 | end) | 36 | end) |
| 37 | |||
| 37 | it("LuaRocks unpack src", function() | 38 | it("LuaRocks unpack src", function() |
| 38 | assert.is_true(run.luarocks_bool("download --source cprint")) | 39 | assert.is_true(run.luarocks_bool("download --source cprint")) |
| 39 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock")) | 40 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock")) |
| 40 | os.remove("cprint-0.1-2.src.rock") | 41 | os.remove("cprint-0.1-2.src.rock") |
| 41 | test_env.remove_dir("cprint-0.1-2") | 42 | test_env.remove_dir("cprint-0.1-2") |
| 42 | end) | 43 | end) |
| 43 | it("LuaRocks unpack rockspec", function() | 44 | |
| 45 | it("LuaRocks unpack src", function() | ||
| 44 | assert.is_true(run.luarocks_bool("download --rockspec cprint")) | 46 | assert.is_true(run.luarocks_bool("download --rockspec cprint")) |
| 45 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec")) | 47 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec")) |
| 46 | os.remove("cprint-0.1-2.rockspec") | 48 | os.remove("cprint-0.1-2.rockspec") |
| 47 | os.remove("lua-cprint") | 49 | os.remove("lua-cprint") |
| 48 | test_env.remove_dir("cprint-0.1-2") | 50 | test_env.remove_dir("cprint-0.1-2") |
| 49 | end) | 51 | end) |
| 52 | |||
| 50 | -- #595 luarocks unpack of a git:// rockspec fails to copy the rockspec | 53 | -- #595 luarocks unpack of a git:// rockspec fails to copy the rockspec |
| 51 | it("LuaRocks unpack git:// rockspec", function() | 54 | it("LuaRocks unpack git:// rockspec", function() |
| 52 | assert.is_true(run.luarocks_bool("download --rockspec luazip")) | 55 | assert.is_true(run.luarocks_bool("download --rockspec luazip")) |
| @@ -54,6 +57,7 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function() | |||
| 54 | assert.is_truthy(lfs.attributes("luazip-1.2.4-1/luazip/luazip-1.2.4-1.rockspec")) | 57 | assert.is_truthy(lfs.attributes("luazip-1.2.4-1/luazip/luazip-1.2.4-1.rockspec")) |
| 55 | test_env.remove_dir("luazip-1.2.4-1") | 58 | test_env.remove_dir("luazip-1.2.4-1") |
| 56 | end) | 59 | end) |
| 60 | |||
| 57 | it("LuaRocks unpack binary", function() | 61 | it("LuaRocks unpack binary", function() |
| 58 | assert.is_true(run.luarocks_bool("build cprint")) | 62 | assert.is_true(run.luarocks_bool("build cprint")) |
| 59 | assert.is_true(run.luarocks_bool("pack cprint")) | 63 | assert.is_true(run.luarocks_bool("pack cprint")) |
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index c68a1cdf..ff39cb96 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua | |||
| @@ -45,7 +45,7 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() | |||
| 45 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec")) | 45 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec")) |
| 46 | end) | 46 | end) |
| 47 | 47 | ||
| 48 | it("LuaRocks upload force", function() | 48 | it("LuaRocks upload force #unix", function() |
| 49 | assert.is_true(run.luarocks_bool("install lua-cjson")) | 49 | assert.is_true(run.luarocks_bool("install lua-cjson")) |
| 50 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec")) | 50 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec")) |
| 51 | assert.is_true(run.luarocks_bool("install lua-cjson")) | 51 | assert.is_true(run.luarocks_bool("install lua-cjson")) |
| @@ -63,10 +63,10 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() | |||
| 63 | end) | 63 | end) |
| 64 | 64 | ||
| 65 | it("LuaRocks upload rockspec with api-key", function() | 65 | it("LuaRocks upload rockspec with api-key", function() |
| 66 | assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) | 66 | assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.OPENSSL_DIRS .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) |
| 67 | end) | 67 | end) |
| 68 | it("LuaRocks upload rockspec with api-key and skip-pack", function() | 68 | it("LuaRocks upload rockspec with api-key and skip-pack", function() |
| 69 | assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) | 69 | assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.OPENSSL_DIRS .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) |
| 70 | end) | 70 | end) |
| 71 | end) | 71 | end) |
| 72 | end) | 72 | end) |
diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 23e3ebd8..2779b1ce 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua | |||
| @@ -27,7 +27,7 @@ describe("Basic tests #blackbox #b_util", function() | |||
| 27 | assert.is_false(run.luarocks_bool("invalid=5")) | 27 | assert.is_false(run.luarocks_bool("invalid=5")) |
| 28 | end) | 28 | end) |
| 29 | 29 | ||
| 30 | it("LuaRocks execute from not existing directory", function() | 30 | it("LuaRocks execute from not existing directory #unix", function() |
| 31 | local main_path = lfs.currentdir() | 31 | local main_path = lfs.currentdir() |
| 32 | assert.is_true(lfs.mkdir("idontexist")) | 32 | assert.is_true(lfs.mkdir("idontexist")) |
| 33 | assert.is_true(lfs.chdir("idontexist")) | 33 | assert.is_true(lfs.chdir("idontexist")) |
| @@ -66,34 +66,109 @@ describe("Basic tests #blackbox #b_util", function() | |||
| 66 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua")) | 66 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua")) |
| 67 | end) | 67 | end) |
| 68 | 68 | ||
| 69 | describe("LuaRocks sysconfig fails", function() | 69 | -- Disable versioned config temporarily, because it always takes |
| 70 | local scdir = "" | 70 | -- precedence over config.lua (config-5.x.lua is installed by default on Windows, |
| 71 | 71 | -- but not on Unix, so on Unix the os.rename commands below will fail silently, but this is harmless) | |
| 72 | before_each(function() | 72 | describe("LuaRocks config - more complex tests", function() |
| 73 | scdir = testing_paths.testing_lrprefix .. "/etc/luarocks/" | 73 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" |
| 74 | local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" | ||
| 75 | local scname = scdir .. "/config.lua" | ||
| 76 | |||
| 77 | local configfile | ||
| 78 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 79 | configfile = versioned_scname | ||
| 80 | else | ||
| 81 | configfile = scname | ||
| 82 | end | ||
| 83 | |||
| 84 | it("LuaRocks fail system config", function() | ||
| 85 | os.rename(versioned_scname, versioned_scname .. "bak") | ||
| 86 | local ok = run.luarocks_bool("config --system-config") | ||
| 87 | os.rename(versioned_scname .. ".bak", versioned_scname) | ||
| 88 | assert.is_false(ok) | ||
| 89 | end) | ||
| 90 | |||
| 91 | it("LuaRocks system config", function() | ||
| 74 | lfs.mkdir(testing_paths.testing_lrprefix) | 92 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 75 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | 93 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 76 | lfs.mkdir(scdir) | 94 | lfs.mkdir(scdir) |
| 95 | |||
| 96 | local sysconfig = io.open(configfile, "w+") | ||
| 97 | sysconfig:write(" ") | ||
| 98 | sysconfig:close() | ||
| 99 | |||
| 100 | local output = run.luarocks("config --system-config") | ||
| 101 | os.remove(configfile) | ||
| 102 | assert.are.same(output, configfile) | ||
| 77 | end) | 103 | end) |
| 78 | 104 | ||
| 79 | after_each(function() | 105 | it("LuaRocks fail system config invalid", function() |
| 80 | test_env.remove_dir(testing_paths.testing_lrprefix) | 106 | lfs.mkdir(testing_paths.testing_lrprefix) |
| 81 | end) | 107 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") |
| 108 | lfs.mkdir(scdir) | ||
| 82 | 109 | ||
| 83 | it("LuaRocks sysconfig fail", function() | 110 | local sysconfig = io.open(configfile, "w+") |
| 84 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | 111 | sysconfig:write("if if if") |
| 85 | sysconfig:write("aoeui") | ||
| 86 | sysconfig:close() | 112 | sysconfig:close() |
| 113 | local ok = run.luarocks_bool("config --system-config") | ||
| 114 | os.remove(configfile) | ||
| 115 | assert.is_false(ok) | ||
| 116 | end) | ||
| 117 | end) | ||
| 118 | end) | ||
| 87 | 119 | ||
| 88 | assert.is_false(run.luarocks_bool("list")) | 120 | test_env.unload_luarocks() |
| 121 | local util = require("luarocks.util") | ||
| 122 | |||
| 123 | describe("Luarocks util test #whitebox #w_util", function() | ||
| 124 | describe("util.sortedpairs", function() | ||
| 125 | local function collect(iter, state, var) | ||
| 126 | local collected = {} | ||
| 127 | |||
| 128 | while true do | ||
| 129 | local returns = {iter(state, var)} | ||
| 130 | |||
| 131 | if returns[1] == nil then | ||
| 132 | return collected | ||
| 133 | else | ||
| 134 | table.insert(collected, returns) | ||
| 135 | var = returns[1] | ||
| 136 | end | ||
| 137 | end | ||
| 138 | end | ||
| 139 | |||
| 140 | it("default sort", function() | ||
| 141 | assert.are.same({}, collect(util.sortedpairs({}))) | ||
| 142 | assert.are.same({ | ||
| 143 | {1, "v1"}, | ||
| 144 | {2, "v2"}, | ||
| 145 | {3, "v3"}, | ||
| 146 | {"bar", "v5"}, | ||
| 147 | {"foo", "v4"} | ||
| 148 | }, collect(util.sortedpairs({"v1", "v2", "v3", foo = "v4", bar = "v5"}))) | ||
| 89 | end) | 149 | end) |
| 90 | 150 | ||
| 91 | it("LuaRocks sysconfig fail", function() | 151 | it("sort by function", function() |
| 92 | local sysconfig = io.open(scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua", "w+") | 152 | local function compare(a, b) return a > b end |
| 93 | sysconfig:write("aoeui") | 153 | assert.are.same({}, collect(util.sortedpairs({}, compare))) |
| 94 | sysconfig:close() | 154 | assert.are.same({ |
| 155 | {3, "v3"}, | ||
| 156 | {2, "v2"}, | ||
| 157 | {1, "v1"} | ||
| 158 | }, collect(util.sortedpairs({"v1", "v2", "v3"}, compare))) | ||
| 159 | end) | ||
| 95 | 160 | ||
| 96 | assert.is_false(run.luarocks_bool("list")) | 161 | it("sort by priority table", function() |
| 162 | assert.are.same({}, collect(util.sortedpairs({}, {"k1", "k2"}))) | ||
| 163 | assert.are.same({ | ||
| 164 | {"k3", "v3"}, | ||
| 165 | {"k2", "v2", {"sub order"}}, | ||
| 166 | {"k1", "v1"}, | ||
| 167 | {"k4", "v4"}, | ||
| 168 | {"k5", "v5"}, | ||
| 169 | }, collect(util.sortedpairs({ | ||
| 170 | k1 = "v1", k2 = "v2", k3 = "v3", k4 = "v4", k5 = "v5" | ||
| 171 | }, {"k3", {"k2", {"sub order"}}, "k1"}))) | ||
| 97 | end) | 172 | end) |
| 98 | end) | 173 | end) |
| 99 | end) | 174 | end) |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 73bff097..b5c60ed1 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
| @@ -6,10 +6,9 @@ | |||
| 6 | -- file format documentation</a> for details. | 6 | -- file format documentation</a> for details. |
| 7 | -- | 7 | -- |
| 8 | -- End-users shouldn't edit this file. They can override any defaults | 8 | -- End-users shouldn't edit this file. They can override any defaults |
| 9 | -- set in this file using their system-wide $LUAROCKS_SYSCONFIG file | 9 | -- set in this file using their system-wide or user-specific configuration |
| 10 | -- (see luarocks.site_config) or their user-specific configuration file | 10 | -- files. Run `luarocks` with no arguments to see the locations of |
| 11 | -- (~/.luarocks/config.lua on Unix or %APPDATA%/luarocks/config.lua on | 11 | -- these files in your platform. |
| 12 | -- Windows). | ||
| 13 | 12 | ||
| 14 | local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, tonumber, type, assert, _VERSION = | 13 | local rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, tonumber, type, assert, _VERSION = |
| 15 | rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, tonumber, type, assert, _VERSION | 14 | rawset, next, table, pairs, require, io, os, setmetatable, pcall, ipairs, package, tonumber, type, assert, _VERSION |
| @@ -477,6 +476,7 @@ if cfg.platforms.mingw32 then | |||
| 477 | defaults.variables.RANLIB = "ranlib" | 476 | defaults.variables.RANLIB = "ranlib" |
| 478 | defaults.variables.CFLAGS = "-O2" | 477 | defaults.variables.CFLAGS = "-O2" |
| 479 | defaults.variables.LIBFLAG = "-shared" | 478 | defaults.variables.LIBFLAG = "-shared" |
| 479 | defaults.makefile = "Makefile" | ||
| 480 | defaults.external_deps_patterns = { | 480 | defaults.external_deps_patterns = { |
| 481 | bin = { "?.exe", "?.bat" }, | 481 | bin = { "?.exe", "?.bat" }, |
| 482 | -- mingw lookup list from http://stackoverflow.com/a/15853231/1793220 | 482 | -- mingw lookup list from http://stackoverflow.com/a/15853231/1793220 |
diff --git a/src/luarocks/core/util.lua b/src/luarocks/core/util.lua index f2e409d1..85b59af6 100644 --- a/src/luarocks/core/util.lua +++ b/src/luarocks/core/util.lua | |||
| @@ -213,52 +213,59 @@ local function default_sort(a, b) | |||
| 213 | end | 213 | end |
| 214 | end | 214 | end |
| 215 | 215 | ||
| 216 | --- The iterator function used internally by util.sortedpairs. | 216 | --- A table iterator generator that returns elements sorted by key, |
| 217 | -- to be used in "for" loops. | ||
| 217 | -- @param tbl table: The table to be iterated. | 218 | -- @param tbl table: The table to be iterated. |
| 218 | -- @param sort_function function or nil: An optional comparison function | 219 | -- @param sort_function function or table or nil: An optional comparison function |
| 219 | -- to be used by table.sort when sorting keys. | 220 | -- to be used by table.sort when sorting keys, or an array listing an explicit order |
| 220 | -- @see sortedpairs | 221 | -- for keys. If a value itself is an array, it is taken so that the first element |
| 221 | local function sortedpairs_iterator(tbl, sort_function) | 222 | -- is a string representing the field name, and the second element is a priority table |
| 222 | local ks = util.keys(tbl) | 223 | -- for that key, which is returned by the iterator as the third value after the key |
| 223 | if not sort_function or type(sort_function) == "function" then | 224 | -- and the value. |
| 224 | table.sort(ks, sort_function or default_sort) | 225 | -- @return function: the iterator function. |
| 225 | for _, k in ipairs(ks) do | 226 | function util.sortedpairs(tbl, sort_function) |
| 226 | coroutine.yield(k, tbl[k]) | 227 | sort_function = sort_function or default_sort |
| 227 | end | 228 | local keys = util.keys(tbl) |
| 229 | local sub_orders = {} | ||
| 230 | |||
| 231 | if type(sort_function) == "function" then | ||
| 232 | table.sort(keys, sort_function) | ||
| 228 | else | 233 | else |
| 229 | local order = sort_function | 234 | local order = sort_function |
| 230 | local done = {} | 235 | local ordered_keys = {} |
| 231 | for _, k in ipairs(order) do | 236 | local all_keys = keys |
| 232 | local sub_order | 237 | keys = {} |
| 233 | if type(k) == "table" then | 238 | |
| 234 | sub_order = k[2] | 239 | for _, order_entry in ipairs(order) do |
| 235 | k = k[1] | 240 | local key, sub_order |
| 241 | if type(order_entry) == "table" then | ||
| 242 | key = order_entry[1] | ||
| 243 | sub_order = order_entry[2] | ||
| 244 | else | ||
| 245 | key = order_entry | ||
| 236 | end | 246 | end |
| 237 | if tbl[k] then | 247 | |
| 238 | done[k] = true | 248 | if tbl[key] then |
| 239 | coroutine.yield(k, tbl[k], sub_order) | 249 | ordered_keys[key] = true |
| 250 | sub_orders[key] = sub_order | ||
| 251 | table.insert(keys, key) | ||
| 240 | end | 252 | end |
| 241 | end | 253 | end |
| 242 | table.sort(ks, default_sort) | 254 | |
| 243 | for _, k in ipairs(ks) do | 255 | table.sort(all_keys, default_sort) |
| 244 | if not done[k] then | 256 | for _, key in ipairs(all_keys) do |
| 245 | coroutine.yield(k, tbl[k]) | 257 | if not ordered_keys[key] then |
| 258 | table.insert(keys, key) | ||
| 246 | end | 259 | end |
| 247 | end | 260 | end |
| 248 | end | 261 | end |
| 249 | end | ||
| 250 | 262 | ||
| 251 | --- A table iterator generator that returns elements sorted by key, | 263 | local i = 1 |
| 252 | -- to be used in "for" loops. | 264 | return function() |
| 253 | -- @param tbl table: The table to be iterated. | 265 | local key = keys[i] |
| 254 | -- @param sort_function function or table or nil: An optional comparison function | 266 | i = i + 1 |
| 255 | -- to be used by table.sort when sorting keys, or an array listing an explicit order | 267 | return key, tbl[key], sub_orders[key] |
| 256 | -- for keys. If a value itself is an array, it is taken so that the first element | 268 | end |
| 257 | -- is a string representing the field name, and the second element is a priority table | ||
| 258 | -- for that key. | ||
| 259 | -- @return function: the iterator function. | ||
| 260 | function util.sortedpairs(tbl, sort_function) | ||
| 261 | return coroutine.wrap(function() sortedpairs_iterator(tbl, sort_function) end) | ||
| 262 | end | 269 | end |
| 263 | 270 | ||
| 264 | return util | 271 | return util |
diff --git a/src/luarocks/doc.lua b/src/luarocks/doc.lua index 8378bbc2..63c4c4e3 100644 --- a/src/luarocks/doc.lua +++ b/src/luarocks/doc.lua | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | local doc = {} | 4 | local doc = {} |
| 5 | 5 | ||
| 6 | local util = require("luarocks.util") | 6 | local util = require("luarocks.util") |
| 7 | local show = require("luarocks.show") | 7 | local search = require("luarocks.search") |
| 8 | local path = require("luarocks.path") | 8 | local path = require("luarocks.path") |
| 9 | local dir = require("luarocks.dir") | 9 | local dir = require("luarocks.dir") |
| 10 | local fetch = require("luarocks.fetch") | 10 | local fetch = require("luarocks.fetch") |
| @@ -61,7 +61,7 @@ function doc.command(flags, name, version) | |||
| 61 | return nil, "Argument missing. "..util.see_help("doc") | 61 | return nil, "Argument missing. "..util.see_help("doc") |
| 62 | end | 62 | end |
| 63 | 63 | ||
| 64 | local iname, iversion, repo = show.pick_installed_rock(name, version, flags["tree"]) | 64 | local iname, iversion, repo = search.pick_installed_rock(name, version, flags["tree"]) |
| 65 | if not iname then | 65 | if not iname then |
| 66 | util.printout(name..(version and " "..version or "").." is not installed. Looking for it in the rocks servers...") | 66 | util.printout(name..(version and " "..version or "").." is not installed. Looking for it in the rocks servers...") |
| 67 | return try_to_open_homepage(name, version) | 67 | return try_to_open_homepage(name, version) |
diff --git a/src/luarocks/loader.lua b/src/luarocks/loader.lua index 0faaebda..b8072110 100644 --- a/src/luarocks/loader.lua +++ b/src/luarocks/loader.lua | |||
| @@ -25,6 +25,28 @@ local util = require("luarocks.core.util") | |||
| 25 | local require = nil | 25 | local require = nil |
| 26 | -------------------------------------------------------------------------------- | 26 | -------------------------------------------------------------------------------- |
| 27 | 27 | ||
| 28 | -- Workaround for wrappers produced by older versions of LuaRocks | ||
| 29 | local temporary_global = false | ||
| 30 | if luarocks then | ||
| 31 | -- The site_config.lua file generated by old versions uses module(), | ||
| 32 | -- so it produces a global `luarocks` table. Since we have the table, | ||
| 33 | -- add the `loader` field to make the old wrappers happy. | ||
| 34 | luarocks.loader = loader | ||
| 35 | else | ||
| 36 | -- When a new version is installed on top of an old version, | ||
| 37 | -- site_config.lua may be replaced, and then it no longer creates | ||
| 38 | -- a global. | ||
| 39 | -- Detect when being called via -lluarocks.loader; this is | ||
| 40 | -- most likely a wrapper. | ||
| 41 | local info = debug.getinfo(2, "nS") | ||
| 42 | if info.what == "C" and not info.name then | ||
| 43 | luarocks = { loader = loader } | ||
| 44 | temporary_global = true | ||
| 45 | -- For the other half of this hack, | ||
| 46 | -- see the next use of `temporary_global` below. | ||
| 47 | end | ||
| 48 | end | ||
| 49 | |||
| 28 | loader.context = {} | 50 | loader.context = {} |
| 29 | 51 | ||
| 30 | -- Contains a table when rocks trees are loaded, | 52 | -- Contains a table when rocks trees are loaded, |
| @@ -58,6 +80,13 @@ function loader.add_context(name, version) | |||
| 58 | -- assert(type(name) == "string") | 80 | -- assert(type(name) == "string") |
| 59 | -- assert(type(version) == "string") | 81 | -- assert(type(version) == "string") |
| 60 | 82 | ||
| 83 | if temporary_global then | ||
| 84 | -- The first thing a wrapper does is to call add_context. | ||
| 85 | -- From here on, it's safe to clean the global environment. | ||
| 86 | luarocks = nil | ||
| 87 | temporary_global = false | ||
| 88 | end | ||
| 89 | |||
| 61 | if loader.context[name] then | 90 | if loader.context[name] then |
| 62 | return | 91 | return |
| 63 | end | 92 | end |
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index b85653e9..989d49ee 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
| @@ -83,38 +83,20 @@ end | |||
| 83 | 83 | ||
| 84 | -- @param name string: Name of package to pack. | 84 | -- @param name string: Name of package to pack. |
| 85 | -- @param version string or nil: A version number may also be passed. | 85 | -- @param version string or nil: A version number may also be passed. |
| 86 | -- @param tree string or nil: An optional tree to pick the package from. | ||
| 86 | -- @return string or (nil, string): The filename of the resulting | 87 | -- @return string or (nil, string): The filename of the resulting |
| 87 | -- .src.rock file; or nil and an error message. | 88 | -- .src.rock file; or nil and an error message. |
| 88 | local function do_pack_binary_rock(name, version) | 89 | local function do_pack_binary_rock(name, version, tree) |
| 89 | assert(type(name) == "string") | 90 | assert(type(name) == "string") |
| 90 | assert(type(version) == "string" or not version) | 91 | assert(type(version) == "string" or not version) |
| 91 | 92 | ||
| 92 | local query = search.make_query(name, version) | 93 | local repo, repo_url |
| 93 | query.exact_name = true | 94 | name, version, repo, repo_url = search.pick_installed_rock(name, version, tree) |
| 94 | local results = {} | 95 | if not name then |
| 95 | 96 | return nil, version | |
| 96 | search.manifest_search(results, cfg.rocks_dir, query) | ||
| 97 | |||
| 98 | if not next(results) then | ||
| 99 | return nil, "'"..name.."' does not seem to be an installed rock." | ||
| 100 | end | ||
| 101 | |||
| 102 | local versions = results[name] | ||
| 103 | |||
| 104 | if not version then | ||
| 105 | local first = next(versions) | ||
| 106 | if next(versions, first) then | ||
| 107 | return nil, "Please specify which version of '"..name.."' to pack." | ||
| 108 | end | ||
| 109 | version = first | ||
| 110 | end | ||
| 111 | if not version:match("[^-]+%-%d+") then | ||
| 112 | return nil, "Expected version "..version.." in version-revision format." | ||
| 113 | end | 97 | end |
| 114 | 98 | ||
| 115 | local info = versions[version][1] | 99 | local root = path.root_dir(repo_url) |
| 116 | |||
| 117 | local root = path.root_dir(info.repo) | ||
| 118 | local prefix = path.install_dir(name, version, root) | 100 | local prefix = path.install_dir(name, version, root) |
| 119 | if not fs.exists(prefix) then | 101 | if not fs.exists(prefix) then |
| 120 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." | 102 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." |
| @@ -180,7 +162,7 @@ function pack.pack_binary_rock(name, version, cmd, ...) | |||
| 180 | if not rname then | 162 | if not rname then |
| 181 | rname, rversion = name, version | 163 | rname, rversion = name, version |
| 182 | end | 164 | end |
| 183 | return do_pack_binary_rock(rname, rversion) | 165 | return do_pack_binary_rock(rname, rversion, temp_dir) |
| 184 | end | 166 | end |
| 185 | 167 | ||
| 186 | --- Driver function for the "pack" command. | 168 | --- Driver function for the "pack" command. |
| @@ -200,7 +182,7 @@ function pack.command(flags, arg, version) | |||
| 200 | if arg:match(".*%.rockspec") then | 182 | if arg:match(".*%.rockspec") then |
| 201 | file, err = pack.pack_source_rock(arg) | 183 | file, err = pack.pack_source_rock(arg) |
| 202 | else | 184 | else |
| 203 | file, err = do_pack_binary_rock(arg, version) | 185 | file, err = do_pack_binary_rock(arg, version, flags["tree"]) |
| 204 | end | 186 | end |
| 205 | if err then | 187 | if err then |
| 206 | return nil, err | 188 | return nil, err |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 7d4f3e81..44eff694 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
| @@ -415,6 +415,39 @@ function search.act_on_src_or_rockspec(action, name, version, ...) | |||
| 415 | return action(url, ...) | 415 | return action(url, ...) |
| 416 | end | 416 | end |
| 417 | 417 | ||
| 418 | function search.pick_installed_rock(name, version, given_tree) | ||
| 419 | local results = {} | ||
| 420 | local query = search.make_query(name, version) | ||
| 421 | query.exact_name = true | ||
| 422 | local tree_map = {} | ||
| 423 | local trees = cfg.rocks_trees | ||
| 424 | if given_tree then | ||
| 425 | trees = { given_tree } | ||
| 426 | end | ||
| 427 | for _, tree in ipairs(trees) do | ||
| 428 | local rocks_dir = path.rocks_dir(tree) | ||
| 429 | tree_map[rocks_dir] = tree | ||
| 430 | search.manifest_search(results, rocks_dir, query) | ||
| 431 | end | ||
| 432 | |||
| 433 | if not next(results) then -- | ||
| 434 | return nil,"cannot find package "..name.." "..(version or "").."\nUse 'list' to find installed rocks." | ||
| 435 | end | ||
| 436 | |||
| 437 | version = nil | ||
| 438 | local repo_url | ||
| 439 | local package, versions = util.sortedpairs(results)() | ||
| 440 | --question: what do we do about multiple versions? This should | ||
| 441 | --give us the latest version on the last repo (which is usually the global one) | ||
| 442 | for vs, repositories in util.sortedpairs(versions, deps.compare_versions) do | ||
| 443 | if not version then version = vs end | ||
| 444 | for _, rp in ipairs(repositories) do repo_url = rp.repo end | ||
| 445 | end | ||
| 446 | |||
| 447 | local repo = tree_map[repo_url] | ||
| 448 | return name, version, repo, repo_url | ||
| 449 | end | ||
| 450 | |||
| 418 | --- Driver function for "search" command. | 451 | --- Driver function for "search" command. |
| 419 | -- @param name string: A substring of a rock name to search. | 452 | -- @param name string: A substring of a rock name to search. |
| 420 | -- @param version string or nil: a version may also be passed. | 453 | -- @param version string or nil: a version may also be passed. |
diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua index f0bf2164..66ac6448 100644 --- a/src/luarocks/show.lua +++ b/src/luarocks/show.lua | |||
| @@ -56,45 +56,12 @@ local function format_text(text) | |||
| 56 | return (table.concat(paragraphs, "\n\n"):gsub("%s$", "")) | 56 | return (table.concat(paragraphs, "\n\n"):gsub("%s$", "")) |
| 57 | end | 57 | end |
| 58 | 58 | ||
| 59 | function show.pick_installed_rock(name, version, tree) | ||
| 60 | local results = {} | ||
| 61 | local query = search.make_query(name, version) | ||
| 62 | query.exact_name = true | ||
| 63 | local tree_map = {} | ||
| 64 | local trees = cfg.rocks_trees | ||
| 65 | if tree then | ||
| 66 | trees = { tree } | ||
| 67 | end | ||
| 68 | for _, tree in ipairs(trees) do | ||
| 69 | local rocks_dir = path.rocks_dir(tree) | ||
| 70 | tree_map[rocks_dir] = tree | ||
| 71 | search.manifest_search(results, rocks_dir, query) | ||
| 72 | end | ||
| 73 | |||
| 74 | if not next(results) then -- | ||
| 75 | return nil,"cannot find package "..name.." "..(version or "").."\nUse 'list' to find installed rocks." | ||
| 76 | end | ||
| 77 | |||
| 78 | version = nil | ||
| 79 | local repo_url | ||
| 80 | local package, versions = util.sortedpairs(results)() | ||
| 81 | --question: what do we do about multiple versions? This should | ||
| 82 | --give us the latest version on the last repo (which is usually the global one) | ||
| 83 | for vs, repositories in util.sortedpairs(versions, deps.compare_versions) do | ||
| 84 | if not version then version = vs end | ||
| 85 | for _, rp in ipairs(repositories) do repo_url = rp.repo end | ||
| 86 | end | ||
| 87 | |||
| 88 | local repo = tree_map[repo_url] | ||
| 89 | return name, version, repo, repo_url | ||
| 90 | end | ||
| 91 | |||
| 92 | local function installed_rock_label(name, tree) | 59 | local function installed_rock_label(name, tree) |
| 93 | local installed, version | 60 | local installed, version |
| 94 | if cfg.rocks_provided[name] then | 61 | if cfg.rocks_provided[name] then |
| 95 | installed, version = true, cfg.rocks_provided[name] | 62 | installed, version = true, cfg.rocks_provided[name] |
| 96 | else | 63 | else |
| 97 | installed, version = show.pick_installed_rock(name, nil, tree) | 64 | installed, version = search.pick_installed_rock(name, nil, tree) |
| 98 | end | 65 | end |
| 99 | return installed and "(using "..version..")" or "(missing)" | 66 | return installed and "(using "..version..")" or "(missing)" |
| 100 | end | 67 | end |
| @@ -109,7 +76,7 @@ function show.command(flags, name, version) | |||
| 109 | end | 76 | end |
| 110 | 77 | ||
| 111 | local repo, repo_url | 78 | local repo, repo_url |
| 112 | name, version, repo, repo_url = show.pick_installed_rock(name, version, flags["tree"]) | 79 | name, version, repo, repo_url = search.pick_installed_rock(name, version, flags["tree"]) |
| 113 | if not name then | 80 | if not name then |
| 114 | return nil, version | 81 | return nil, version |
| 115 | end | 82 | end |
diff --git a/test/README.md b/test/README.md index c374438f..5deaa175 100644 --- a/test/README.md +++ b/test/README.md | |||
| @@ -12,7 +12,7 @@ Test suite for LuaRocks project with Busted unit testing framework(http://olivin | |||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | ##Usage | 14 | ##Usage |
| 15 | Running of tests is based on basic Busted usage. *-Xhelper* flag is mandatory for inserting arguments into testing (primary black-box). Flag *--tags=* or *-t* is mandatory for specifying which tests will run. Mandatory *-Xhelper* flag always needs version of Lua or LuaJIT (e.g. *lua=5.2.4* or *luajit=2.0.3*). Start tests inside LuaRocks folder or specify with *-C* flag. | 15 | Running of tests is based on basic Busted usage. *-Xhelper* flag is mandatory for inserting arguments into testing (primary black-box). Flag *--tags=* or *-t* is mandatory for specifying which tests will run. Start tests inside LuaRocks folder or specify with *-C* flag. |
| 16 | 16 | ||
| 17 | **Arguments for Busted helper script** | 17 | **Arguments for Busted helper script** |
| 18 | 18 | ||
| @@ -22,7 +22,9 @@ OR | |||
| 22 | luajit=<version>, !mandatory! type your full version of LuaJIT (e.g. luajit=5.2.4) | 22 | luajit=<version>, !mandatory! type your full version of LuaJIT (e.g. luajit=5.2.4) |
| 23 | 23 | ||
| 24 | env=<type>, (default:"minimal") type what kind of environment to use ["minimal", "full"] | 24 | env=<type>, (default:"minimal") type what kind of environment to use ["minimal", "full"] |
| 25 | noreset, Don't reset environment after each test | ||
| 25 | clean, remove existing testing environment | 26 | clean, remove existing testing environment |
| 27 | appveyor, add just if running on TravisCI | ||
| 26 | travis, add just if running on TravisCI | 28 | travis, add just if running on TravisCI |
| 27 | os=<version>, type your OS ["linux", "os x", "windows"] | 29 | os=<version>, type your OS ["linux", "os x", "windows"] |
| 28 | ``` | 30 | ``` |
| @@ -35,6 +37,10 @@ os=<version>, type your OS ["linux", "os x", "windows"] | |||
| 35 | 37 | ||
| 36 | **ssh** - run all tests which require ssh | 38 | **ssh** - run all tests which require ssh |
| 37 | 39 | ||
| 40 | **mock** - run all tests which require mock LuaRocks server (upload tests) | ||
| 41 | |||
| 42 | **unix** - run all tests which are UNIX based, won't work on Windows systems | ||
| 43 | |||
| 38 | **w**\_*name-of-command* - whitebox testing of command | 44 | **w**\_*name-of-command* - whitebox testing of command |
| 39 | 45 | ||
| 40 | **b**\_*name-of-command* - blackbox testing of command | 46 | **b**\_*name-of-command* - blackbox testing of command |
| @@ -42,6 +48,9 @@ os=<version>, type your OS ["linux", "os x", "windows"] | |||
| 42 | for example: `b_install` or `w_help` | 48 | for example: `b_install` or `w_help` |
| 43 | 49 | ||
| 44 | ###Examples | 50 | ###Examples |
| 51 | To run all tests: | ||
| 52 | `busted` | ||
| 53 | |||
| 45 | To run white-box tests in LuaRocks directory type : | 54 | To run white-box tests in LuaRocks directory type : |
| 46 | 55 | ||
| 47 | `busted -t "whitebox"` | 56 | `busted -t "whitebox"` |
diff --git a/test/test_environment.lua b/test/test_environment.lua index c26c1e87..799e13ec 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
| @@ -17,6 +17,7 @@ ARGUMENTS | |||
| 17 | noreset Don't reset environment after each test | 17 | noreset Don't reset environment after each test |
| 18 | clean Remove existing testing environment. | 18 | clean Remove existing testing environment. |
| 19 | travis Add if running on TravisCI. | 19 | travis Add if running on TravisCI. |
| 20 | appveyor Add if running on Appveyor. | ||
| 20 | os=<type> Set OS ("linux", "osx", or "windows"). | 21 | os=<type> Set OS ("linux", "osx", or "windows"). |
| 21 | ]] | 22 | ]] |
| 22 | 23 | ||
| @@ -36,18 +37,54 @@ local function exists(path) | |||
| 36 | return lfs.attributes(path, "mode") ~= nil | 37 | return lfs.attributes(path, "mode") ~= nil |
| 37 | end | 38 | end |
| 38 | 39 | ||
| 39 | function test_env.quiet(commad) | 40 | --- Quote argument for shell processing. Fixes paths on Windows. |
| 41 | -- Adds double quotes and escapes. Based on function in fs/win32.lua. | ||
| 42 | -- @param arg string: Unquoted argument. | ||
| 43 | -- @return string: Quoted argument. | ||
| 44 | local function Q(arg) | ||
| 45 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 46 | local drive_letter = "[%.a-zA-Z]?:?[\\/]" | ||
| 47 | -- Quote DIR for Windows | ||
| 48 | if arg:match("^"..drive_letter) then | ||
| 49 | arg = arg:gsub("/", "\\") | ||
| 50 | end | ||
| 51 | |||
| 52 | if arg == "\\" then | ||
| 53 | return '\\' -- CHDIR needs special handling for root dir | ||
| 54 | end | ||
| 55 | |||
| 56 | return '"' .. arg .. '"' | ||
| 57 | else | ||
| 58 | return "'" .. arg:gsub("'", "'\\''") .. "'" | ||
| 59 | end | ||
| 60 | end | ||
| 61 | |||
| 62 | function test_env.quiet(command) | ||
| 40 | if not test_env.VERBOSE then | 63 | if not test_env.VERBOSE then |
| 41 | if test_env.TEST_TARGET_OS == "linux" or test_env.TEST_TARGET_OS == "osx" then | 64 | if test_env.TEST_TARGET_OS == "windows" then |
| 42 | return commad .. " 1> /dev/null 2> /dev/null" | 65 | return command .. " 1> NUL 2> NUL" |
| 43 | elseif test_env.TEST_TARGET_OS == "windows" then | 66 | else |
| 44 | return commad .. " 2> NUL 1> NUL" | 67 | return command .. " 1> /dev/null 2> /dev/null" |
| 45 | end | 68 | end |
| 46 | else | 69 | else |
| 47 | return command | 70 | return command |
| 48 | end | 71 | end |
| 49 | end | 72 | end |
| 50 | 73 | ||
| 74 | function test_env.copy(source, destination) | ||
| 75 | local r_source, err = io.open(source, "r") | ||
| 76 | local r_destination, err = io.open(destination, "w") | ||
| 77 | |||
| 78 | while true do | ||
| 79 | local block = r_source:read(8192) | ||
| 80 | if not block then break end | ||
| 81 | r_destination:write(block) | ||
| 82 | end | ||
| 83 | |||
| 84 | r_source:close() | ||
| 85 | r_destination:close() | ||
| 86 | end | ||
| 87 | |||
| 51 | --- Helper function for execute_bool and execute_output | 88 | --- Helper function for execute_bool and execute_output |
| 52 | -- @param command string: command to execute | 89 | -- @param command string: command to execute |
| 53 | -- @param print_command boolean: print command if 'true' | 90 | -- @param print_command boolean: print command if 'true' |
| @@ -61,27 +98,50 @@ function test_env.execute_helper(command, print_command, env_variables) | |||
| 61 | end | 98 | end |
| 62 | 99 | ||
| 63 | if env_variables then | 100 | if env_variables then |
| 64 | final_command = "export " | 101 | if test_env.TEST_TARGET_OS == "windows" then |
| 65 | for k,v in pairs(env_variables) do | 102 | for k,v in pairs(env_variables) do |
| 66 | final_command = final_command .. k .. "='" .. v .. "' " | 103 | final_command = final_command .. "set " .. k .. "=" .. v .. "&" |
| 104 | end | ||
| 105 | final_command = final_command:sub(1, -2) .. "&" | ||
| 106 | else | ||
| 107 | final_command = "export " | ||
| 108 | for k,v in pairs(env_variables) do | ||
| 109 | final_command = final_command .. k .. "='" .. v .. "' " | ||
| 110 | end | ||
| 111 | -- remove last space and add ';' to separate exporting variables from command | ||
| 112 | final_command = final_command:sub(1, -2) .. "; " | ||
| 67 | end | 113 | end |
| 68 | -- remove last space and add ';' to separate exporting variables from command | ||
| 69 | final_command = final_command:sub(1, -2) .. "; " | ||
| 70 | end | 114 | end |
| 71 | 115 | ||
| 72 | final_command = final_command .. command | 116 | final_command = final_command .. command .. " 2>&1" |
| 73 | 117 | ||
| 74 | return final_command | 118 | return final_command |
| 75 | end | 119 | end |
| 76 | 120 | ||
| 77 | --- Execute command and returns true/false | 121 | --- Execute command and returns true/false |
| 78 | -- In Lua5.1 os.execute returns numeric value, but in Lua5.2+ returns boolean | ||
| 79 | -- @return true/false boolean: status of the command execution | 122 | -- @return true/false boolean: status of the command execution |
| 80 | local function execute_bool(command, print_command, env_variables) | 123 | local function execute_bool(command, print_command, env_variables) |
| 81 | command = test_env.execute_helper(command, print_command, env_variables) | 124 | command = test_env.execute_helper(command, print_command, env_variables) |
| 82 | 125 | ||
| 83 | local ok = os.execute(command) | 126 | local redirect_filename |
| 84 | return ok == true or ok == 0 | 127 | local redirect = "" |
| 128 | if print_command ~= nil then | ||
| 129 | redirect_filename = test_env.testing_paths.luarocks_tmp.."/output.txt" | ||
| 130 | redirect = " > "..redirect_filename | ||
| 131 | end | ||
| 132 | local ok = os.execute(command .. redirect) | ||
| 133 | ok = (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean | ||
| 134 | if redirect ~= "" then | ||
| 135 | if not ok then | ||
| 136 | local fd = io.open(redirect_filename, "r") | ||
| 137 | if fd then | ||
| 138 | print(fd:read("*a")) | ||
| 139 | fd:close() | ||
| 140 | end | ||
| 141 | end | ||
| 142 | os.remove(redirect_filename) | ||
| 143 | end | ||
| 144 | return ok | ||
| 85 | end | 145 | end |
| 86 | 146 | ||
| 87 | --- Execute command and returns output of command | 147 | --- Execute command and returns output of command |
| @@ -109,6 +169,7 @@ end | |||
| 109 | function test_env.set_args() | 169 | function test_env.set_args() |
| 110 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables | 170 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables |
| 111 | test_env.TYPE_TEST_ENV = "minimal" | 171 | test_env.TYPE_TEST_ENV = "minimal" |
| 172 | test_env.OPENSSL_DIRS = "" | ||
| 112 | test_env.RESET_ENV = true | 173 | test_env.RESET_ENV = true |
| 113 | 174 | ||
| 114 | for _, argument in ipairs(arg) do | 175 | for _, argument in ipairs(arg) do |
| @@ -122,8 +183,15 @@ function test_env.set_args() | |||
| 122 | test_env.VERBOSE = true | 183 | test_env.VERBOSE = true |
| 123 | elseif argument == "travis" then | 184 | elseif argument == "travis" then |
| 124 | test_env.TRAVIS = true | 185 | test_env.TRAVIS = true |
| 186 | elseif argument == "appveyor" then | ||
| 187 | test_env.APPVEYOR = true | ||
| 188 | test_env.OPENSSL_DIRS = "OPENSSL_LIBDIR=C:\\OpenSSL-Win32\\lib OPENSSL_INCDIR=C:\\OpenSSL-Win32\\include" | ||
| 125 | elseif argument:find("^os=") then | 189 | elseif argument:find("^os=") then |
| 126 | test_env.TEST_TARGET_OS = argument:match("^os=(.*)$") | 190 | test_env.TEST_TARGET_OS = argument:match("^os=(.*)$") |
| 191 | elseif argument == "mingw" then | ||
| 192 | test_env.MINGW = true | ||
| 193 | elseif argument == "vs" then | ||
| 194 | test_env.MINGW = false | ||
| 127 | else | 195 | else |
| 128 | help() | 196 | help() |
| 129 | end | 197 | end |
| @@ -134,7 +202,7 @@ function test_env.set_args() | |||
| 134 | 202 | ||
| 135 | if execute_bool("sw_vers") then | 203 | if execute_bool("sw_vers") then |
| 136 | test_env.TEST_TARGET_OS = "osx" | 204 | test_env.TEST_TARGET_OS = "osx" |
| 137 | elseif execute_bool("uname -s") then | 205 | elseif execute_output("uname -s") == "Linux" then |
| 138 | test_env.TEST_TARGET_OS = "linux" | 206 | test_env.TEST_TARGET_OS = "linux" |
| 139 | else | 207 | else |
| 140 | test_env.TEST_TARGET_OS = "windows" | 208 | test_env.TEST_TARGET_OS = "windows" |
| @@ -143,6 +211,15 @@ function test_env.set_args() | |||
| 143 | return true | 211 | return true |
| 144 | end | 212 | end |
| 145 | 213 | ||
| 214 | local function copy_dir(source_path, target_path) | ||
| 215 | local testing_paths = test_env.testing_paths | ||
| 216 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 217 | execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path) | ||
| 218 | else | ||
| 219 | execute_bool("cp -a ".. source_path .. "/. " .. target_path) | ||
| 220 | end | ||
| 221 | end | ||
| 222 | |||
| 146 | --- Remove directory recursively | 223 | --- Remove directory recursively |
| 147 | -- @param path string: directory path to delete | 224 | -- @param path string: directory path to delete |
| 148 | function test_env.remove_dir(path) | 225 | function test_env.remove_dir(path) |
| @@ -159,7 +236,7 @@ function test_env.remove_dir(path) | |||
| 159 | end | 236 | end |
| 160 | end | 237 | end |
| 161 | end | 238 | end |
| 162 | os.remove(path) | 239 | lfs.rmdir(path) |
| 163 | end | 240 | end |
| 164 | 241 | ||
| 165 | --- Remove subdirectories of a directory that match a pattern | 242 | --- Remove subdirectories of a directory that match a pattern |
| @@ -205,13 +282,17 @@ end | |||
| 205 | -- @param save_path string: path to directory, where to download rocks/rockspecs | 282 | -- @param save_path string: path to directory, where to download rocks/rockspecs |
| 206 | -- @return make_manifest boolean: true if new rocks downloaded | 283 | -- @return make_manifest boolean: true if new rocks downloaded |
| 207 | local function download_rocks(urls, save_path) | 284 | local function download_rocks(urls, save_path) |
| 208 | local luarocks_repo = "https://luarocks.org" | 285 | local luarocks_repo = "https://www.luarocks.org" |
| 209 | local make_manifest = false | 286 | local make_manifest = false |
| 210 | 287 | ||
| 211 | for _, url in ipairs(urls) do | 288 | for _, url in ipairs(urls) do |
| 212 | -- check if already downloaded | 289 | -- check if already downloaded |
| 213 | if not exists(save_path .. url) then | 290 | if not exists(save_path .. url) then |
| 214 | execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. url) | 291 | if test_env.TEST_TARGET_OS == "windows" then |
| 292 | execute_bool(test_env.testing_paths.win_tools .. "/wget -cP " .. save_path .. " " .. luarocks_repo .. url .. " --no-check-certificate") | ||
| 293 | else | ||
| 294 | execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. url) | ||
| 295 | end | ||
| 215 | make_manifest = true | 296 | make_manifest = true |
| 216 | end | 297 | end |
| 217 | end | 298 | end |
| @@ -235,9 +316,9 @@ local function hash_environment(path) | |||
| 235 | return execute_output("find " .. path .. " -printf \"%s %p\n\" | md5sum") | 316 | return execute_output("find " .. path .. " -printf \"%s %p\n\" | md5sum") |
| 236 | elseif test_env.TEST_TARGET_OS == "osx" then | 317 | elseif test_env.TEST_TARGET_OS == "osx" then |
| 237 | return execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5") | 318 | return execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5") |
| 238 | else | 319 | elseif test_env.TEST_TARGET_OS == "windows" then |
| 239 | -- TODO: Windows | 320 | return execute_output("\"" .. Q(test_env.testing_paths.win_tools .. "/find") .. " " .. Q(path) |
| 240 | return "" | 321 | .. " -printf \"%s %p\"\" > temp_sum.txt && certUtil -hashfile temp_sum.txt && del temp_sum.txt") |
| 241 | end | 322 | end |
| 242 | end | 323 | end |
| 243 | 324 | ||
| @@ -261,7 +342,7 @@ local function create_env(testing_paths) | |||
| 261 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" | 342 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" |
| 262 | env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" | 343 | env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" |
| 263 | .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" | 344 | .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" |
| 264 | env_variables.PATH = os.getenv("PATH") .. ":" .. testing_paths.testing_tree .. "/bin:" .. testing_paths.testing_sys_tree .. "/bin" | 345 | env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;" |
| 265 | 346 | ||
| 266 | return env_variables | 347 | return env_variables |
| 267 | end | 348 | end |
| @@ -278,13 +359,17 @@ local function create_md5sums(testing_paths) | |||
| 278 | end | 359 | end |
| 279 | 360 | ||
| 280 | local function make_run_function(cmd_name, exec_function, with_coverage, do_print) | 361 | local function make_run_function(cmd_name, exec_function, with_coverage, do_print) |
| 281 | local cmd_prefix = test_env.testing_paths.lua .. " " | 362 | local cmd_prefix = Q(test_env.testing_paths.lua) .. " " |
| 282 | 363 | ||
| 283 | if with_coverage then | 364 | if with_coverage then |
| 284 | cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testing_dir .. "/luacov.config')\" " | 365 | cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testing_dir .. "/luacov.config')\" " |
| 285 | end | 366 | end |
| 286 | 367 | ||
| 287 | cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " | 368 | if test_env.TEST_TARGET_OS == "windows" then |
| 369 | cmd_prefix = cmd_prefix .. Q(test_env.testing_paths.testing_lrprefix .. "/" .. cmd_name .. ".lua") .. " " | ||
| 370 | else | ||
| 371 | cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " | ||
| 372 | end | ||
| 288 | 373 | ||
| 289 | return function(cmd, new_vars) | 374 | return function(cmd, new_vars) |
| 290 | local temp_vars = {} | 375 | local temp_vars = {} |
| @@ -327,19 +412,23 @@ local function build_environment(rocks, env_variables) | |||
| 327 | lfs.mkdir(testing_paths.testing_tree) | 412 | lfs.mkdir(testing_paths.testing_tree) |
| 328 | lfs.mkdir(testing_paths.testing_sys_tree) | 413 | lfs.mkdir(testing_paths.testing_sys_tree) |
| 329 | 414 | ||
| 330 | test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_server) | 415 | test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_server)) |
| 331 | test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_cache) | 416 | test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_cache)) |
| 332 | 417 | ||
| 333 | for _, rock in ipairs(rocks) do | 418 | for _, rock in ipairs(rocks) do |
| 334 | if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) then | 419 | if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. Q(rock), env_variables) then |
| 335 | test_env.run.luarocks_nocov("build --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) | 420 | test_env.run.luarocks_nocov("build --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock) .. "", env_variables) |
| 336 | test_env.run.luarocks_nocov("pack --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) | 421 | test_env.run.luarocks_nocov("pack --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables) |
| 337 | execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) | 422 | if test_env.TEST_TARGET_OS == "windows" then |
| 423 | execute_bool(testing_paths.win_tools .. "/mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) | ||
| 424 | else | ||
| 425 | execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) | ||
| 426 | end | ||
| 338 | end | 427 | end |
| 339 | end | 428 | end |
| 340 | 429 | ||
| 341 | execute_bool("cp -a " .. testing_paths.testing_tree .. "/. " .. testing_paths.testing_tree_copy) | 430 | copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) |
| 342 | execute_bool("cp -a " .. testing_paths.testing_sys_tree .. "/. " .. testing_paths.testing_sys_tree_copy) | 431 | copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) |
| 343 | end | 432 | end |
| 344 | 433 | ||
| 345 | --- Reset testing environment | 434 | --- Reset testing environment |
| @@ -349,14 +438,13 @@ local function reset_environment(testing_paths, md5sums) | |||
| 349 | 438 | ||
| 350 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then | 439 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then |
| 351 | test_env.remove_dir(testing_paths.testing_tree) | 440 | test_env.remove_dir(testing_paths.testing_tree) |
| 352 | execute_bool("cp -a " .. testing_paths.testing_tree_copy .. "/. " .. testing_paths.testing_tree) | 441 | copy_dir(testing_paths.testing_tree_copy, testing_paths.testing_tree) |
| 353 | end | 442 | end |
| 354 | 443 | ||
| 355 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then | 444 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then |
| 356 | test_env.remove_dir(testing_paths.testing_sys_tree) | 445 | test_env.remove_dir(testing_paths.testing_sys_tree) |
| 357 | execute_bool("cp -a " .. testing_paths.testing_sys_tree_copy .. "/. " .. testing_paths.testing_sys_tree) | 446 | copy_dir(testing_paths.testing_sys_tree_copy, testing_paths.testing_sys_tree) |
| 358 | end | 447 | end |
| 359 | |||
| 360 | print("\n[ENVIRONMENT RESET]") | 448 | print("\n[ENVIRONMENT RESET]") |
| 361 | end | 449 | end |
| 362 | 450 | ||
| @@ -367,9 +455,18 @@ local function create_paths(luaversion_full) | |||
| 367 | testing_paths.luadir = cfg.variables.LUA_BINDIR:gsub("/bin/?$", "") | 455 | testing_paths.luadir = cfg.variables.LUA_BINDIR:gsub("/bin/?$", "") |
| 368 | testing_paths.lua = cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter | 456 | testing_paths.lua = cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter |
| 369 | 457 | ||
| 370 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" --windows? | 458 | if test_env.TEST_TARGET_OS == "windows" then |
| 459 | testing_paths.luarocks_tmp = os.getenv("TEMP") | ||
| 460 | else | ||
| 461 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" | ||
| 462 | end | ||
| 371 | 463 | ||
| 372 | testing_paths.luarocks_dir = lfs.currentdir() | 464 | testing_paths.luarocks_dir = lfs.currentdir() |
| 465 | |||
| 466 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 467 | testing_paths.luarocks_dir = testing_paths.luarocks_dir:gsub("\\","/") | ||
| 468 | end | ||
| 469 | |||
| 373 | testing_paths.testing_dir = testing_paths.luarocks_dir .. "/test" | 470 | testing_paths.testing_dir = testing_paths.luarocks_dir .. "/test" |
| 374 | testing_paths.src_dir = testing_paths.luarocks_dir .. "/src" | 471 | testing_paths.src_dir = testing_paths.luarocks_dir .. "/src" |
| 375 | testing_paths.testing_lrprefix = testing_paths.testing_dir .. "/testing_lrprefix-" .. luaversion_full | 472 | testing_paths.testing_lrprefix = testing_paths.testing_dir .. "/testing_lrprefix-" .. luaversion_full |
| @@ -380,6 +477,10 @@ local function create_paths(luaversion_full) | |||
| 380 | testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full | 477 | testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full |
| 381 | testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full | 478 | testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full |
| 382 | 479 | ||
| 480 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 481 | testing_paths.win_tools = testing_paths.testing_lrprefix .. "/tools" | ||
| 482 | end | ||
| 483 | |||
| 383 | return testing_paths | 484 | return testing_paths |
| 384 | end | 485 | end |
| 385 | 486 | ||
| @@ -546,13 +647,19 @@ end | |||
| 546 | 647 | ||
| 547 | --- Install luarocks into testing prefix. | 648 | --- Install luarocks into testing prefix. |
| 548 | local function install_luarocks(install_env_vars) | 649 | local function install_luarocks(install_env_vars) |
| 549 | -- Configure LuaRocks testing environment | 650 | local testing_paths = test_env.testing_paths |
| 550 | title("Installing LuaRocks") | 651 | title("Installing LuaRocks") |
| 551 | local configure_cmd = "./configure --with-lua=" .. test_env.testing_paths.luadir .. " --prefix=" .. test_env.testing_paths.testing_lrprefix | 652 | if test_env.TEST_TARGET_OS == "windows" then |
| 552 | assert(execute_bool(test_env.quiet(configure_cmd), false, install_env_vars)) | 653 | local compiler_flag = test_env.MINGW and "/MW" or "" |
| 553 | assert(execute_bool(test_env.quiet("make clean"), false, install_env_vars)) | 654 | assert(execute_bool("install.bat /LUA " .. testing_paths.luadir .. " " .. compiler_flag .. " /P " .. testing_paths.testing_lrprefix .. " /NOREG /NOADMIN /F /Q /CONFIG " .. testing_paths.testing_lrprefix .. "/etc/luarocks", false, install_env_vars)) |
| 554 | assert(execute_bool(test_env.quiet("make src/luarocks/site_config.lua"), false, install_env_vars)) | 655 | assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/site_config* " .. testing_paths.src_dir .. "/luarocks/site_config.lua")) |
| 555 | assert(execute_bool(test_env.quiet("make dev"), false, install_env_vars)) | 656 | else |
| 657 | local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix | ||
| 658 | assert(execute_bool(configure_cmd, false, install_env_vars)) | ||
| 659 | assert(execute_bool("make clean", false, install_env_vars)) | ||
| 660 | assert(execute_bool("make src/luarocks/site_config.lua", false, install_env_vars)) | ||
| 661 | assert(execute_bool("make dev", false, install_env_vars)) | ||
| 662 | end | ||
| 556 | print("LuaRocks installed correctly!") | 663 | print("LuaRocks installed correctly!") |
| 557 | end | 664 | end |
| 558 | 665 | ||
| @@ -571,9 +678,7 @@ function test_env.main() | |||
| 571 | create_configs() | 678 | create_configs() |
| 572 | 679 | ||
| 573 | local install_env_vars = { | 680 | local install_env_vars = { |
| 574 | LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua", | 681 | LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua" |
| 575 | LUA_PATH = "", | ||
| 576 | LUA_CPATH = "" | ||
| 577 | } | 682 | } |
| 578 | 683 | ||
| 579 | install_luarocks(install_env_vars) | 684 | install_luarocks(install_env_vars) |
diff --git a/test/testing.bat b/test/testing.bat deleted file mode 100644 index 7083678b..00000000 --- a/test/testing.bat +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | @echo off | ||
| 2 | Setlocal EnableDelayedExpansion EnableExtensions | ||
| 3 | |||
| 4 | if not defined LUAROCKS_REPO set LUAROCKS_REPO=https://luarocks.org | ||
| 5 | |||
| 6 | appveyor DownloadFile %LUAROCKS_REPO%/stdlib-41.0.0-1.src.rock | ||
| 7 | luarocks build stdlib | ||
| 8 | |||
| 9 | endlocal | ||
