From a04ab7d9cda9be83aae9d05359d13b0ea22f0b90 Mon Sep 17 00:00:00 2001 From: "Vadim A. Misbakh-Soloviov" Date: Sun, 9 Apr 2017 13:15:06 +0700 Subject: [PATCH] added travis; moved rockspecs; tests and docs modified --- .travis.yml | 42 ++++++ .travis/platform.sh | 15 +++ .travis/setenv_lua.sh | 3 + .travis/setup_lua.sh | 122 ++++++++++++++++++ doc/README.html | 6 +- doc/sample.html | 2 +- doc/sample.lua | 2 +- .../htmlparser-0.3.2-2.rockspec | 0 .../htmlparser-scm-0.rockspec | 0 tst/.luacov | 50 +++++++ tst/init.lua | 16 ++- 11 files changed, 252 insertions(+), 6 deletions(-) create mode 100644 .travis.yml create mode 100644 .travis/platform.sh create mode 100644 .travis/setenv_lua.sh create mode 100644 .travis/setup_lua.sh rename htmlparser-0.3.2-2.rockspec => rockspecs/htmlparser-0.3.2-2.rockspec (100%) rename htmlparser-scm-0.rockspec => rockspecs/htmlparser-scm-0.rockspec (100%) create mode 100644 tst/.luacov diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8377480 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +language: c + +sudo: false + +env: + global: + - LUAROCKS=2.3.0 + matrix: + - LUA=lua5.1 + - LUA=lua5.2 + - LUA=lua5.3 + - LUA=luajit # latest stable version (2.0.4) + - LUA=luajit2.0 # current head of 2.0 branch + - LUA=luajit2.1 # current head of 2.1 branch + +#branches: +# only: +# - master + +before_install: + - source .travis/setenv_lua.sh + - pip install --user cpp-coveralls + - luarocks install Lua-cURL --server=https://luarocks.org/dev + - luarocks install luacov-coveralls --server=https://luarocks.org/dev + - luarocks install lunitx + +install: + - luarocks make rockspecs/htmlparser-scm-0.rockspec CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage" + +script: + - cd tst + - lua -e "print(require'cURL'.version())" + - lunit.sh init.lua + +after_success: + - coveralls -b .. -r .. -i ./src --dump c.report.json + - luacov-coveralls -j c.report.json -v + +notifications: + email: + on_success: change + on_failure: always diff --git a/.travis/platform.sh b/.travis/platform.sh new file mode 100644 index 0000000..7259a7d --- /dev/null +++ b/.travis/platform.sh @@ -0,0 +1,15 @@ +if [ -z "${PLATFORM:-}" ]; then + PLATFORM=$TRAVIS_OS_NAME; +fi + +if [ "$PLATFORM" == "osx" ]; then + PLATFORM="macosx"; +fi + +if [ -z "$PLATFORM" ]; then + if [ "$(uname)" == "Linux" ]; then + PLATFORM="linux"; + else + PLATFORM="macosx"; + fi; +fi diff --git a/.travis/setenv_lua.sh b/.travis/setenv_lua.sh new file mode 100644 index 0000000..8d8c825 --- /dev/null +++ b/.travis/setenv_lua.sh @@ -0,0 +1,3 @@ +export PATH=${PATH}:$HOME/.lua:$HOME/.local/bin:${TRAVIS_BUILD_DIR}/install/luarocks/bin +bash .travis/setup_lua.sh +eval `$HOME/.lua/luarocks path` diff --git a/.travis/setup_lua.sh b/.travis/setup_lua.sh new file mode 100644 index 0000000..6dcc0c6 --- /dev/null +++ b/.travis/setup_lua.sh @@ -0,0 +1,122 @@ +#! /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 + +set -eufo pipefail + +LUAJIT_VERSION="2.0.4" +LUAJIT_BASE="LuaJIT-$LUAJIT_VERSION" + +source .travis/platform.sh + +LUA_HOME_DIR=$TRAVIS_BUILD_DIR/install/lua + +LR_HOME_DIR=$TRAVIS_BUILD_DIR/install/luarocks + +mkdir $HOME/.lua + +LUAJIT="no" + +if [ "$PLATFORM" == "macosx" ]; then + if [ "$LUA" == "luajit" ]; then + LUAJIT="yes"; + fi + if [ "$LUA" == "luajit2.0" ]; then + LUAJIT="yes"; + fi + if [ "$LUA" == "luajit2.1" ]; then + LUAJIT="yes"; + fi; +elif [ "$(expr substr $LUA 1 6)" == "luajit" ]; then + LUAJIT="yes"; +fi + +mkdir -p "$LUA_HOME_DIR" + +if [ "$LUAJIT" == "yes" ]; then + + if [ "$LUA" == "luajit" ]; then + curl --location https://github.com/LuaJIT/LuaJIT/archive/v$LUAJIT_VERSION.tar.gz | tar xz; + else + git clone https://github.com/LuaJIT/LuaJIT.git $LUAJIT_BASE; + fi + + cd $LUAJIT_BASE + + if [ "$LUA" == "luajit2.1" ]; then + git checkout v2.1; + # force the INSTALL_TNAME to be luajit + perl -i -pe 's/INSTALL_TNAME=.+/INSTALL_TNAME= luajit/' Makefile + fi + + make && make install PREFIX="$LUA_HOME_DIR" + + ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/luajit + ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/lua; + +else + + if [ "$LUA" == "lua5.1" ]; then + curl http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz + cd lua-5.1.5; + elif [ "$LUA" == "lua5.2" ]; then + curl http://www.lua.org/ftp/lua-5.2.4.tar.gz | tar xz + cd lua-5.2.4; + elif [ "$LUA" == "lua5.3" ]; then + curl http://www.lua.org/ftp/lua-5.3.2.tar.gz | tar xz + cd lua-5.3.2; + fi + + # Build Lua without backwards compatibility for testing + perl -i -pe 's/-DLUA_COMPAT_(ALL|5_2)//' src/Makefile + make $PLATFORM + make INSTALL_TOP="$LUA_HOME_DIR" install; + + ln -s $LUA_HOME_DIR/bin/lua $HOME/.lua/lua + ln -s $LUA_HOME_DIR/bin/luac $HOME/.lua/luac; + +fi + +cd $TRAVIS_BUILD_DIR + +lua -v + +LUAROCKS_BASE=luarocks-$LUAROCKS + +curl --location http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz | tar xz + +cd $LUAROCKS_BASE + +if [ "$LUA" == "luajit" ]; then + ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR"; +elif [ "$LUA" == "luajit2.0" ]; then + ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR"; +elif [ "$LUA" == "luajit2.1" ]; then + ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.1" --prefix="$LR_HOME_DIR"; +else + ./configure --with-lua="$LUA_HOME_DIR" --prefix="$LR_HOME_DIR" +fi + +make build && make install + +ln -s $LR_HOME_DIR/bin/luarocks $HOME/.lua/luarocks + +cd $TRAVIS_BUILD_DIR + +luarocks --version + +rm -rf $LUAROCKS_BASE + +if [ "$LUAJIT" == "yes" ]; then + rm -rf $LUAJIT_BASE; +elif [ "$LUA" == "lua5.1" ]; then + rm -rf lua-5.1.5; +elif [ "$LUA" == "lua5.2" ]; then + rm -rf lua-5.2.4; +elif [ "$LUA" == "lua5.3" ]; then + rm -rf lua-5.3.2; +fi diff --git a/doc/README.html b/doc/README.html index 5966854..a359a53 100644 --- a/doc/README.html +++ b/doc/README.html @@ -3,12 +3,12 @@ Htmlparser LuaRock Readme - +

