Compare commits

..

No commits in common. "master" and "0.1.0" have entirely different histories.

15 changed files with 306 additions and 2426 deletions

7
.gitignore vendored
View File

@ -1,7 +0,0 @@
*.pyc
*.egg-info
dist
.coverage
test/here
test/builds
test/luarocks

View File

@ -1,22 +1,30 @@
language: python
sudo: false
matrix:
include:
- os: linux
sudo: false
python: 2.7
- os: linux
sudo: false
python: 3.5
- os: osx
language: generic
cache:
directories: cache
python:
- "2.7"
- "3.2"
- "3.5"
install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo pip2 install pyflakes pycodestyle coverage coveralls nose --ignore-installed; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pip install pyflakes pycodestyle coverage coveralls nose; fi
- pip install pyflakes
- pip install pep8
script:
- pyflakes .
- pycodestyle .
- nosetests
- coveralls
- pep8 . --max-line-length 99 --ignore E302
- python hererocks.py here -l 5.3 -r^ --downloads cache --builds cache
- export PATH=$PATH:$PWD/here/bin
- lua -v
- luarocks --version
- luarocks make
- hererocks-test
- rm here -r
- python hererocks.py here -j 2.1 -r^ --downloads cache --builds cache
- lua -v
- luarocks --version
- luarocks make
- hererocks-test

View File

