From 84b4fe99cac37850a97858e0b641043bd3178d8a Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 4 Oct 2017 11:14:42 -0300 Subject: Use versioned files only. (#734) Let's take the opportunity of a new major version to make an important cleanup: getting rid of the error-prone unversioned configuration files. This drops support for: * Unversioned config.lua -> use config-5.x.lua * Unversioned luarocks/site_config.lua -> it always generates luarocks/core/site_config_5_x.lua * Unversioned lib/luarocks/rocks -> it always uses lib/luarocks/rocks-5.x --- .travis.yml | 5 ++-- Makefile | 52 ++++++++++++++++++-------------------- appveyor.yml | 6 ++--- configure | 29 ++++----------------- install.bat | 13 +++++----- spec/build_spec.lua | 40 ++++++++++++++--------------- spec/config_spec.lua | 12 ++------- spec/deps_spec.lua | 64 +++++++++++++++++++++++------------------------ spec/doc_spec.lua | 6 ++--- spec/install_spec.lua | 12 ++++----- spec/list_spec.lua | 3 +-- spec/make_spec.lua | 10 ++++---- spec/remove_spec.lua | 20 +++++++-------- spec/util_spec.lua | 63 ++++++---------------------------------------- src/luarocks/core/cfg.lua | 11 +++----- test/test_environment.lua | 42 +++++++++++++++++++++---------- 16 files changed, 161 insertions(+), 227 deletions(-) diff --git a/.travis.yml b/.travis.yml index e842371a..466177f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,8 +63,9 @@ install: - if [ ! -f lua_install/bin/luacov ]; then luarocks install luacov; luarocks install luacov-coveralls; fi script: - - busted -o gtest --verbose -Xhelper travis - - busted -o gtest --verbose -Xhelper travis,env=full + - lua -v + - busted -o gtest --verbose -Xhelper "lua_dir=$PWD/lua_install,travis" + - busted -o gtest --verbose -Xhelper "lua_dir=$PWD/lua_install,travis,env=full" after_success: - luacov -c $TRAVIS_BUILD_DIR/test/luacov.config diff --git a/Makefile b/Makefile index ae308a67..0f1274ae 100644 --- a/Makefile +++ b/Makefile @@ -24,64 +24,60 @@ all: include Makefile.setup.inc include Makefile.install.inc -build: src/luarocks/site_config.lua build_bins +build: $(SITE_CONFIG) build_bins @echo @echo "Done. Type 'make install' to install into $(PREFIX)." @echo -src/luarocks/site_config.lua: config.unix - rm -f src/luarocks/site_config.lua - echo 'local site_config = {}' >> src/luarocks/site_config.lua +$(SITE_CONFIG): config.unix + rm -f $(SITE_CONFIG) + echo 'local site_config = {}' >> $(SITE_CONFIG) if [ -n "$(PREFIX)" ] ;\ then \ - echo "site_config.LUAROCKS_PREFIX=[[$(PREFIX)]]" >> src/luarocks/site_config.lua ;\ + echo "site_config.LUAROCKS_PREFIX=[[$(PREFIX)]]" >> $(SITE_CONFIG) ;\ fi if [ -n "$(LUA_INCDIR)" ] ;\ then \ - echo "site_config.LUA_INCDIR=[[$(LUA_INCDIR)]]" >> src/luarocks/site_config.lua ;\ + echo "site_config.LUA_INCDIR=[[$(LUA_INCDIR)]]" >> $(SITE_CONFIG) ;\ fi if [ -n "$(LUA_LIBDIR)" ] ;\ then \ - echo "site_config.LUA_LIBDIR=[[$(LUA_LIBDIR)]]" >> src/luarocks/site_config.lua ;\ + echo "site_config.LUA_LIBDIR=[[$(LUA_LIBDIR)]]" >> $(SITE_CONFIG) ;\ fi if [ -n "$(LUA_BINDIR)" ] ;\ then \ - echo "site_config.LUA_BINDIR=[[$(LUA_BINDIR)]]" >> src/luarocks/site_config.lua ;\ + echo "site_config.LUA_BINDIR=[[$(LUA_BINDIR)]]" >> $(SITE_CONFIG) ;\ fi if [ -n "$(LUA_SUFFIX)" ] ;\ then \ - echo "site_config.LUA_INTERPRETER=[[lua$(LUA_SUFFIX)]]" >> src/luarocks/site_config.lua ;\ + echo "site_config.LUA_INTERPRETER=[[lua$(LUA_SUFFIX)]]" >> $(SITE_CONFIG) ;\ fi if [ -n "$(SYSCONFDIR)" ] ;\ then \ - echo "site_config.LUAROCKS_SYSCONFDIR=[[$(SYSCONFDIR)]]" >> src/luarocks/site_config.lua ;\ + echo "site_config.LUAROCKS_SYSCONFDIR=[[$(SYSCONFDIR)]]" >> $(SITE_CONFIG) ;\ fi if [ -n "$(ROCKS_TREE)" ] ;\ then \ - echo "site_config.LUAROCKS_ROCKS_TREE=[[$(ROCKS_TREE)]]" >> src/luarocks/site_config.lua ;\ + echo "site_config.LUAROCKS_ROCKS_TREE=[[$(ROCKS_TREE)]]" >> $(SITE_CONFIG) ;\ fi if [ -n "$(FORCE_CONFIG)" ] ;\ then \ - echo "site_config.LUAROCKS_FORCE_CONFIG=true" >> src/luarocks/site_config.lua ;\ - fi - if [ -n "$(LUAROCKS_ROCKS_SUBDIR)" ] ;\ - then \ - echo "site_config.LUAROCKS_ROCKS_SUBDIR=[[$(LUAROCKS_ROCKS_SUBDIR)]]" >> src/luarocks/site_config.lua ;\ + echo "site_config.LUAROCKS_FORCE_CONFIG=true" >> $(SITE_CONFIG) ;\ fi if [ "$(LUA_DIR_SET)" = "yes" ] ;\ then \ - echo "site_config.LUA_DIR_SET=true" >> src/luarocks/site_config.lua ;\ + echo "site_config.LUA_DIR_SET=true" >> $(SITE_CONFIG) ;\ fi - echo "site_config.LUAROCKS_UNAME_S=[[$(LUAROCKS_UNAME_S)]]" >> src/luarocks/site_config.lua - echo "site_config.LUAROCKS_UNAME_M=[[$(LUAROCKS_UNAME_M)]]" >> src/luarocks/site_config.lua - echo "site_config.LUAROCKS_DOWNLOADER=[[$(LUAROCKS_DOWNLOADER)]]" >> src/luarocks/site_config.lua - echo "site_config.LUAROCKS_MD5CHECKER=[[$(LUAROCKS_MD5CHECKER)]]" >> src/luarocks/site_config.lua + echo "site_config.LUAROCKS_UNAME_S=[[$(LUAROCKS_UNAME_S)]]" >> $(SITE_CONFIG) + echo "site_config.LUAROCKS_UNAME_M=[[$(LUAROCKS_UNAME_M)]]" >> $(SITE_CONFIG) + echo "site_config.LUAROCKS_DOWNLOADER=[[$(LUAROCKS_DOWNLOADER)]]" >> $(SITE_CONFIG) + echo "site_config.LUAROCKS_MD5CHECKER=[[$(LUAROCKS_MD5CHECKER)]]" >> $(SITE_CONFIG) if [ -n "$(MULTIARCH_SUBDIR)" ] ;\ then \ - echo 'site_config.LUAROCKS_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[$(MULTIARCH_SUBDIR)]] }, include="include" }' >> src/luarocks/site_config.lua ;\ - echo 'site_config.LUAROCKS_RUNTIME_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[$(MULTIARCH_SUBDIR)]] }, include="include" }' >> src/luarocks/site_config.lua ;\ + echo 'site_config.LUAROCKS_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[$(MULTIARCH_SUBDIR)]] }, include="include" }' >> $(SITE_CONFIG) ;\ + echo 'site_config.LUAROCKS_RUNTIME_EXTERNAL_DEPS_SUBDIRS={ bin="bin", lib={ "lib", [[$(MULTIARCH_SUBDIR)]] }, include="include" }' >> $(SITE_CONFIG) ;\ fi - echo "return site_config" >> src/luarocks/site_config.lua + echo "return site_config" >> $(SITE_CONFIG) dev: $(MAKE) build_bins LUADIR=$(PWD)/src @@ -123,14 +119,14 @@ cleanup_bins: done clean: cleanup_bins - rm -f src/luarocks/site_config.lua + rm -f $(SITE_CONFIG) run_luarocks: '$(LUA_BINDIR)/lua$(LUA_SUFFIX)' -e "package.path=[[$(SAFEPWD)/src/?.lua;]]..package.path" src/bin/luarocks make rockspec --tree="$(PREFIX)" -install_site_config: src/luarocks/site_config.lua +install_site_config: $(SITE_CONFIG) mkdir -p "$(DESTDIR)$(LUADIR)/luarocks" - cp src/luarocks/site_config.lua "$(DESTDIR)$(LUADIR)/luarocks" + cp $(SITE_CONFIG) "$(DESTDIR)$(LUADIR)/luarocks" write_sysconfig: mkdir -p "$(DESTDIR)$(ROCKS_TREE)" @@ -148,7 +144,7 @@ write_sysconfig: install: install_bins install_luas install_site_config write_sysconfig -bootstrap: src/luarocks/site_config.lua run_luarocks install_site_config write_sysconfig cleanup_bins +bootstrap: $(SITE_CONFIG) run_luarocks install_site_config write_sysconfig cleanup_bins install_rock: install_bins install_luas diff --git a/appveyor.yml b/appveyor.yml index a7cf1be6..3255e2db 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -38,14 +38,14 @@ init: before_build: - set PATH=C:\Python27\Scripts;%PATH% # Add directory containing 'pip' to PATH - pip install hererocks - - hererocks env --%LUA% --luarocks @luarocks-3 --target=%COMPILER% - - call env\bin\activate + - hererocks lua_install --%LUA% --luarocks @luarocks-3 --target=%COMPILER% + - call lua_install\bin\activate build_script: - luarocks install busted 1> NUL 2> NUL test_script: - - busted --lpath=.//?.lua --exclude-tags=ssh,unix,mock -Xhelper appveyor,%COMPILER% + - busted --lpath=.//?.lua --exclude-tags=ssh,unix,mock -Xhelper lua_dir=%CD%\lua_install,appveyor,%COMPILER% after_test: - if "%LUA%"=="lua 5.1" (luarocks show bit32 || luarocks install bit32) diff --git a/configure b/configure index 15a18bb8..42d18f61 100755 --- a/configure +++ b/configure @@ -58,9 +58,6 @@ system's package manager. --with-md5-checker=TOOL Which tool to use as a downloader. Valid options are: md5sum, openssl Default is to auto-detect. ---versioned-rocks-dir Use a versioned rocks dir, such as - \$PREFIX/lib/luarocks/rocks-$LUA_VERSION/. - Default is to auto-detect the necessity. --force-config Use a single config location. Do not use the \$LUAROCKS_CONFIG variable or the user's home directory. Useful to avoid conflicts when LuaRocks @@ -155,7 +152,8 @@ do FORCE_CONFIG=yes ;; --versioned-rocks-dir) - VERSIONED_ROCKS_DIR=yes + echo "--versioned-rocks-dir is no longer necessary." + echo "The rocks tree in LuaRocks 3.0 is always versioned." ;; --lua-suffix) [ -n "$value" ] || die "Missing value in flag $key." @@ -411,25 +409,6 @@ for v in 5.1 5.2 5.3; do fi done -LUAROCKS_ROCKS_SUBDIR=/lib/luarocks/rocks -if [ "$VERSIONED_ROCKS_DIR" = "yes" ] -then - LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR-$LUA_VERSION - echo "Using versioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR" -elif [ -e "$PREFIX/share/lua/$LUA_VERSION/luarocks/site_config.lua" ] -then - echo "Existing installation detected." - LUAROCKS_ROCKS_SUBDIR=`grep "LUAROCKS_ROCKS_SUBDIR" "$PREFIX/share/lua/$LUA_VERSION/luarocks/site_config.lua" | sed 's,.*=\[\[\(.*\)\]\],\1,'` - echo "Using previously configured rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR" -elif [ -n "$LUA_OTHER_VERSION" ] -then - echo "Existing installation detected for other Lua version ($LUA_OTHER_VERSION)." - LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR-$LUA_VERSION - echo "Using versioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR" -else - echo "Using unversioned rocks dir: $PREFIX$LUAROCKS_ROCKS_SUBDIR" -fi - if [ "$LUAROCKS_UNAME_S" = Linux ] then GCC_ARCH=`gcc -print-multiarch 2>/dev/null` @@ -447,6 +426,8 @@ if [ -f config.unix ]; then rm -f config.unix fi +SITE_CONFIG=src/luarocks/core/site_config_$(echo "$LUA_VERSION" | sed 's,\.,_,').lua + # Write config echo "Writing configuration..." @@ -458,6 +439,7 @@ cat < config.unix # Run "./configure --help" for details. LUA_VERSION=$LUA_VERSION +SITE_CONFIG=$SITE_CONFIG PREFIX=$PREFIX SYSCONFDIR=$SYSCONFDIR ROCKS_TREE=$ROCKS_TREE @@ -472,7 +454,6 @@ LUAROCKS_UNAME_M=$LUAROCKS_UNAME_M LUAROCKS_UNAME_S=$LUAROCKS_UNAME_S LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER -LUAROCKS_ROCKS_SUBDIR=$LUAROCKS_ROCKS_SUBDIR MULTIARCH_SUBDIR=$MULTIARCH_SUBDIR EOF diff --git a/install.bat b/install.bat index 118abfc7..0f334ab9 100644 --- a/install.bat +++ b/install.bat @@ -604,14 +604,14 @@ local function backup_config_files() vars.CONFBACKUPDIR = temppath mkdir(vars.CONFBACKUPDIR) exec(S[[COPY "$PREFIX\config*.*" "$CONFBACKUPDIR" >NUL]]) - exec(S[[COPY "$PREFIX\lua\luarocks\site_config*.*" "$CONFBACKUPDIR" >NUL]]) + exec(S[[COPY "$PREFIX\lua\luarocks\core\site_config*.*" "$CONFBACKUPDIR" >NUL]]) end -- restore previously backed up config files local function restore_config_files() if not vars.CONFBACKUPDIR then return end -- there is no backup to restore exec(S[[COPY "$CONFBACKUPDIR\config*.*" "$PREFIX" >NUL]]) - exec(S[[COPY "$CONFBACKUPDIR\site_config*.*" "$PREFIX\lua\luarocks" >NUL]]) + exec(S[[COPY "$CONFBACKUPDIR\site_config*.*" "$PREFIX\lua\luarocks\core" >NUL]]) -- cleanup exec(S[[RD /S /Q "$CONFBACKUPDIR"]]) vars.CONFBACKUPDIR = nil @@ -937,13 +937,14 @@ print("Configuring LuaRocks...") -- Create a site-config file local site_config = S("site_config_$LUA_VERSION"):gsub("%.","_") -if exists(S([[$LUADIR\luarocks\]]..site_config..[[.lua]])) then - local nname = backup(S([[$LUADIR\luarocks\]]..site_config..[[.lua]]), site_config..".lua.bak") + +if exists(S([[$LUADIR\luarocks\core\]]..site_config..[[.lua]])) then + local nname = backup(S([[$LUADIR\luarocks\core\]]..site_config..[[.lua]]), site_config..".lua.bak") print("***************") print("*** WARNING *** LuaRocks site_config file already exists: '"..site_config..".lua'. The old file has been renamed to '"..nname.."'") print("***************") end -local f = io.open(vars.LUADIR.."\\luarocks\\"..site_config..".lua", "w") +local f = io.open(vars.LUADIR.."\\luarocks\\core\\"..site_config..".lua", "w") f:write(S[=[ local site_config = {} site_config.LUA_INCDIR=[[$LUA_INCDIR]] @@ -971,7 +972,7 @@ if vars.SYSCONFFORCE then -- only write this value when explcitly given, otherw end f:write("return site_config\n") f:close() -print(S([[Created LuaRocks site-config file: $LUADIR\luarocks\]]..site_config..[[.lua]])) +print(S([[Created LuaRocks site-config file: $LUADIR\luarocks\core\]]..site_config..[[.lua]])) -- create config file if not exists(vars.SYSCONFDIR) then diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 2ff7cbe6..ffae144d 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua @@ -63,22 +63,22 @@ describe("LuaRocks build tests #blackbox #b_build", function() it("LuaRocks build lpeg branch=master", function() assert.is_true(run.luarocks_bool("build --branch=master lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) end) it("LuaRocks build lpeg deps-mode=123", function() assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg --verbose")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) end) it("LuaRocks build lpeg only-sources example", function() assert.is_true(run.luarocks_bool("download --rockspec lpeg")) assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) assert.is_true(run.luarocks_bool("download --source lpeg")) assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.src.rock")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) assert.is_true(os.remove("lpeg-1.0.0-1.rockspec")) assert.is_true(os.remove("lpeg-1.0.0-1.src.rock")) @@ -86,7 +86,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() it("LuaRocks build lpeg with empty tree", function() assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) end) end) @@ -97,17 +97,17 @@ describe("LuaRocks build tests #blackbox #b_build", function() it("LuaRocks build luacov diff version", function() assert.is_true(run.luarocks_bool("build luacov 0.11.0-1")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov/0.11.0-1/luacov-0.11.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luacov/0.11.0-1/luacov-0.11.0-1.rockspec")) end) it("LuaRocks build command stdlib", function() assert.is_true(run.luarocks_bool("build stdlib")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec")) end) it("LuaRocks build install bin luarepl", function() assert.is_true(run.luarocks_bool("build luarepl")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl/0.4-1/luarepl-0.4-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luarepl/0.4-1/luarepl-0.4-1.rockspec")) end) it("LuaRocks build supported platforms lpty", function() @@ -115,24 +115,24 @@ describe("LuaRocks build tests #blackbox #b_build", function() assert.is_false(run.luarocks_bool("build lpty")) --Error: This rockspec for lpty does not support win32, windows platforms else assert.is_true(run.luarocks_bool("build lpty")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty/1.0.1-1/lpty-1.0.1-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpty/1.0.1-1/lpty-1.0.1-1.rockspec")) end end) it("LuaRocks build luasec with skipping dependency checks", function() assert.is_true(run.luarocks_bool("build luasec " .. test_env.OPENSSL_DIRS .. " --nodeps")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec/0.6-1/luasec-0.6-1.rockspec")) end) it("LuaRocks build lmathx deps partial match", function() assert.is_true(run.luarocks_bool("build lmathx")) if test_env.LUA_V == "5.1" or test_env.LUAJIT_V then - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20120430.51-1/lmathx-20120430.51-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lmathx/20120430.51-1/lmathx-20120430.51-1.rockspec")) elseif test_env.LUA_V == "5.2" then - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20120430.52-1/lmathx-20120430.52-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lmathx/20120430.52-1/lmathx-20120430.52-1.rockspec")) elseif test_env.LUA_V == "5.3" then - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20150505-1/lmathx-20150505-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lmathx/20150505-1/lmathx-20150505-1.rockspec")) end end) end) @@ -148,15 +148,15 @@ describe("LuaRocks build tests #blackbox #b_build", function() it("LuaRocks build luasec only deps", function() assert.is_true(run.luarocks_bool("build luasec " .. test_env.OPENSSL_DIRS .. " --only-deps")) assert.is_false(run.luarocks_bool("show luasec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec/0.6-1/luasec-0.6-1.rockspec")) end) it("LuaRocks build only deps of downloaded rockspec of lxsh", function() assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2")) assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.rockspec --only-deps")) assert.is_false(run.luarocks_bool("show lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) end) @@ -164,8 +164,8 @@ describe("LuaRocks build tests #blackbox #b_build", function() assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.src.rock --only-deps")) assert.is_false(run.luarocks_bool("show lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) end) @@ -174,7 +174,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) assert.is.truthy(run.luarocks("show validate-args")) - 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")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/validate-args/1.5.4-1/validate-args-1.5.4-1.rockspec")) assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) end) @@ -185,7 +185,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) assert.is.truthy(run.luarocks("show validate-args")) - 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")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/validate-args/1.5.4-1/validate-args-1.5.4-1.rockspec")) assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) end) diff --git a/spec/config_spec.lua b/spec/config_spec.lua index cdb5ccc4..6be586c2 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -12,7 +12,7 @@ describe("LuaRocks config tests #blackbox #b_config", function() before_each(function() test_env.setup_specs() test_env.unload_luarocks() -- need to be required here, because site_config is created after first loading of specs - site_config = require("luarocks.site_config") + site_config = require("luarocks.core.site_config_" .. test_env.lua_version:gsub("%.", "_")) end) describe("LuaRocks config - basic tests", function() @@ -64,15 +64,7 @@ describe("LuaRocks config tests #blackbox #b_config", function() describe("LuaRocks config - more complex tests", function() local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" - local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" - local scname = scdir .. "/config.lua" - - local configfile - if test_env.TEST_TARGET_OS == "windows" then - configfile = versioned_scname - else - configfile = scname - end + local configfile = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" it("LuaRocks fail system config", function() os.rename(configfile, configfile .. ".bak") diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua index e453c9a1..8c4effcd 100644 --- a/spec/deps_spec.lua +++ b/spec/deps_spec.lua @@ -23,59 +23,59 @@ describe("LuaRocks deps tests #blackbox #b_deps", function() assert.is_true(run.luarocks_bool("build --tree=system lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode order", function() assert.is_true(run.luarocks_bool("build --tree=system lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_tree .. " lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode order sys", function() assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode all sys", function() assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=all --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode none", function() assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=none lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks nodeps alias", function() assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " --nodeps lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode make order", function() @@ -89,10 +89,10 @@ describe("LuaRocks deps tests #blackbox #b_deps", function() test_env.remove_dir("lxsh-0.8.6-2") assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode make order sys", function() @@ -106,9 +106,9 @@ describe("LuaRocks deps tests #blackbox #b_deps", function() test_env.remove_dir("lxsh-0.8.6-2") assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) end) diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua index a04d3c14..ea42cd6b 100644 --- a/spec/doc_spec.lua +++ b/spec/doc_spec.lua @@ -28,12 +28,12 @@ describe("LuaRocks doc tests #blackbox #b_doc", function() end) it("LuaRocks doc with no home page and no doc folder", function() assert.is_true(run.luarocks_bool("install c3")) - test_env.remove_dir(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/c3/1.0-1/doc") + test_env.remove_dir(testing_paths.testing_sys_rocks .. "/c3/1.0-1/doc") assert.is_false(run.luarocks_bool("doc c3")) end) it("LuaRocks doc with no doc folder opening descript.homepage", function() assert.is_true(run.luarocks_bool("install luarepl")) - test_env.remove_dir(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl/0.4-1/doc") + test_env.remove_dir(testing_paths.testing_sys_rocks .. "/luarepl/0.4-1/doc") local output = run.luarocks("doc luarepl") assert.is.truthy(output:find("Local documentation directory not found")) end) @@ -53,7 +53,7 @@ describe("LuaRocks doc tests #blackbox #b_doc", function() it("LuaRocks doc of luacov and list doc folder", function() assert.is_true(run.luarocks_bool("install luacov")) local output = assert.is.truthy(run.luarocks("doc luacov --list")) - assert.is.truthy(output:find("/lib/luarocks/rocks/luacov/0.11.0--1/doc/")) + assert.is.truthy(output:find("/lib/luarocks/rocks%-.*/luacov/0.11.0%-1/doc/", 1)) end) it("LuaRocks doc of luacov local", function() diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 74f8f493..92b780d3 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -83,9 +83,9 @@ describe("LuaRocks install tests #blackbox #b_install", function() assert.is_true(run.luarocks_bool("show luasec")) if env_variables.TYPE_TEST_ENV == "minimal" then assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) end - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec")) end) it('LuaRocks install - handle relative path in --tree #632', function() @@ -170,22 +170,22 @@ describe("LuaRocks install tests #blackbox #b_install", function() assert.is_true(run.luarocks_bool("install say 1.2")) assert.is_true(run.luarocks_bool("install luassert")) assert.is_true(run.luarocks_bool("install say 1.0")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) end) it("LuaRocks install break dependencies force", function() assert.is_true(run.luarocks_bool("install say 1.2")) assert.is_true(run.luarocks_bool("install luassert")) local output = run.luarocks("install --force say 1.0") assert.is.truthy(output:find("Checking stability of dependencies")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) end) it("LuaRocks install break dependencies force fast", function() assert.is_true(run.luarocks_bool("install say 1.2")) assert.is_true(run.luarocks_bool("install luassert")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) local output = run.luarocks("install --force-fast say 1.0") assert.is.falsy(output:find("Checking stability of dependencies")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.0-1")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.0-1")) end) end) end) diff --git a/spec/list_spec.lua b/spec/list_spec.lua index 1b082ab6..b9a8e4c4 100644 --- a/spec/list_spec.lua +++ b/spec/list_spec.lua @@ -22,8 +22,7 @@ describe("LuaRocks list tests #blackbox #b_list", function() it("LuaRocks list porcelain", function() local output = run.luarocks("list --porcelain") - local path = testing_paths.testing_sys_tree:gsub("-", "--") -- !not sure! why this is good - assert.is.truthy(output:find("luacov\t0.11.0--1\tinstalled\t" .. path .. "/lib/luarocks/rocks" )) + assert.is.truthy(output:find("luacov\t0.11.0-1\tinstalled\t" .. testing_paths.testing_sys_rocks, 1, true)) end) it("LuaRocks install outdated and list it", function() diff --git a/spec/make_spec.lua b/spec/make_spec.lua index ab2d49a3..4c406c68 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua @@ -35,7 +35,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() -- test it assert.is_true(run.luarocks_bool("show luasocket")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) -- delete downloaded and unpacked files lfs.chdir(testing_paths.luarocks_dir) @@ -63,7 +63,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() assert.is_true(run.luarocks_bool("make")) assert.is_true(run.luarocks_bool("show lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-3/lxsh-0.8.6-3.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-3/lxsh-0.8.6-3.rockspec")) end) it("LuaRocks make unnamed rockspec", function() @@ -71,7 +71,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() assert.is_true(run.luarocks_bool("make")) assert.is_true(run.luarocks_bool("show lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) os.remove("rockspec") end) @@ -81,7 +81,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() assert.is.truthy(output:match("Error: Inconsistency between rockspec filename")) assert.is_false(run.luarocks_bool("show lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks make ambiguous unnamed rockspec", function() @@ -91,7 +91,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() assert.is.truthy(output:match("Error: Please specify which rockspec file to use")) assert.is_false(run.luarocks_bool("show lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks make pack binary rock", function() diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index 03b3681e..4d3f5cdc 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua @@ -37,16 +37,16 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() it("LuaRocks remove built abelhas", function() assert.is_true(run.luarocks_bool("build abelhas 1.0")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/abelhas")) assert.is_true(run.luarocks_bool("remove abelhas 1.0")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/abelhas")) end) it("LuaRocks remove built abelhas with uppercase name", function() assert.is_true(run.luarocks_bool("build abelhas 1.0")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/abelhas")) assert.is_true(run.luarocks_bool("remove Abelhas 1.0")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/abelhas")) end) end) @@ -56,28 +56,28 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() end) it("LuaRocks remove fail, break dependencies", function() - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) assert.is_true(run.luarocks_bool("build lualogging")) assert.is_false(run.luarocks_bool("remove luasocket")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) end) it("LuaRocks remove force", function() - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) assert.is_true(run.luarocks_bool("build lualogging")) local output = run.luarocks("remove --force luasocket") - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) assert.is.truthy(output:find("Checking stability of dependencies")) end) it("LuaRocks remove force fast", function() - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) assert.is_true(run.luarocks_bool("build lualogging")) local output = run.luarocks("remove --force-fast luasocket") - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) assert.is.falsy(output:find("Checking stability of dependencies")) end) end) diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 988d8ef0..25cc51d8 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua @@ -55,66 +55,19 @@ describe("Basic tests #blackbox #b_util", function() end) it("LuaRocks test site config", function() - assert.is.truthy(os.rename("src/luarocks/site_config.lua", "src/luarocks/site_config.lua.tmp")) - assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua")) - assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua.tmp")) + local scname = "src/luarocks/core/site_config_"..test_env.lua_version:gsub("%.", "_")..".lua" + + assert.is.truthy(os.rename(scname, scname..".tmp")) + assert.is.falsy(lfs.attributes(scname)) + assert.is.truthy(lfs.attributes(scname..".tmp")) assert.is.truthy(run.luarocks("")) - assert.is.truthy(os.rename("src/luarocks/site_config.lua.tmp", "src/luarocks/site_config.lua")) - assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua.tmp")) - assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua")) + assert.is.truthy(os.rename(scname..".tmp", scname)) + assert.is.falsy(lfs.attributes(scname..".tmp")) + assert.is.truthy(lfs.attributes(scname)) end) - -- Disable versioned config temporarily, because it always takes - -- precedence over config.lua (config-5.x.lua is installed by default on Windows, - -- but not on Unix, so on Unix the os.rename commands below will fail silently, but this is harmless) - describe("LuaRocks config - more complex tests", function() - local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" - local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" - local scname = scdir .. "/config.lua" - - local configfile - if test_env.TEST_TARGET_OS == "windows" then - configfile = versioned_scname - else - configfile = scname - end - - it("LuaRocks fail system config", function() - os.rename(versioned_scname, versioned_scname .. "bak") - local ok = run.luarocks_bool("config --system-config") - os.rename(versioned_scname .. ".bak", versioned_scname) - assert.is_false(ok) - end) - - it("LuaRocks system config", function() - lfs.mkdir(testing_paths.testing_lrprefix) - lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") - lfs.mkdir(scdir) - - local sysconfig = io.open(configfile, "w+") - sysconfig:write(" ") - sysconfig:close() - - local output = run.luarocks("config --system-config") - os.remove(configfile) - assert.are.same(output, configfile) - end) - - it("LuaRocks fail system config invalid", function() - lfs.mkdir(testing_paths.testing_lrprefix) - lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") - lfs.mkdir(scdir) - - local sysconfig = io.open(configfile, "w+") - sysconfig:write("if if if") - sysconfig:close() - local ok = run.luarocks_bool("config --system-config") - os.remove(configfile) - assert.is_false(ok) - end) - end) end) test_env.unload_luarocks() diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 8c005aaa..f22acbb4 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua @@ -19,12 +19,9 @@ cfg.lua_version = _VERSION:match(" (5%.[123])$") or "5.1" local version_suffix = cfg.lua_version:gsub("%.", "_") -- Load site-local global configurations -local ok, site_config = pcall(require, "luarocks.site_config_"..version_suffix) +local ok, site_config = pcall(require, "luarocks.core.site_config_"..version_suffix) if not ok then - ok, site_config = pcall(require, "luarocks.site_config") -end -if not ok then - io.stderr:write("Site-local luarocks/site_config.lua file not found. Incomplete installation?\n") + io.stderr:write("Site-local luarocks/core/site_config_"..version_suffix..".lua file not found. Incomplete installation?\n") site_config = {} end @@ -229,7 +226,6 @@ do sys_config_file_default = sys_config_dir.."/config-"..cfg.lua_version..".lua" sys_config_file = load_config_file({ site_config.LUAROCKS_SYSCONFIG or sys_config_file_default, - sys_config_dir.."/config.lua", }) sys_config_ok = (sys_config_file ~= nil) end @@ -260,7 +256,6 @@ if not site_config.LUAROCKS_FORCE_CONFIG then if not home_config_ok then local list = { home_config_file_default, - home_config_dir.."/config.lua", } home_config_file = load_config_file(list) home_config_ok = (home_config_file ~= nil) @@ -337,7 +332,7 @@ local defaults = { lua_modules_path = "/share/lua/"..cfg.lua_version, lib_modules_path = "/lib/lua/"..cfg.lua_version, - rocks_subdir = site_config.LUAROCKS_ROCKS_SUBDIR or "/lib/luarocks/rocks", + rocks_subdir = "/lib/luarocks/rocks-"..cfg.lua_version, arch = "unknown", lib_extension = "unknown", diff --git a/test/test_environment.lua b/test/test_environment.lua index 6338da0a..56b394cd 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua @@ -12,13 +12,15 @@ REQUIREMENTS USAGE busted [-Xhelper ] ARGUMENTS - env= Set type of environment to use ("minimal" or "full", - default: "minimal"). - noreset Don't reset environment after each test - clean Remove existing testing environment. - travis Add if running on TravisCI. - appveyor Add if running on Appveyor. - os= Set OS ("linux", "osx", or "windows"). + env= Set type of environment to use ("minimal" or "full", + default: "minimal"). + noreset Don't reset environment after each test + clean Remove existing testing environment. + travis Add if running on TravisCI. + appveyor Add if running on Appveyor. + os= Set OS ("linux", "osx", or "windows"). + lua_dir= Path of Lua installation (default "/usr/local") + lua_interpreter= Name of the interpreter (default "lua") ]] local function help() @@ -128,6 +130,7 @@ local function execute_bool(command, print_command, env_variables) if print_command ~= nil then redirect_filename = test_env.testing_paths.luarocks_tmp.."/output.txt" redirect = " > "..redirect_filename + os.remove(redirect_filename) end local ok = os.execute(command .. redirect) ok = (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean @@ -160,8 +163,10 @@ end function test_env.set_lua_version() if _G.jit then test_env.LUAJIT_V = _G.jit.version:match("(2%.%d)%.%d") + test_env.lua_version = "5.1" else test_env.LUA_V = _VERSION:match("5%.%d") + test_env.lua_version = test_env.LUA_V end end @@ -192,6 +197,10 @@ function test_env.set_args() test_env.MINGW = true elseif argument == "vs" then test_env.MINGW = false + elseif argument:find("^lua_dir=") then + test_env.LUA_DIR = argument:match("^lua_dir=(.*)$") + elseif argument:find("^lua_interpreter=") then + test_env.LUA_INTERPRETER = argument:match("^lua_interpreter=(.*)$") else help() end @@ -338,7 +347,12 @@ local function create_env(testing_paths) local env_variables = {} env_variables.LUA_VERSION = luaversion_short env_variables.LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config.lua" - env_variables.LUA_PATH = testing_paths.testing_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" + if test_env.TEST_TARGET_OS == "windows" then + env_variables.LUA_PATH = testing_paths.testing_lrprefix .. "\\lua\\?.lua;" + else + env_variables.LUA_PATH = testing_paths.testing_lrprefix .. "/share/lua/" .. luaversion_short .. "/?.lua;" + end + env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" @@ -451,11 +465,10 @@ local function reset_environment(testing_paths, md5sums) end local function create_paths(luaversion_full) - local cfg = require("luarocks.core.cfg") local testing_paths = {} - testing_paths.luadir = cfg.variables.LUA_BINDIR:gsub("/bin/?$", "") - testing_paths.lua = cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter + testing_paths.luadir = (test_env.LUA_DIR or "/usr/local") + testing_paths.lua = testing_paths.luadir .. "/bin/" .. (test_env.LUA_INTERPRETER or "lua") if test_env.TEST_TARGET_OS == "windows" then testing_paths.luarocks_tmp = os.getenv("TEMP") @@ -479,6 +492,9 @@ local function create_paths(luaversion_full) testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full + testing_paths.testing_rocks = testing_paths.testing_tree .. "/lib/luarocks/rocks-" .. test_env.lua_version + testing_paths.testing_sys_rocks = testing_paths.testing_sys_tree .. "/lib/luarocks/rocks-" .. test_env.lua_version + if test_env.TEST_TARGET_OS == "windows" then testing_paths.win_tools = testing_paths.testing_lrprefix .. "/tools" end @@ -658,12 +674,12 @@ local function install_luarocks(install_env_vars) if test_env.TEST_TARGET_OS == "windows" then local compiler_flag = test_env.MINGW and "/MW" or "" 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)) - assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/site_config* " .. testing_paths.src_dir .. "/luarocks/site_config.lua")) + assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/core/site_config* " .. testing_paths.src_dir .. "/luarocks/core")) else local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix assert(execute_bool(configure_cmd, false, install_env_vars)) assert(execute_bool("make clean", false, install_env_vars)) - assert(execute_bool("make src/luarocks/site_config.lua", false, install_env_vars)) + assert(execute_bool("make src/luarocks/core/site_config_"..test_env.lua_version:gsub("%.", "_")..".lua", false, install_env_vars)) assert(execute_bool("make dev", false, install_env_vars)) end print("LuaRocks installed correctly!") -- cgit v1.2.3-55-g6feb