Skip to content

Commit

Permalink
Merge pull request #15 from thibaultCha/feat/rewrite
Browse files Browse the repository at this point in the history
feat(rewrite)
  • Loading branch information
thibaultcha committed Dec 18, 2015
2 parents e0a269a + 4a23097 commit e3a8530
Show file tree
Hide file tree
Showing 114 changed files with 7,703 additions and 3,072 deletions.
21 changes: 21 additions & 0 deletions .ci/busted_print.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local ansicolors = require 'ansicolors'

return function(options)
local handler = require 'busted.outputHandlers.utfTerminal'(options)

handler.fileStart = function(file)
io.write('\n' .. ansicolors('%{cyan}' .. file.name) .. ':')
end

handler.testStart = function(element, parent, status, debug)
io.write('\n ' .. handler.getFullName(element) .. ' ... ')
io.flush()
end

local busted = require 'busted'

busted.subscribe({ 'file', 'start' }, handler.fileStart)
busted.subscribe({ 'test', 'start' }, handler.testStart)

return handler
end
File renamed without changes.
11 changes: 11 additions & 0 deletions .ci/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

if [ "$OPENRESTY_TESTS" != "yes" ]; then
busted -v --coverage -o .ci/busted_print.lua
make lint
luacov-coveralls -i cassandra
else
prove -l t
fi
12 changes: 12 additions & 0 deletions .ci/setup_cassandra.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