@ -1,243 +0,0 @@
# Changelog
## 0.20.0 (2018-09-10)
### New features and improvements
* Added support for LuaRocks 3.0.0 - 3.0.2. `latest` and `^` aliases still
point to `2.4.4`.
* `--show` can now be used when installing programs; all programs present
in the given location are listed after installation is complete.
### Fixes
* `package.path` for Lua 5.3+ built with hererocks now includes `./?/init.lua`,
just as with standard Lua.
## 0.19.0 (2018-07-11)
### New features and improvements
* Added support for Lua 5.4.0-work1 and 5.4.0-work2.
* Added support for Lua 5.3.5.
* Added patches for Lua 5.3.4:
- `Lua crashes when building sequences with more than 2^30 elements`
- `Table length computation overflows for sequences larger than 2^31
elements`
- `Memory-allocation error when resizing a table can leave it in an
inconsistent state`
## 0.18.0 (2018-03-13)
### New features and improvements
* Added support for LuaRocks 2.4.4.
* Using `3` as version when installing LuaRocks now uses master branch of the
LuaRocks git repo instead of `luarocks-3`.
* Added `lua_pushcclosure should not call the garbage collector when n is zero`
patch for Lua 5.3.4.
## 0.17.0 (2017-09-13)
### New features and improvements
* Added support for LuaRocks 2.4.3.
* When installing PUC-Rio Lua from a git repo or local sources, source files
are expected to be in root directory instead of `src`. This allows one to
install Lua from the default Lua repo at github.com/lua/lua.
## 0.16.0 (2017-06-10)
### New features and improvements
* Added support for LuaJIT 2.0.5 and 2.1.0-beta3.
* Added fallback to a mirror for PUC-Rio Lua download.
* Added `--timeout` option for downloads.
## 0.15.0 (2017-04-02)
### New features and improvements
* When building Lua with custom cflags, hererocks now instructs LuaRocks to use
same flags when building C modules.
## 0.14.0 (2017-01-31)
### New features and improvements
* Added support for Lua 5.3.4.
## 0.13.1 (2017-01-09)
### Fixes
* Fixed an error when setting up cl.exe and hererocks has been installed using
a version of pip that passes `prefix/hererocks` instead of
`prefix/hererocks-script.py` as `sys.argv[0]`.
## 0.13.0 (2016-12-22)
### New features and improvements
* Added support for LuaRocks 2.4.2.
* LuaRocks is now configured to allow using config in user home directory.
In particular, API keys for `luarocks upload` command are now properly cached.
## 0.12.0 (2016-11-04)
### New features and improvements
* Added support for LuaRocks 2.4.1.
* Updated URL for LuaRocks downloads and default git repo.
## 0.11.0 (2016-09-10)
### New features and improvements
* Added support for LuaRocks 2.4.0.
* Added two new patches for bugs in Lua 5.3.3, try `--patch`.
* Caching of downloads now works on Unix-like systems even when `$HOME` is
unset (#28).
## 0.10.0 (2016-07-14)
### New features and improvements
* hererocks now creates activation scripts a-la virtualenv in `<location>/bin`.
Bash, Zsh, Dash, Fish, Csh, Batch, and PowerShell are supported.
* Lua 5.3.3 can now be patched to fix a bug (`Expression list with four or more
expressions in a 'for' loop can crash the interpreter`), try `--patch`.
## 0.9.0 (2016-06-21)
### New features and improvements
* Added support for LuaRocks 2.0.13.
### Fixes
* Fixed occasional SHA256 mismatches when downloading LuaJIT (#27).
## 0.8.1 (2016-06-12)
### Fixes
* Fixed error when installing from non-default git repo on Windows.
## 0.8.0 (2016-06-07)
### New features and improvements
* Added support for Lua 5.3.3.
## 0.7.0 (2016-05-03)
### New features and improvements
* Windows support with automatic Visual Studio setup.
* New values for `--target` option for selecting Visual Studio version and
target architecture.
* New `--show` option for listing programs installed in a location.
* New `--patch` option for applying official patches for bugs in Lua (#21).
* Documented `--downloads` and `--builds` options, may be useful for caching.
### Fixes
* Fixed an error when a command failed when using Python 3 (#15).
* Fixed error when running with `HOME` environment variable undefined (#24).
## 0.6.2 (2016-03-22)
### Fixes
Fixed a bug that resulted in Lua being built without compatibility flags (#14).
## 0.6.1 (2016-03-22) [yanked]
## 0.6.0 (2016-03-20)
### Breaking changes
* `hererocks --luajit 2.1` now installs LuaJIT 2.1.0-beta2 instead of
using v2.1 git branch. Use `hererocks --luajit @v2.1` to get old behaviour.
### New features and improvements
* LuaJIT versions 2.1.0-beta1 - 2.1.0-beta2 are now supported.
* Lua is now built manually (`make` is not run).
* OS X 10.4+ support for Lua 5.1.0 - 5.1.2.
* SHA256 checksums for downloaded archives are now verified (#13).
* `--no-readline` flag for building Lua without readline library.
* Lua archives are now downloaded using HTTPS.
### Fixes
* `luajit.h` is installed for LuaJIT (#11, #12).
* `jit.*` modules work correctly for LuaJIT 2.0.1.
## 0.5.0 (2016-01-11)
### New features and improvements
LuaRocks 2.3.0 is now supported.
## 0.4.0 (2016-01-03)
### New features and improvements
* Documented --no-git-cache option.
### Fixes
* Fixed error when installing Lua 5.1 on OS X, thanks to @xpol.
## 0.3.1 (2015-12-22)
### Fixes
* Fetch LuaJIT from GitHub mirror archive to avoid 'Connection refused' errors
when installing it on Travis.
## 0.3.0 (2015-12-19)
### New features and improvements
* LuaRocks versions 2.0.8 - 2.0.12 are now supported.
* `--compat=none` now turns off Lua 5.0 compatibility options when installing
Lua 5.1
* Default git repos are cached.
* New `--cflags` option for adding custom compiler flags when compiling Lua and
LuaJIT.
### Fixes
* LuaJIT `jit.*` modules are now properly installed.
## 0.2.0 (2015-12-02)
### New features and improvements
* Lua 5.3.2 is now supported.
* Versions of installed programs are showed in status messages.
## 0.1.0 (2015-11-29)
### Breaking changes
* Removed `-c` and `-t` shortcuts.
### New features and improvements
* `--verbose` flag that prints commands hererocks runs.
* hererocks now checks if requested versions are already installed, and skips
installation in that case. Override using `--ignore-installed/-i` flag.
* PUC Rio Lua now has default git URI.
### Fixes
* Installing from a git branch now works with newer git versions.
## 0.0.3 (2015-08-14)
The first release.

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015 - 2017 Peter Melnichenko
Copyright (c) 2015 Peter Melnichenko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,117 +1,64 @@
hererocks
=========
.. |travis| image:: https://travis-ci.org/mpeterv/hererocks.svg?branch=master
.. image:: https://travis-ci.org/mpeterv/hererocks.svg?branch=master
:target: https://travis-ci.org/mpeterv/hererocks
.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/85mocuaej4owyifj?svg=true
:target: https://ci.appveyor.com/project/mpeterv/hererocks
|travis| |appveyor|
``hererocks`` is a single file Python 2.7/3.x script for installing `Lua <http://http://www.lua.org/>`_ (or `LuaJIT <http://luajit.org/>`_) and `LuaRocks <https://luarocks.org/>`_, its package manager, into a local directory. It configures Lua to only see packages installed by that bundled version of LuaRocks, so that the installation is isolated.
Basic usage
-----------
.. code-block:: bash
hererocks lua53 -l5.3 -rlatest # Install Lua 5.3 with latest LuaRocks into 'lua53' directory.
source lua53/bin/activate # Run activation script, adding 'lua53/bin' to $PATH.
lua -v # Lua, LuaRocks, and programs
luarocks install luacheck # installed using LuaRocks
luacheck --version # can now be used.
deactivate-lua # Remove 'lua53/bin' from $PATH.
lua53/bin/lua -v # All the binaries can still be used directly.
For more info see below or run ``hererocks --help`` for a complete listing of options.
``hererocks`` is a single file Python script for installing `Lua <http://http://www.lua.org/>`_ (or `LuaJIT <http://luajit.org/>`_) and `LuaRocks <https://luarocks.org/>`_, its package manager, into a local directory. It configures Lua to only see packages installed by that bundled version of LuaRocks, so that the installation is isolated.
Installation
------------
Using `pip <https://pypi.python.org/pypi/pip>`_: run ``pip install hererocks``, using ``sudo`` if necessary.
Manually: download hererocks with ``wget https://raw.githubusercontent.com/mpeterv/hererocks/latest/hererocks.py``, then use ``python hererocks.py ...`` to run it.
Manually: download hererocks with ``wget https://raw.githubusercontent.com/mpeterv/hererocks/0.1.0/hererocks.py``, then use ``python hererocks.py ...`` to run it.
Requirements
------------
* Python 2.7 or 3.x
* Git for installing from Git repositories.
* Compiler:
* Windows: MinGW with tools such as ``gcc`` in PATH, or Visual Studio 2008 or later (see help message for ``--target``).
* OS X: ``cc``.
* Other systems: ``gcc``.
Activation scripts
------------------
``hererocks`` writes several activation scripts into ``bin`` subdirectory of the installation directory.
When sourced (on Windows: simply executed) they add path to that subdirectory to ``PATH`` environment variable.
This allows one to use ``lua``, ``luarocks`` and other programs installed in the created environment directly.
Additionally, activation scripts make ``deactivate-lua`` command available. It removes path to currently activated
environment from ``PATH``. Activating an environment deactivates the previous one automatically, if it exists.
Several versions of activation scripts are installed to support various shells:
* Windows:
* Batch: ``activate.bat``.
* PowerShell: ``activate.ps1``.
* Other systems:
* Bash, Zsh, Dash: ``activate``.
* Fish: ``activate.fish``.
* Tcsh, csh: ``activate.csh``.
Command-line options
--------------------
Usage
-----
Installation location
^^^^^^^^^^^^^^^^^^^^^
The first argument of ``hererocks`` command should be path to the directory where Lua and/or LuaRocks should be installed. If it does not exist, it will be created.
If installation directory already has Lua installed, a new version of Lua or LuaRocks can be installed over it as a seamless upgrade (packages installed with LuaRocks will keep working) provided new and old Lua minor versions are same. E.g. Lua 5.1.5 and LuaJIT 2.1 can be installed over Lua 5.1.1, but not over Lua 5.2.1. Otherwise, when installing an incompatible Lua version, the installation directory should be removed prior to running ``hererocks``. If ``hererocks`` detects that it has already installed requested version of Lua or LuaRocks built with same options into the directory, it will skip installation for that program, unless ``--ignore-installed/-i`` is used.
If installation directory already has Lua installed, a new version of Lua or LuaRocks can be installed over it as a seamless upgrade (packages installed with LuaRocks will keep working) provided new and old Lua minor versions are same. E.g. Lua 5.1.5 and LuaJIT 2.1 can be installed over Lua 5.1.1, but not over Lua 5.2.1. Otherwise, when installing an incompatible Lua version, the installation directory should be removed prior to running ``hererocks``. If ``hererocks`` detects that it has already installed requested version of Lua or LuaRocks into the directory, it will skip installation for that program, unless ``--ignore-installed/-i`` is used.
After installation Lua and LuaRocks binaries will be in the ``bin`` subdirectory of the installation directory. Scripts installed using LuaRocks will also turn up there. Lua binary is always named ``lua``, even if it's LuaJIT under the hood, and LuaRocks binary is named ``luarocks`` as usual.
Version selection
^^^^^^^^^^^^^^^^^
``--lua/-l``, ``--luajit/-j`` and ``--luarocks/-r`` options select versions of programs to install. There are three ways to specify how to fetch the sources:
``--lua/-l``, ``--luajit/-j`` and ``--luarocks/-r`` options should be used to select versions of programs to install. There are three ways to specify how to fetch the sources:
* Using version number, such as ``5.1.5``. If patch or minor versions are left out the latest possible version will be used, e.g. for Lua ``5.2`` is currently equivalent to ``5.2.4`` and for LuaJIT ``2.1`` is same as ``2.1.0-beta3``. ``latest`` or ``^`` can be used to select the latest stable version. ``hererocks`` will fetch and unpack sources of the selected version from corresponding downloads location, verifying their SHA256 checksum.
* Using git URI plus reference to checkout, separated by ``@``. Default reference is ``master``, and there are default git URIs for Lua (https://github.com/lua/lua), LuaJIT (https://github.com/luajit/luajit) and LuaRocks (https://github.com/luarocks/luarocks). For instance, ``--luajit @458a40b`` installs from a commit at the LuaJIT git repository and ``--luajit @`` installs from its master branch. ``hererocks`` will use ``git`` command for cloning.
* Using version number, such as ``5.1.5``. If patch or minor versions are left out the latest possible version will be used, e.g. for Lua ``5.2`` is currently equivalent to ``5.2.4``. ``^`` can be used to select the latest stable version. ``hererocks`` will fetch and unpack sources of the selected version from corresponding official downloads location.
* Using git URI plus reference to checkout, separated by ``@``. Default reference is ``master``, and there are default git URIs for `Lua <https://github.com/lua/lua>`_, `LuaJIT <https://github.com/luajit/luajit>`_ and `LuaRocks <https://github.com/keplerproject/luarocks>`_. For instance, ``--luajit @458a40b`` installs from a commit at the LuaJIT git repository and ``--luajit @`` installs from its master branch. ``hererocks`` will use ``git`` command for cloning.
* Using path to a local directory.
Compatibility flags
^^^^^^^^^^^^^^^^^^^
Lua and LuaJIT have some flags that add compatibility with other Lua versions. Lua 5.1 has several options for compatibility with Lua 5.0 (on by default), Lua 5.2 has 5.1 compatibility flag (on by default), Lua 5.3 - both 5.1 and 5.2 compatibility flags (only 5.2 compatibility is on by default), and LuaJIT has 5.2 flag (off by default). ``hererocks`` can change these flags before building when using ``--compat`` option. Possible arguments are ``default``, ``none``, ``all``, ``5.1`` and ``5.2``.
Lua and LuaJIT have some flags that add compatibility with other Lua versions. Lua 5.2 has 5.1 compatibility flag (on by default), Lua 5.3 - both 5.1 and 5.2 compatibility flags (only 5.2 compatibility is on by default), and LuaJIT has 5.2 flag (off by default). ``hererocks`` can change these flags before building when using ``--compat`` option. Possible arguments are ``default``, ``none``, ``all``, ``5.1`` and ``5.2``.
Installing standard PUC-Rio Lua
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Available versions: 5.1 - 5.1.5, 5.2.0 - 5.2.4, 5.3.0 - 5.3.5, 5.4.0-work1 - 5.4.0-work2 (5.4 and 5.4.0 are aliases for 5.4.0-work2). ``latest`` and ``^`` version aliases point to ``5.3.5``.
Available versions: 5.1 - 5.1.5, 5.2.0 - 5.2.4, 5.3.0 - 5.3.1.
Use ``5.1.0`` to install Lua ``5.1`` which was released without patch version for some reason.
When building Lua, ``hererocks`` tries to emulate a sensible ``make`` target. The default can be seen in the help message printed by ``hererocks --help``. To select another target use ``--target`` option.
When building Lua, ``hererocks`` tries to use sensible ``make`` target. The default can be seen in the help message printed by ``hererocks --help``. To select another target, use ``--target`` option.
Installing LuaJIT
^^^^^^^^^^^^^^^^^
Available versions: 2.0.0 - 2.0.5, 2.1.0-beta1 - 2.1.0-beta3. ``latest`` and ``^`` version aliases point to ``2.0.5``.
Available versions: 2.0.0 - 2.0.4, 2.1 (installs from ``v2.1`` branch of the LuaJIT git repository).
Installing LuaRocks
^^^^^^^^^^^^^^^^^^^
Available versions: 2.0.8 - 2.0.13, 2.1.0 - 2.1.2, 2.2.0 - 2.2.2, 2.3.0, 2.4.0 - 2.4.4, 3.0.0 - 3.0.2. ``latest`` and ``^`` version aliases point to ``2.4.4``.
Available versions: 2.1.0 - 2.1.2, 2.2.0 - 2.2.2, 3 (installs from ``luarocks-3`` branch of the LuaRocks git repository).
Version 2.0.8 does not support Lua 5.2. Versions 2.0.8 - 2.1.2 do not support Lua 5.3.
Versions 2.1.0 - 2.1.2 do not support Lua 5.3.
Using hererocks to set up automated testing
-------------------------------------------
@ -120,9 +67,8 @@ Popular continuous integration services such as `Travis-CI <https://travis-ci.or
.. code-block:: yaml
language: python # Can use any language here, but if it's not 'python'
# it becomes necessary to pass '--user' to pip when installing hererocks.
sudo: false # Use container-based infrastructure.
language: python # Need python environment for pip
sudo: false # Use container-based infrastructure
env:
- LUA="lua 5.1"
@ -133,38 +79,15 @@ Popular continuous integration services such as `Travis-CI <https://travis-ci.or
before_install:
- pip install hererocks
- hererocks env --$LUA -rlatest # Use latest LuaRocks, install into 'env' directory.
- source env/bin/activate # Add directory with all installed binaries to PATH.
- hererocks here -r^ --$LUA # Install latest LuaRocks version
# plus the Lua version for this build job
# into 'here' subdirectory
- export PATH=$PATH:$PWD/here/bin # Add directory with all installed binaries to PATH
- luarocks install busted
install:
- luarocks make # Install the rock, assuming there is a rockspec
# in the root of the repository.
# in the root of the repository
script:
- busted
Equivalent configuration (``appveyor.yml``) for `Appveyor <http://www.appveyor.com/>`_ that allows testing on Windows:
.. code-block:: yaml
environment:
matrix:
- LUA: "lua 5.1"
- LUA: "lua 5.2"
- LUA: "lua 5.3"
- LUA: "luajit 2.0"
- LUA: "luajit 2.1"
before_build:
- set PATH=C:\Python27\Scripts;%PATH% # Add directory containing 'pip' to PATH
- pip install hererocks
- hererocks env --%LUA% -rlatest
- call env\bin\activate
- luarocks install busted
build_script:
- luarocks make
test_script:
- busted
- busted spec # Run the test suite, assuming tests are in the 'spec' subdirectory

View File

@ -1,17 +0,0 @@
version: 1.0.{build}
environment:
matrix:
- Python: 35-x64
- Python: 27
build_script:
- PATH %CD%\here\bin;C:\mingw\bin;C:\python%Python%;C:\python%Python%\scripts;%PATH%
- pip install pyflakes pycodestyle coverage coveralls nose
test_script:
- pyflakes .
- pycodestyle .
- nosetests
- coverage report
- if not "%COVERALLS_REPO_TOKEN%"=="" coveralls

View File

@ -15,11 +15,11 @@ dependencies = {
build = {
type = "builtin",
modules = {
["hererocks.test"] = "test/test.lua"
["hererocks.test"] = "test.lua"
},
install = {
bin = {
["hererocks-test"] = "test/hererocks-test.lua"
["hererocks-test"] = "hererocks-test.lua"
}
},
copy_directories = {}

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +0,0 @@
[pycodestyle]
ignore = E203,E302,E305,E501

View File

@ -9,7 +9,7 @@ readme.close()
setuptools.setup(
name="hererocks",
version="0.20.0",
version="0.1.0",
description="Tool for installing Lua and LuaRocks locally",
long_description=long_description,
keywords="lua",
@ -18,7 +18,7 @@ setuptools.setup(
author_email="mpeterval@gmail.com",
license="MIT",
classifiers=[
"Development Status :: 4 - Beta",
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
@ -28,9 +28,7 @@ setuptools.setup(
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7"
"Programming Language :: Python :: 3.5"
],
py_modules=["hererocks"],
entry_points={

View File

@ -1,21 +0,0 @@
@echo off
echo "initial: %PATH%"
call "test\here\bad (dir) 1\bin\activate"
echo "activate 1: %PATH%"
call deactivate-lua
echo "deactivate 1: %PATH%"
call "test\here\bad (dir) 1\bin\activate"
echo "activate 1 again: %PATH%"
call "test\here\bad (dir) 1\bin\activate"
echo "reactivate 1: %PATH%"
call "test\here\bad (dir) 2\bin\activate"
echo "activate 2: %PATH%"
call deactivate-lua
echo "deactivate 2: %PATH%"

View File

@ -1,20 +0,0 @@
#!/usr/bin/env bash
echo "initial: $PATH"
source "test/here/bad (dir) 1/bin/activate"
echo "activate 1: $PATH"
deactivate-lua
echo "deactivate 1: $PATH"
source "test/here/bad (dir) 1/bin/activate"
echo "activate 1 again: $PATH"
source "test/here/bad (dir) 1/bin/activate"
echo "reactivate 1: $PATH"
source "test/here/bad (dir) 2/bin/activate"
echo "activate 2: $PATH"
deactivate-lua
echo "deactivate 2: $PATH"

View File

@ -1,156 +0,0 @@
import os
import shutil
import subprocess
import time
import unittest
class TestCLI(unittest.TestCase):
@classmethod
def setUpClass(cls):
subprocess.check_call(["coverage", "erase"])
def setUp(self):
if os.name == "nt":
# On Windows tests randomly fail here with errors such as 'can not remove here\bin: directory not empty'.
# Supposedly this happens because a file in the directory is still open, and on NFS
# deleting an open file leaves a file in the same directory. Waiting before attempting
# to remove directories seems to help.
time.sleep(1)
for subdir in ["here", "builds"]:
if os.path.exists(os.path.join("test", subdir)):
shutil.rmtree(os.path.join("test", subdir))
def assertSuccess(self, args, expected_output_lines=None, from_prefix=True):
if from_prefix:
args[0] = os.path.join("test", "here", "bin", args[0])
if os.name == "nt" and not os.path.exists(args[0]) and not os.path.exists(args[0] + ".exe"):
args[0] += ".bat"
process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = process.communicate()[0]
if process.returncode != 0:
raise AssertionError("Error running command '{}': code {}, output:\n{}".format(
" ".join(args), process.returncode, output))
if expected_output_lines is not None:
actual_output_lines = output.splitlines()
for expected_output_line in expected_output_lines:
expected_output_line = expected_output_line.encode("UTF-8")
if not any(expected_output_line in actual_output_line for actual_output_line in actual_output_lines):
raise AssertionError("Expected to see '{}' in output of command '{}', got output:\n{}".format(
expected_output_line, " ".join(args), output))
def assertHererocksSuccess(self, args, expected_output_lines=None, location="here"):
self.assertSuccess([
"coverage", "run", "-a",
"hererocks.py", os.path.join("test", location)] + args, expected_output_lines, from_prefix=False)
def test_install_latest_lua_with_latest_luarocks(self):
self.assertHererocksSuccess(["--lua", "latest", "--luarocks", "latest"])
self.assertHererocksSuccess(["--show"], ["Programs installed in", "Compat: default"])
self.assertSuccess(["lua", "-v"], ["Lua 5.3.5"])
self.assertSuccess(["lua", "-e", "assert(bit32)"])
self.assertSuccess(["luarocks", "--version"])
self.assertSuccess(["luarocks", "make", os.path.join("test", "hererocks-test-scm-1.rockspec")])
self.assertSuccess(["hererocks-test"], ["Lua 5.3"])
self.assertHererocksSuccess(["--lua", "latest", "--luarocks", "latest"], ["already installed"])
self.assertHererocksSuccess(["--luarocks", "latest", "--ignore-installed"], ["Fetching", "cached"])
def test_install_latest_lua_with_luarocks_from_git(self):
self.assertHererocksSuccess(["--lua", "latest", "--luarocks", "https://github.com/mpeterv/luarocks@master"])
def test_install_lua_from_git_with_latest_luarocks(self):
self.assertHererocksSuccess(["--lua", "@b1daa06", "--luarocks", "latest"])
self.assertHererocksSuccess(["--show"], ["Programs installed in", "cloned from https://github.com/lua/lua"])
self.assertSuccess(["luarocks", "--version"])
def test_verbose_install_bleeding_edge_luajit_with_latest_luarocks(self):
self.assertHererocksSuccess(["--luajit", "@v2.1", "--luarocks", "latest", "--verbose"])
self.assertSuccess(["lua", "-v"], ["LuaJIT 2.1.0"])
self.assertSuccess(["lua", "-e", "require 'jit.bcsave'"])
self.assertSuccess(["luarocks", "--version"])
self.assertSuccess(["luarocks", "make", os.path.join("test", "hererocks-test-scm-1.rockspec")])
self.assertSuccess(["hererocks-test"], ["LuaJIT 2.1.0"])
self.assertHererocksSuccess(["--luajit", "@v2.1", "--luarocks", "latest"], ["already installed"])
self.assertHererocksSuccess(["--show"], ["cloned from https://github.com/LuaJIT/LuaJIT"])
def test_install_lua_5_1_without_compat_without_readline_with_old_luarocks(self):
self.assertHererocksSuccess(["--lua", "5.1", "--compat", "none", "--no-readline", "--luarocks", "2.0.8"])
self.assertSuccess(["lua", "-e", "assert(not pcall(string.gfind, '', '.'))"])
self.assertSuccess(["lua", "-e", "(function(...) assert(arg == nil) end)()"])
self.assertSuccess(["lua", "-e", "assert(math.mod == nil)"])
self.assertSuccess(["luarocks", "--version"])
self.assertSuccess(["luarocks", "make", os.path.join("test", "hererocks-test-scm-1.rockspec")])
def test_install_lua_5_3_2_with_patches(self):
self.assertHererocksSuccess(["--lua", "5.3.2", "--patch"])
self.assertSuccess(["lua", "-e", "assert(coroutine.wrap(string.gmatch('x', '.'))() == 'x')"])
if os.name == "nt":
self.assertHererocksSuccess(["--lua", "5.3.2", "--patch", "--target", "vs"])
self.assertSuccess(["lua", "-e", "assert(coroutine.wrap(string.gmatch('x', '.'))() == 'x')"])
def test_install_luajit_with_compat_with_apicheck(self):
self.assertHererocksSuccess(["--luajit", "latest", "--compat", "5.2", "--cflags=-DLUA_USE_APICHECK"])
if os.name == "nt":
self.assertHererocksSuccess([
"--luajit", "latest", "--compat", "5.2", "--cflags=-DLUA_USE_APICHECK", "--target", "vs"])
def test_cached_lua_5_2_build(self):
self.assertHererocksSuccess(
["--lua", "5.2", "--builds", os.path.join("test", "builds")],
["No patches available for Lua 5.2"])
self.assertHererocksSuccess(
["--lua", "5.2", "--compat", "none", "--builds", os.path.join("test", "builds")],
["No patches available for Lua 5.2"])
self.assertHererocksSuccess(
["--lua", "5.2", "--ignore-installed", "--compat", "none", "--builds", os.path.join("test", "builds")],
["compat: none) (cached)"])
def test_install_lua_5_2_with_luarocks_from_local_sources(self):
local_luarocks = os.path.join("test", "luarocks")
if not os.path.exists(local_luarocks):
self.assertSuccess([
"git", "clone", "https://github.com/keplerproject/luarocks",
"--depth=1", local_luarocks], from_prefix=False)
self.assertHererocksSuccess(["--lua", "5.2", "--luarocks", local_luarocks])
self.assertHererocksSuccess(["--show"], ["from local sources"])
def test_activate_scripts(self):
self.assertHererocksSuccess(["--lua", "5.1"], location=os.path.join("here", "bad (dir) 1"))
self.assertHererocksSuccess(["--lua", "5.2"], location=os.path.join("here", "bad (dir) 2"))
checker = os.path.join("test", "check_activate." + ("bat" if os.name == "nt" else "sh"))
path = os.getenv("PATH")
path1 = os.path.abspath(os.path.join("test", "here", "bad (dir) 1", "bin"))
path2 = os.path.abspath(os.path.join("test", "here", "bad (dir) 2", "bin"))
self.assertSuccess([checker], [
"initial: {}".format(path),
"activate 1: {}{}{}".format(path1, os.pathsep, path),
"deactivate 1: {}".format(path),
"activate 1 again: {}{}{}".format(path1, os.pathsep, path),
"reactivate 1: {}{}{}".format(path1, os.pathsep, path),
"activate 2: {}{}{}".format(path2, os.pathsep, path),
"deactivate 2: {}".format(path)
], from_prefix=False)
def test_install_lua_5_4_with_luarocks_3(self):
self.assertHererocksSuccess(["--lua", "5.4", "--luarocks", "3"])
self.assertHererocksSuccess(["--lua", "5.4.0-work1", "--luarocks", "3"])
if os.name == "nt":
self.assertHererocksSuccess(["--lua", "5.4", "--luarocks", "3", "--target", "vs"])
self.assertHererocksSuccess(["--lua", "5.4.0-work1", "--luarocks", "3", "--target", "vs"])