Parcourir la Source

Added coverage support

Yonaba il y a 11 ans
Parent
commit
9603c8168c
8 fichiers modifiés avec 127 ajouts et 8 suppressions
  1. 22 8
      .travis.yml
  2. 48 0
      .travis/setup_lua.sh
  3. 2 0
      README.md
  4. 51 0
      specs/.luacov
  5. 1 0
      specs/delaunay.lua
  6. 1 0
      specs/edge.lua
  7. 1 0
      specs/point.lua
  8. 1 0
      specs/triangle.lua

+ 22 - 8
.travis.yml

@@ -1,15 +1,29 @@
 language: erlang
+
+env:
+  global:
+    - PLATFORM=linux
+    - LUAROCKS_VER=2.2.0beta1
+  matrix:
+    - LUA=lua5.1
+    - LUA=lua5.2
+    - LUA=luajit
+
 branches:
   only:
     - master
 
-env:
-  - LUA=""
-  - LUA="luajit"
-
-install:
-  - sudo apt-get install luajit
-  - sudo apt-get install luarocks
-  - sudo luarocks install telescope
+before_install:
+  - bash .travis/setup_lua.sh
+  - sudo luarocks install telescope 0.6.0 --server=http://rocks.moonscript.org
+  - sudo luarocks install luacov-coveralls --server=http://rocks.moonscript.org/dev
 
 script: "tsc -f specs/*"
+  
+after_success:
+  - luacov-coveralls -c specs/.luacov
+
+notifications:
+  email:
+    on_success: change
+    on_failure: always

+ 48 - 0
.travis/setup_lua.sh

@@ -0,0 +1,48 @@
+#! /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".
+# PLATFORM must be "linux" or "macosx".
+# Original written by Alexey Melnichuk <https://github.com/moteus>
+
+if [ "$LUA" == "luajit" ]; then
+  curl http://luajit.org/download/LuaJIT-2.0.2.tar.gz | tar xz
+  cd LuaJIT-2.0.2
+  make && sudo make install
+  sudo ln -s /usr/local/bin/luajit /usr/local/bin/lua
+  cd $TRAVIS_BUILD_DIR;
+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.3.tar.gz | tar xz
+    cd lua-5.2.3;
+  fi
+  sudo make $PLATFORM install
+  cd $TRAVIS_BUILD_DIR;
+fi
+
+LUAROCKS_BASE=luarocks-$LUAROCKS_VER
+curl http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz | tar xz
+cd $LUAROCKS_BASE;
+
+if [ "$LUA" == "luajit" ]; then
+  ./configure --lua-suffix=jit --with-lua-include=/usr/local/include/luajit-2.0;
+else
+  ./configure;
+fi
+
+make build && sudo make install
+
+cd $TRAVIS_BUILD_DIR
+
+rm -rf $LUAROCKS_BASE
+
+if [ "$LUA" == "luajit" ]; then
+  rm -rf LuaJIT-2.0.2;
+elif [ "$LUA" == "lua5.1" ]; then
+  rm -rf lua-5.1.5;
+elif [ "$LUA" == "lua5.2" ]; then
+  rm -rf lua-5.2.3;
+fi

+ 2 - 0
README.md

@@ -2,6 +2,8 @@ Delaunay
 =====
 
 [![Build Status](https://travis-ci.org/Yonaba/delaunay.png)](https://travis-ci.org/Yonaba/delaunay)
+[![Coverage Status](https://coveralls.io/repos/Yonaba/delaunay/badge.png?branch=master)](https://coveralls.io/r/Yonaba/delaunay?branch=master)
+[![License](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)
 
 *delaunay* is a Lua module for [delaunay triangulation](http://en.wikipedia.org/wiki/Delaunay_triangulation) of a convex polygon.
 

+ 51 - 0
specs/.luacov

@@ -0,0 +1,51 @@
+--- 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"] = {
+  },
+
+  -- 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"] = {
+    'tsc',
+    'telescope',
+    'loader',
+  },
+
+  -- configuration for luacov-coveralls reporter
+  ["coveralls"] = {
+
+    -- ["debug"] = true;
+
+    ["pathcorrect"] = {
+      {"/usr/local/share/lua/5.[12]", "src/lua"};
+    },
+
+  },
+
+}

+ 1 - 0
specs/delaunay.lua

@@ -1,3 +1,4 @@
+require 'luacov'
 local Delaunay       = (require "delaunay")
 local Point          = Delaunay.Point
 local Triangle       = Delaunay.Triangle

+ 1 - 0
specs/edge.lua

@@ -1,3 +1,4 @@
+require 'luacov'
 local Point = (require "delaunay").Point
 local Edge  = (require "delaunay").Edge
 

+ 1 - 0
specs/point.lua

@@ -1,3 +1,4 @@
+require 'luacov'
 local Point = (require "delaunay").Point
 
 context("Point", function()

+ 1 - 0
specs/triangle.lua

@@ -1,3 +1,4 @@
+require 'luacov'
 local make_assertion = (require "telescope").make_assertion
 local Point          = (require "delaunay").Point
 local Edge           = (require "delaunay").Edge