Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ jobs:
luarocks install luasocket
luarocks install luasec

- name: fetch dependencies
run: |
chmod +x ./fetch-deps.sh
./fetch-deps.sh

- name: test
run: |
busted vector
# further tests here
busted vector
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/config
/.vscode
/computer
/computer
/libs/eventCallStack.lua
/libs/helperFunctions.lua
/libs/ccClass.lua
7 changes: 0 additions & 7 deletions .gitmodules

This file was deleted.

50 changes: 21 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
# Install

in your testfile(s), just add these few lines to automaticly install the test-suites in the /suits folder of your current path.

```lua
-- Check if relvant suit is found(only relevant when testing locally)
-- otherwise run the installer
if not pcall(function () io.open("./suits/vector/vector.lua", "r"):close() end) then
print("Downloading TestSuite-lib")
local http = require("socket.http")
local url = "https://raw.githubusercontent.com/mc-cc-scripts/TestSuite-lib/master/installSuit.lua" -- URL of the installer
local body, statusCode = http.request(url)
if statusCode == 200 then
local loader
if _VERSION == "Lua 5.1" then
loader = loadstring
else
loader = load
end
local installScript = loader(body)().install()
else
error("Failed to download TestSuite-lib: " .. tostring(statusCode))
end
end
```

## Planned features
Specify the install location for the suit
update files already present / add missing files
# TestSuite

This emulates the basic ccTweaked functions missing in basic-lua.

- fs
- http
- vector-functions

Additionally it emulates our **[scm](https://github.com/mc-cc-scripts/script-manager)** script and includes the **[json](https://gist.github.com/tylerneylon/59f4bcf316be525b30ab)** handler - which makes tests a lot easier.

# Usage

As this repo emulates many functionalites given by ccTweaked, you might want to test you code **outside** of Minecraft, maybe even automated. To achieve that, you need to download the scripts listed above and save them in your testingenv.

Ideally you want to add those scripts to your .gitignore and only add them locally / for github actions.

### Example

For how to import the scipts, an example is already used by this repo for some of its dependancies:

[fetch-deps.sh](fetch-deps.sh)
52 changes: 0 additions & 52 deletions ccClass/ccClass.lua

This file was deleted.

11 changes: 0 additions & 11 deletions ccPackage.lua

This file was deleted.

1 change: 0 additions & 1 deletion eventCallStack-lib
Submodule eventCallStack-lib deleted from fa366a
41 changes: 41 additions & 0 deletions fetch-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# ---- Whats happening ---- #

# This fetches the dependencies listed in the "libs" variable and saves them in the targetFolder



set -e

libs=(
"helperFunctions-lib"
"eventCallStack-lib"
"ccClass-lib"
)

# Basic setup variables
repo="mc-cc-scripts"
branch="master"
targetFolderName=libs


# fetch files.txt and save each file into the targetFolder
fetch() {

files_txt=$(curl -fsSL "https://raw.githubusercontent.com/$repo/$1/$branch/files.txt")
if [ -z "$files_txt" ]; then
echo "Could not load files.txt for $1"
exit 1
fi
while IFS= read -r FILE; do
rm -f $targetFolderName/$1.lua # rm existing file
curl -s "https://raw.githubusercontent.com/$repo/$1/$branch/$FILE" -o "$targetFolderName/$FILE"
done < <(echo "$files_txt")
}

mkdir -p $targetFolderName

for i in "${libs[@]}"; do
fetch "$i"
done
11 changes: 5 additions & 6 deletions files.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
vector/vector.lua
ccClass/ccClass.lua
http/http.lua
fs/fs.lua
helperFunctions/helperFunctions.lua
json/json.lua
vector.lua
http.lua
fs.lua
json.lua
scm.lua
File renamed without changes.
1 change: 0 additions & 1 deletion helperFunctions
Submodule helperFunctions deleted from 2e6bcf
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions vector/vector.lua → vector.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local cPath = debug.getinfo(1).source:match("@?(.*/)")
cPath = string.gsub(cPath, "/vector/", "/ccClass/ccClass")
---@type function
local class = require(cPath)
local class = require("ccClass")

---@class Vector
---@field x number
Expand Down
8 changes: 1 addition & 7 deletions vector/tests/test_spec.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@

local spath =
debug.getinfo(1,'S').source:sub(2):gsub("/+", "/"):gsub("[^/]*$",""):gsub("/vector/tests", ""):gsub("vector/tests", "")
if spath == "" then
spath = "./"
end
require(spath .. "ccPackage")
package.path = package.path.. ";libs/?.lua"
local vector = require("vector")

describe('Vector', function()
Expand Down
Loading