arr=(${HOSTS//,/ })

pip install --user PyYAML six
git clone https://github.com/pcmanus/ccm.git
pushd ccm
./setup.py install --user
popd
ccm create test -v binary:$CASSANDRA_VERSION -n ${#arr[@]} -d
ccm start -v
ccm status
100 changes: 100 additions & 0 deletions .ci/setup_lua.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash

# A script for setting up environment for travis-ci testing.
# Sets up Lua and Luarocks.
# LUA must be "lua5.1", "lua5.2" or "luajit".
# luajit2.0 - master v2.0
# luajit2.1 - master v2.1

LUAJIT="no"

source .ci/platform.sh

############
# Lua/LuaJIT
############

if [ "$LUA" == "luajit" ]; then
LUAJIT="yes"
LUA="luajit-2.0"
elif [ "$LUA" == "luajit-2.0" ]; then
LUAJIT="yes"
elif [ "$LUA" == "luajit-2.1" ]; then
LUAJIT="yes"
fi

if [ "$LUAJIT" == "yes" ]; then
mkdir -p $LUAJIT_DIR

# If cache is empty, download and compile
if [ ! "$(ls -A $LUAJIT_DIR)" ]; then
git clone http://luajit.org/git/luajit-2.0.git
pushd luajit-2.0

if [ "$LUA" == "luajit-2.0" ]; then
git checkout v2.0.4
elif [ "$LUA" == "luajit-2.1" ]; then
git checkout v2.1
fi

make
make install PREFIX=$LUAJIT_DIR
popd

if [ "$LUA" == "luajit-2.1" ]; then
ln -sf $LUAJIT_DIR/bin/luajit-2.1.0-beta1 $LUAJIT_DIR/bin/luajit
fi

ln -sf $LUAJIT_DIR/bin/luajit $LUAJIT_DIR/bin/lua
fi

LUA_INCLUDE="$LUAJIT_DIR/include/$LUA"
else
if [ "$LUA" == "lua5.1" ]; then
curl http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz
pushd lua-5.1.5
elif [ "$LUA" == "lua5.2" ]; then
curl http://www.lua.org/ftp/lua-5.2.3.tar.gz | tar xz
pushd lua-5.2.3
elif [ "$LUA" == "lua5.3" ]; then
curl http://www.lua.org/ftp/lua-5.3.0.tar.gz | tar xz
pushd lua-5.3.0
fi

make $PLATFORM
make install INSTALL_TOP=$LUA_DIR
popd

LUA_INCLUDE="$LUA_DIR/include"
fi

##########
# Luarocks
##########

LUAROCKS_BASE=luarocks-$LUAROCKS_VERSION
CONFIGURE_FLAGS=""

git clone https://github.com/keplerproject/luarocks.git $LUAROCKS_BASE

pushd $LUAROCKS_BASE
git checkout v$LUAROCKS_VERSION

if [ "$LUAJIT" == "yes" ]; then
LUA_DIR=$LUAJIT_DIR
elif [ "$LUA" == "lua5.1" ]; then
CONFIGURE_FLAGS=$CONFIGURE_FLAGS" --lua-version=5.1"
elif [ "$LUA" == "lua5.2" ]; then
CONFIGURE_FLAGS=$CONFIGURE_FLAGS" --lua-version=5.2"
elif [ "$LUA" == "lua5.3" ]; then
CONFIGURE_FLAGS=$CONFIGURE_FLAGS" --lua-version=5.3"
fi

./configure \
--prefix=$LUAROCKS_DIR \
--with-lua-bin=$LUA_DIR/bin \
--with-lua-include=$LUA_INCLUDE \
$CONFIGURE_FLAGS

make build && make install
popd
43 changes: 43 additions & 0 deletions .ci/setup_openresty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

if [ "$OPENRESTY_TESTS" != "yes" ]; then
exit
echo "Exiting, no openresty tests"
fi

set -e

mkdir -p $OPENRESTY_DIR

if [ ! "$(ls -A $OPENRESTY_DIR)" ]; then
OPENRESTY_BASE=ngx_openresty-$OPENRESTY_VERSION

curl https://openresty.org/download/$OPENRESTY_BASE.tar.gz | tar xz
pushd $OPENRESTY_BASE

./configure \
--prefix=$OPENRESTY_DIR \
--with-luajit=$LUAJIT_DIR \
--without-http_coolkit_module \
--without-lua_resty_dns \
--without-lua_resty_lrucache \
--without-lua_resty_upstream_healthcheck \
--without-lua_resty_websocket \
--without-lua_resty_upload \
--without-lua_resty_string \
--without-lua_resty_mysql \
--without-lua_resty_redis \
--without-http_redis_module \
--without-http_redis2_module \
--without-lua_redis_parser

make
make install
popd
fi

git clone git://github.com/travis-perl/helpers travis-perl-helpers
pushd travis-perl-helpers
source ./init
popd
cpan-install Test::Nginx::Socket
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nginx_tmp
t/servroot
3 changes: 2 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
unused_args = false
globals = {"ngx", "describe", "setup", "teardown", "it", "pending"}
redefined = false
globals = {"ngx", "describe", "setup", "teardown", "it", "pending", "before_each", "after_each", "finally", "spy", "mock"}
62 changes: 43 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,50 @@
language: erlang

language: perl
perl: "5.18"
sudo: false
notifications:
email: false
addons:
apt:
packages:
- libreadline-dev
- libncurses5-dev
- libpcre3-dev
- libssl-dev
- build-essential
env:
global:
- LUAROCKS=2.2.2
- CASSANDRA_VERSION=2.1.8
- CASSANDRA_VERSION=2.1.9
- LUAROCKS_VERSION=2.2.2
- OPENRESTY_VERSION=1.9.3.1
- LUA_DIR=$HOME/lua
- LUAJIT_DIR=$HOME/luajit
- LUAROCKS_DIR=$HOME/luarocks
- OPENRESTY_DIR=$HOME/openresty
- "HOSTS=127.0.0.1,127.0.0.2,127.0.0.3"
- SMALL_LOAD=true
matrix:
- LUA=lua5.1
- LUA=lua5.2
- LUA=lua5.3
- LUA=luajit

- LUA=luajit-2.1
- OPENRESTY_TESTS: "yes"
LUA: "luajit-2.1"
before_install:
- bash .travis/setup_lua.sh
- bash .travis/setup_cassandra.sh
- sudo luarocks install luasocket
- sudo make dev

script:
- "busted -v --coverage"
- "make lint"

after_success: "luacov-coveralls -i cassandra"

notifications:
email: false
- bash .ci/setup_cassandra.sh
- bash .ci/setup_lua.sh
- bash .ci/setup_openresty.sh
- export PATH=$LUA_DIR/src:$LUAJIT_DIR/bin:$LUAROCKS_DIR/bin:$OPENRESTY_DIR/nginx/sbin:$PATH
- export LUA_PATH="./?.lua;$LUAROCKS_DIR/share/lua/5.1/?.lua;$LUAROCKS_DIR/share/lua/5.1/?/init.lua;$LUAROCKS_DIR/lib/lua/5.1/?.lua;$LUA_PATH"
- export LUA_CPATH="$LUAROCKS_DIR/lib/lua/5.1/?.so;$LUA_CPATH"
install:
- make dev
- luarocks install ansicolors
script: .ci/run_tests.sh
cache:
cpan: true
apt: true
pip: true
directories:
- $LUAJIT_DIR
- $OPENRESTY_DIR
- $HOME/.ccm/repository/
7 changes: 0 additions & 7 deletions .travis/setup_cassandra.sh

This file was deleted.

101 changes: 0 additions & 101 deletions .travis/setup_lua.sh

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MIT License (MIT)

Original work Copyright (c) 2014 Juarez Bochi
Modified work Copyright 2015 Thibault Charbonnier
Original work Copyright (c) 2015 Thibault Charbonnier
Based on the work of Juarez Bochi Copyright 2014

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit e3a8530

Please sign in to comment.