You are being redirected to the homepage of the - Htmlparser LuaRock. + Htmlparser LuaRock.

If you are not redirected after a few seconds, please click on the link above!

- \ No newline at end of file + diff --git a/doc/sample.html b/doc/sample.html index 3907213..19d7d26 100644 --- a/doc/sample.html +++ b/doc/sample.html @@ -62,4 +62,4 @@ - \ No newline at end of file + diff --git a/doc/sample.lua b/doc/sample.lua index 9431784..24a2471 100644 --- a/doc/sample.lua +++ b/doc/sample.lua @@ -1,4 +1,4 @@ -require("luarocks.loader") +--require("luarocks.loader") -- Omit next line in actual module clients; it's only to support development of the module itself package.path = "../src/?.lua;" .. package.path local htmlparser = require("htmlparser") diff --git a/htmlparser-0.3.2-2.rockspec b/rockspecs/htmlparser-0.3.2-2.rockspec similarity index 100% rename from htmlparser-0.3.2-2.rockspec rename to rockspecs/htmlparser-0.3.2-2.rockspec diff --git a/htmlparser-scm-0.rockspec b/rockspecs/htmlparser-scm-0.rockspec similarity index 100% rename from htmlparser-scm-0.rockspec rename to rockspecs/htmlparser-scm-0.rockspec diff --git a/tst/.luacov b/tst/.luacov new file mode 100644 index 0000000..45fa73a --- /dev/null +++ b/tst/.luacov @@ -0,0 +1,50 @@ +--- Global configuration file. Copy, customize and store in your +-- project folder as '.luacov' for project specific configuration +-- @class module +-- @name luacov.defaults +return { + + -- default filename to load for config options if not provided + -- only has effect in 'luacov.defaults.lua' + configfile = ".luacov", + + -- filename to store stats collected + statsfile = "luacov.stats.out", + + -- filename to store report + reportfile = "luacov.report.json", + + -- Run reporter on completion? (won't work for ticks) + runreport = false, + + -- Delete stats file after reporting? + deletestats = false, + + -- Patterns for files to include when reporting + -- all will be included if nothing is listed + -- (exclude overrules include, do not include + -- the .lua extension) + include = { + "/foo$", + "/foo/.+$", + }, + + -- Patterns for files to exclude when reporting + -- all will be included if nothing is listed + -- (exclude overrules include, do not include + -- the .lua extension) + exclude = { + }, + + -- configuration for luacov-coveralls reporter + coveralls = { + + -- debug = true; + + pathcorrect = { + {"^.-/share/lua/5.%d/", "src/lua/"}; + }, + + }, + +} diff --git a/tst/init.lua b/tst/init.lua index a3e1b44..7de9827 100644 --- a/tst/init.lua +++ b/tst/init.lua @@ -1,7 +1,21 @@ -- Omit next line in actual module clients; it's only to support development of the module itself package.path = "../src/?.lua;" .. package.path -local lunitx = require("lunitx") +pcall(require, "luacov") + +print("------------------------------------") +print("Lua version: " .. (jit and jit.version or _VERSION)) +print("------------------------------------") +print("") + +local HAS_RUNNER = not not lunitx +local TEST_CASE = lunitx.TEST_CASE + +local LUA_VER = _VERSION +local unpack, pow, bit32 = unpack, math.pow, bit32 + +local _ENV = TEST_CASE"some_test_case" + module("html", lunitx.testcase, package.seeall) local htmlparser = require("htmlparser")