Skip to content

Commit

Permalink
Convert to luatest. (#33)
Browse files Browse the repository at this point in the history
* Add luatest and remove busted.

* Convert a test.

* Add more tests.

* Rename src to lua.

* Add more tests.

* Set a coverage configuration.

* Add more tests.

I need to figure out why tests with stubs are breaking. There's
something going on with reseting. Busted probably avoided this problem
by reloading the world.

* Convert more tests.

* Convert remaining tests.

* Fix broken server tests.

* Add coverage measurement.
  • Loading branch information
mblayman committed Jul 16, 2023
1 parent 9d5b974 commit 242310f
Show file tree
Hide file tree
Showing 67 changed files with 1,317 additions and 1,207 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH_add .luarocks/bin
PATH_add bin
# This is not optimal, but assume 5.4 for now.
export LUA_PATH='src/?.lua;src/?/init.lua;.luarocks/share/lua/5.4/?.lua;.luarocks/share/lua/5.4/?/init.lua;;'
export LUA_PATH='lua/?.lua;lua/?/init.lua;.luarocks/share/lua/5.4/?.lua;.luarocks/share/lua/5.4/?/init.lua;;'
export LUA_CPATH='.luarocks/lib/lua/5.4/?.so;;'

dotenv
6 changes: 2 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ jobs:
run: make build

- name: style
run: "find src tests -name '*.lua' -print0 | xargs -0 lua-format --check"
run: "find lua tests -name '*.lua' -print0 | xargs -0 lua-format --check"

- name: test
run: |
make coverage
cat luacov.report.out | grep Total | grep 100.00% > /dev/null
run: luatest --cov lua
env:
ATLAS_CONFIG: tests.config
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ venv/

# Environment
.env

lcov.info
html
22 changes: 7 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,11 @@

lr = luarocks --tree .luarocks

coverage: clean t
luacov src
@tail -n+$$(cat luacov.report.out | grep -m 1 -n 'Summary' | cut -d: -f 1) luacov.report.out | grep -v '100.00'

clean:
@rm -f luacov.*

# Busted has no expected failure feature so let's fake it for now.
# This isn't great because it hides tests instead of skipping them
# and showing that they were skipped.
t:
busted --exclude-tags xfail

tap:
busted --exclude-tags xfail -o tap
@rm -rf lcov.info html

build:
$(lr) install busted
$(lr) install luatest
$(lr) install LuaCov
which lua-format || $(lr) install --server https://luarocks.org/dev luaformatter
$(lr) make
Expand All @@ -29,3 +16,8 @@ atlas:

bootstrap:
$(lr) install luacheck

coverage: clean
luatest --cov lua
genhtml -o html lcov.info
open html/index.html
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ This order sounds appealing to me.

## Tools

* Busted for tests. `luarocks install busted`
* LuaCov for coverage. `luarocks install LuaCov`
* luatest for tests. `luarocks install luatest`
* LuaCheck for lint. `luarocks install LuaCheck`
* Here is the pre-commit PR for Lua support:
https://github.com/pre-commit/pre-commit/pull/2158
Expand Down
1 change: 0 additions & 1 deletion _vimrc_local.vim

This file was deleted.

2 changes: 1 addition & 1 deletion bin/t
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
make t
luatest $@
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local assert = require "luassert.assert"
local assert = require "luassert"

local assertions = {}

Expand Down
2 changes: 1 addition & 1 deletion src/atlas/test/loop.lua → lua/atlas/test/loop.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local assert = require "luassert.assert"
local assert = require "luassert"
local luv = require "luv"

local loop = {}
Expand Down
File renamed without changes.
78 changes: 0 additions & 78 deletions tests/application_test.lua

This file was deleted.

31 changes: 0 additions & 31 deletions tests/configuration_test.lua

This file was deleted.

19 changes: 0 additions & 19 deletions tests/fs_test.lua

This file was deleted.

85 changes: 0 additions & 85 deletions tests/main_test.lua

This file was deleted.

22 changes: 0 additions & 22 deletions tests/request_test.lua

This file was deleted.

61 changes: 0 additions & 61 deletions tests/response_test.lua

This file was deleted.

0 comments on commit 242310f

Please sign in to comment.