Skip to content

jun-labs/lua-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


Lua Image

Learning Lua

Release Release
Release Release Release



Install

Before learning Lua, please make sure to correctly install the following modules. (For Mac with AMD chip)

$ brew install lua                 # Lua
$ brew install luajit              # LuaJit
$ brew install luarocks            # LuaRocks
$ luarocks install luaunit         # LuaUnit
$ luarocks install busted          # Busted
$ luarocks install redis-lua       # Redis Lua



If you want to know information about a package, you can run the following command.

$ luarocks show luaunit
LuaUnit 3.4-1 - A unit testing framework for Lua
...
Installed in:   /opt/homebrew

Modules:
        luaunit (/opt/homebrew/share/lua/5.4/luaunit.lua)
export LUA_PATH="/opt/homebrew/share/lua/5.4/?.lua;;"





Run

To run the Lua script, navigate to the folder where your file is located and execute the following command.

$ pwd                                   # 1. Current directory
/lua-script/basic

$ ls                                    # 2. Check directories
chunk    string_library

$ cd string_library                     # 3. Navigate to target directory

$ lua main.lua                          # 4. Execute lua



To run the tests, navigate to the folder where your test file is located and execute the following command.

$ pwd                                   # 1. Current directory
/lua-script/basic

$ ls                                    # 2. Check directories
chunk    string_library

$ cd string_library                     # 3. Navigate to target directory

$ lua test_luaunit.lua                  # 4. Execute test(luaunit)
......
Ran 6 tests in 0.000 seconds, 
6 successes, 0 failures OK
$ pwd                                   # 1. Current directory
/lua-script/basic

$ ls                                    # 2. Check directories
chunk    string_library

$ cd string_library                     # 3. Navigate to target directory

$ busted test_busted.lua                # 4. Execute test(busted)
●●●●●●●●●●●
11 successes / 0 failures / 0 errors / 0 pending : 0.005014 seconds



If your test uses Redis, please execute the following Docker Compose command before running the program, and ensure that the required port 6379 is not already in use to avoid any conflicts.

version: "3.8"
services:
  redis:
    image: redis:latest
    ports:
      - "6379:6379"
$ docker-compose up -d