Parcourir la source

fix lua env and use busted test lib

Nick Hildebrant il y a 10 ans
Parent
commit
bd0a586e28

+ 1 - 1
.travis/install_rocks.sh

@@ -5,7 +5,7 @@ source .travis/lua_env.sh
 
 # add any rocks required for ci_tests to this list
 # lua-curl depends on a libcurl development package (i.e. libcurl4-openssl-dev)
-ROCKS=(lunitx lua-curl)
+ROCKS=(lua-curl busted)
 
 for ROCK in ${ROCKS[*]}
 do

+ 2 - 5
.travis/lua_env.sh

@@ -1,8 +1,5 @@
 #!/bin/bash
 
-export LUAROCKS=.travis/lua/bin/luarocks
-export PATH=$($LUAROCKS path --bin):$PATH
-export LUA_PATH=$($LUAROCKS path --lr-path)
-export LUA_CPATH=$($LUAROCKS path --lr-cpath)
-
+LUAROCKS=.travis/lua/bin/luarocks
+eval $($LUAROCKS path --bin)
 

+ 1 - 14
.travis/run_ci_tests.sh

@@ -2,19 +2,6 @@
 set -ev
 
 source .travis/lua_env.sh
-
-CI_TEST_DIRS=$(ls -d test/ci_test*)
-
-for DIR in $CI_TEST_DIRS
-do
-  echo starting tests in $DIR
-  SCRIPTS=$(ls -f $DIR/*test*.lua)
-  for SCRIPT in $SCRIPTS
-  do
-    echo starting test script $SCRIPT
-    lunit.sh $SCRIPT
-    #lua $SCRIPT
-  done
-done
+busted -o TAP test/ci_tests/
 
 

+ 0 - 8
test/ci_test_basic/test_test.lua

@@ -1,8 +0,0 @@
-local lunit = require('lunitx')
-local cURL = require("cURL")
-
-_ENV = lunit.module('enhanced','seeall')
-
-function test_success() 
-  assert_true (true, 'tests work')
-end

+ 0 - 10
test/ci_test_basic/test_test2.lua

@@ -1,10 +0,0 @@
-local lunit = require('lunitx')
-local cURL = require("cURL")
-
-_ENV = lunit.module('simple','seeall')
-
-function test_success_again() 
-  assert_true (true, 'more tests work')
-end
-
-

+ 7 - 0
test/ci_tests/01_basic/basic_spec.lua

@@ -0,0 +1,7 @@
+require("cURL")
+
+describe("civetweb basic", function()
+ it("should serve a simple get request", function()
+   assert.is(true)
+ end)
+end)

+ 27 - 0
test/ci_tests/test_spec.lua

@@ -0,0 +1,27 @@
+describe("Busted unit testing framework", function()
+  describe("should be awesome", function()
+    it("should be easy to use", function()
+      assert.truthy("Yup.")
+    end)
+
+    it("should have lots of features", function()
+      -- deep check comparisons!
+      assert.are.same({ table = "great"}, { table = "great" })
+
+      -- or check by reference!
+      assert.are_not.equal({ table = "great"}, { table = "great"})
+
+      assert.truthy("this is a string") -- truthy: not false or nil
+
+      assert.True(1 == 1)
+      assert.is_true(1 == 1)
+
+      assert.falsy(nil)
+      assert.has_error(function() error("Wat") end, "Wat")
+    end)
+
+    it("should provide some shortcuts to common functions", function()
+      assert.are.unique({{ thing = 1 }, { thing = 2 }, { thing = 3 }})
+    end)
+  end)
+end)