Skip to content

Commit 8d054c9

Browse files
committed
test: ✨ adding Testing (big WIP)
1 parent d2ab22f commit 8d054c9

File tree

8 files changed

+110
-0
lines changed

8 files changed

+110
-0
lines changed

.github/workflows/test.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Busted
2+
3+
4+
on: [push, pull_request]
5+
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: checkout
13+
uses: actions/checkout@v2
14+
with:
15+
submodules: true
16+
17+
- name: get lua
18+
uses: leafo/gh-actions-lua@v10
19+
with:
20+
luaVersion: "5.1"
21+
22+
- name: get luarocks
23+
uses: leafo/gh-actions-luarocks@v4
24+
with:
25+
luaVersion: "5.1"
26+
27+
- name: get busted and luasocket
28+
run: |
29+
luarocks install busted
30+
luarocks install luasocket
31+
luarocks install luasec
32+
33+
- name: Git Submodule Update
34+
run: |
35+
git pull --recurse-submodules
36+
git submodule update --init --remote --recursive
37+
38+
- name: test
39+
run: |
40+
busted tests

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "turtleEmulator-lib"]
2+
path = turtleEmulator-lib
3+
url = https://github.com/mc-cc-scripts/turtleEmulator-lib
4+
[submodule "libs/miningClient-lib"]
5+
path = libs/miningClient-lib
6+
url = https://github.com/mc-cc-scripts/miningClient-lib.git

cc.pretty.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
return print

ccPackage.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
local spath =
2+
debug.getinfo(1,'S').source:sub(2):gsub("/+", "/"):gsub("[^/]*$","")
3+
package.path = spath.."?.lua;"
4+
..package.path
5+
require(spath.."turtleEmulator-lib/ccPackage")

libs/miningClient-lib

Submodule miningClient-lib added at 3f95f83

scm.lua

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--- This simulates the files requried from the SCM module
2+
local scm = {}
3+
4+
local settingsManager = {settings = {}}
5+
6+
local require2 = require
7+
8+
local function required(name)
9+
print("Required: " .. name)
10+
if (name == "settingsManager") then
11+
return settingsManager
12+
end
13+
if (name == "cc.pretty") then
14+
return print
15+
end
16+
return require2(name)
17+
end
18+
19+
20+
_G.require = required
21+
22+
23+
function settingsManager:setget(name, value, default)
24+
if value ~= nil then
25+
self.settings[name] = value
26+
end
27+
value = self.settings[name]
28+
return value or default
29+
end
30+
31+
function scm:load(name)
32+
return required(name)
33+
end
34+
35+
return scm

tests/test_spec.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
local spath =
3+
debug.getinfo(1,'S').source:sub(2):gsub("/+", "/"):gsub("[^/]*$",""):gsub("/tests", ""):gsub("tests","")
4+
if spath == "" then
5+
spath = "./"
6+
end
7+
require(spath.."ccPackage")
8+
--#region Globals
9+
10+
---@type TurtleEmulator
11+
local turtleEmulator = require("turtleEmulator")
12+
_G.turtle = turtleEmulator:createTurtle()
13+
-- local miner = require("miningClientSmall")
14+
15+
--#endregion
16+
17+
describe("test_spec", function()
18+
it("should be able to run tests", function()
19+
assert.is_true(true)
20+
end)
21+
end)

turtleEmulator-lib

Submodule turtleEmulator-lib added at 8d3331b

0 commit comments

Comments
 (0)