Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
Рефакторинг после переименования репозитория:
- мелкие правки
- оформил тесты стандартным образом
- добавил CI
  • Loading branch information
a1div0 committed Apr 15, 2023
1 parent 2eb009f commit fa7ddde
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 71 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: main

on:
push:
branches:
- main
pull_request:

jobs:
all:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Tarantool
run: |
curl -L https://tarantool.io/eHAFdDf/release/2/installer.sh | bash
sudo apt-get -y install tarantool
- name: Run app tests
run: make test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea/
.idea/
.rocks/
luacov.*.out
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SHELL := /bin/bash

.rocks:
tarantoolctl rocks install luacheck 0.26.0 \
&& tarantoolctl rocks install luatest 0.5.7 \
&& tarantoolctl rocks install luacov 0.13.0 \
&& tarantoolctl rocks install luacov-reporters 0.1.0

.PHONY: test
test: .rocks
.rocks/bin/luacheck lua-debug-helper --max-line-length 200 \
&& .rocks/bin/luatest -v --coverage \
&& .rocks/bin/luacov -r summary && cat luacov.report.out
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
width="250" align="right">
</a>

# ide-debug
# lua-debug-helper
Module for IDE Lua debug. This is an add-on for
[EmmyLua Debugger](https://github.com/EmmyLua/EmmyLuaDebugger)

## Installation
You can:
* clone the repository:
``` shell
git clone https://github.com/a1div0/ide-debug.git
git clone https://github.com/a1div0/lua-debug-helper.git
```
* install the `ide-debug` module using `tarantoolctl`:
* install the `lua-debug-helper` module using `tarantoolctl`:
```shell
tarantoolctl rocks install https://raw.githubusercontent.com/a1div0/ide-debug/main/ide-debug-1.0.1-1.rockspec
tarantoolctl rocks install https://raw.githubusercontent.com/a1div0/lua-debug-helper/main/lua-debug-helper-1.0.2-1.rockspec
```

## Usage
Expand All @@ -27,14 +27,16 @@ tarantoolctl rocks install https://raw.githubusercontent.com/a1div0/ide-debug/ma
### Variant 1
Not invasive (the order of the arguments is important):
```shell
tarantool -l ide_debug example.lua --dbg_port=9966
tarantool -l lua-debug-helper example.lua --dbg_port=9966
```

### Variant 2
Invasive:
1. In your project add this code:
```lua
require('ide-debug').run(9966)
require('lua-debug-helper').run(9999)
-- or
require('lua-debug-helper').run() -- default port is 9966
```

2. Run, example:
Expand Down
25 changes: 0 additions & 25 deletions ide-debug-1.0.1-1.rockspec

This file was deleted.

19 changes: 0 additions & 19 deletions ide-debug/init.lua

This file was deleted.

14 changes: 7 additions & 7 deletions ide-debug-1.0.0-1.rockspec → lua-debug-helper-1.0.2-1.rockspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package = 'ide-debug'
version = '1.0.0-1'
package = 'lua-debug-helper'
version = '1.0.2-1'
source = {
url = 'git+https://github.com/a1div0/ide-debug.git',
url = 'git+https://github.com/a1div0/lua-debug-helper.git',
branch = 'main',
tag = '1.0.0',
tag = '1.0.2',
}
description = {
summary = "Module for IDE Lua debug based EmmyLua Debugger",
homepage = 'https://github.com/a1div0/ide-debug',
homepage = 'https://github.com/a1div0/lua-debug-helper',
maintainer = "Alexander Klenov <[email protected]>",
license = 'None',
}
Expand All @@ -17,9 +17,9 @@ dependencies = {
build = {
type = 'builtin',
modules = {
['ide-debug'] = 'ide-debug/init.lua',
['lua-debug-helper'] = 'lua-debug-helper/init.lua',
},
install = {
lib = {'ide-debug/emmy_core.so'},
lib = {'lua-debug-helper/emmy_core.so'},
}
}
10 changes: 5 additions & 5 deletions ide-debug-scm-1.rockspec → lua-debug-helper-scm-1.rockspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package = 'ide-debug'
package = 'lua-debug-helper'
version = 'scm-1'
source = {
url = 'git+https://github.com/a1div0/ide-debug.git',
url = 'git+https://github.com/a1div0/lua-debug-helper.git',
branch = 'main',
}
description = {
summary = "Module for IDE Lua debug based EmmyLua Debugger",
homepage = 'https://github.com/a1div0/ide-debug',
homepage = 'https://github.com/a1div0/lua-debug-helper',
maintainer = "Alexander Klenov <[email protected]>",
license = 'None',
}
Expand All @@ -16,9 +16,9 @@ dependencies = {
build = {
type = 'builtin',
modules = {
['ide-debug'] = 'ide-debug/init.lua',
['lua-debug-helper'] = 'lua-debug-helper/init.lua',
},
install = {
lib = {'ide-debug/emmy_core.so'},
lib = {'lua-debug-helper/emmy_core.so'},
}
}
File renamed without changes.
24 changes: 24 additions & 0 deletions lua-debug-helper/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local lua_debug_helper = {}

lua_debug_helper.run = function(port)
local dbg = require('emmy_core')
dbg.tcpListen('localhost', port or 9966)
dbg.waitIDE()
end

lua_debug_helper.enable_debugger = function(port)
lua_debug_helper.run(port)
end

lua_debug_helper.arg_init = function(prog_args)
for _, arg_i in ipairs(prog_args) do
local dbg_port = arg_i:match('^--dbg_port=(%d+)$')
if dbg_port ~= nil then
lua_debug_helper.run(tonumber(dbg_port))
end
end
end

lua_debug_helper.arg_init(arg)

return lua_debug_helper
8 changes: 0 additions & 8 deletions test/test.lua

This file was deleted.

24 changes: 24 additions & 0 deletions test/unit/unit_test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local t = require('luatest')
local g = t.group('simplest')

local lua_debug_helper = require('lua-debug-helper')

local launched_port = 0
lua_debug_helper.run = function(port)
launched_port = port
end

g.test_run = function()
lua_debug_helper.run(1111)
t.assert_equals(launched_port, 1111)
end

g.test_enable_debugger = function()
lua_debug_helper.enable_debugger(2222)
t.assert_equals(launched_port, 2222)
end

g.test_arg_init = function()
lua_debug_helper.arg_init{'--dbg_port=3333'}
t.assert_equals(launched_port, 3333)
end

0 comments on commit fa7ddde

Please sign in to comment.