Skip to content

Commit 72ab743

Browse files
authored
Merge pull request #109 from cuberite/Tests
Started working for scenario tests for CuberitePluginChecker
2 parents f72e30a + b2f18a3 commit 72ab743

File tree

8 files changed

+130
-14
lines changed

8 files changed

+130
-14
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,25 @@ jobs:
1111

1212
- name: Install Lua
1313
run: |
14-
sudo apt install lua5.1 luarocks
14+
sudo apt install lua5.1 luarocks libsqlite3-dev
1515
sudo luarocks install luafilesystem
16+
sudo luarocks install lsqlite3
17+
sudo luarocks install luasocket
1618
sudo luarocks install luacheck
19+
sudo luarocks install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu
1720
1821
- name: Set up environment
1922
run: |
20-
wget -O .luacheckrc 'https://ci.appveyor.com/api/projects/cuberite/cuberite/artifacts/.luacheckrc?job=Windows-x64&pr=false&branch=master'
23+
wget -O ../InfoReg.lua https://raw.githubusercontent.com/cuberite/cuberite/master/Server/Plugins/InfoReg.lua
24+
mkdir ~/AutoAPI
25+
wget -O ~/AutoAPI.zip --no-check-certificate 'https://ci.appveyor.com/api/projects/cuberite/cuberite/artifacts/AutoAPI.zip?job=Windows-x64&pr=false&branch=master'
26+
unzip ~/AutoAPI.zip -d ~/AutoAPI
27+
wget -O ~/ManualAPI.zip --no-check-certificate 'https://ci.appveyor.com/api/projects/cuberite/cuberite/artifacts/ManualAPI.zip?job=Windows-x64&pr=false&branch=master'
28+
unzip ~/ManualAPI.zip -d ~
29+
git clone https://github.com/cuberite/CuberitePluginChecker ~/Checker
30+
wget -O .luacheckrc --no-check-certificate 'https://ci.appveyor.com/api/projects/cuberite/cuberite/artifacts/.luacheckrc?job=Windows-x64&pr=false&branch=master'
2131
2232
- name: Run tests
2333
run: |
24-
luacheck . --codes
34+
cd ~/Checker && lua CuberitePluginChecker.lua -p $GITHUB_WORKSPACE -a ~/AutoAPI -e ~/ManualAPI.lua -i APIImpl/All.lua -s $GITHUB_WORKSPACE/Tests/selection.lua -g
35+
cd $GITHUB_WORKSPACE && luacheck . --codes --exclude-files Tests/*

Classes/PlayerState.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,7 @@ end
212212
-- Register the hooks needed:
213213
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_DESTROYED, OnPlayerDestroyed)
214214
cPluginManager:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage)
215+
216+
217+
218+

Classes/ToolRegistrator.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ end
326326

327327

328328
-- Register the hooks needed:
329-
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, RightClickToolsHook);
330-
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_LEFT_CLICK, LeftClickToolsHook);
331-
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_ANIMATION, LeftClickToolsAnimationHook);
329+
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, RightClickToolsHook);
330+
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_LEFT_CLICK, LeftClickToolsHook);
331+
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_ANIMATION, LeftClickToolsAnimationHook);
332+
333+

Commands/Special.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ end
2525
function HandleWorldEditVersionCommand(a_Split, a_Player)
2626
-- /we version
2727

28-
a_Player:SendMessage(cChatColor.LightPurple .. "This is version " .. PLUGIN:GetVersion())
28+
a_Player:SendMessage(cChatColor.LightPurple .. "This is version " .. cPluginManager:GetCurrentPlugin():GetVersion())
2929
return true
3030
end
3131

Config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ g_Config = {}
1616
-- Create an environment for the config loader where the admin can use item names directly without quotes.
1717
local g_LoaderEnv = {}
1818
for Key, Value in pairs(_G) do
19-
if (Key:match("E_.*")) then
19+
if (Key:match("^E_.*")) then
2020
g_LoaderEnv[ItemTypeToString(Value)] = Value
2121
end
2222
end

Tests/selection.lua

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
-- selection.lua
2+
3+
-- These files are used with the CuberitePluginChecker script.
4+
-- This test tests the selection and actions on the selection.
5+
-- Usage: lua CuberitePluginChecker.lua -a AutoAPI -e ManualAPI.lua -i APIImpl/All.lua -p <WorldEditPath> -s <WorldEditPath>/selection.lua -f ^E_
6+
7+
8+
9+
10+
11+
scenario
12+
{
13+
redirectPluginFiles
14+
{
15+
-- Redirect the default config file.
16+
-- This disables the update check and also works around a bug in the simulator which causes block/item enums to not be in the global environment.
17+
["config.cfg"] = "test.config.cfg"
18+
},
19+
world
20+
{
21+
name = "world"
22+
},
23+
initializePlugin(),
24+
connectPlayer
25+
{
26+
name = "TestUser"
27+
},
28+
playerCommand
29+
{
30+
playerName = "TestUser",
31+
command = "//pos1",
32+
},
33+
playerCommand
34+
{
35+
playerName = "TestUser",
36+
command = "//pos2",
37+
},
38+
playerCommand
39+
{
40+
playerName = "TestUser",
41+
command = "//set 0",
42+
},
43+
}
44+
45+
46+

Tests/test.config.cfg

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
WandItem = 271,
2+
Limits =
3+
{
4+
ButcherRadius = -1,
5+
MaxBrushRadius = 5,
6+
DisallowedBlocks = {6, 7, 14, 15, 16, 26, 27, 28, 29, 39, 31, 32, 33, 34, 36, 37, 38, 39, 40, 46, 50, 51, 56, 59, 69, 73, 74, 75, 76, 77, 81, 83},
7+
},
8+
9+
Defaults =
10+
{
11+
ButcherRadius = 20,
12+
},
13+
14+
NavigationWand =
15+
{
16+
Item = 345,
17+
MaxDistance = 120,
18+
TeleportNoHit = true,
19+
},
20+
21+
Scripting =
22+
{
23+
-- If true it logs an error when a craftscript failed
24+
Debug = false,
25+
26+
-- The amount of seconds that a script may be active. Any longer and the script will be aborted.
27+
-- If negative the time a script can run is unlimited.
28+
MaxExecutionTime = 5,
29+
},
30+
31+
Schematics =
32+
{
33+
OverrideExistingFiles = true,
34+
},
35+
36+
Updates =
37+
{
38+
CheckForUpdates = false,
39+
NumAttempts = 3,
40+
ShowMessageWhenUpToDate = true,
41+
DownloadNewerVersion = true,
42+
},
43+
44+
Storage =
45+
{
46+
-- If set to true the selection of a player will be remembered once he leaves.
47+
RememberPlayerSelection = true,
48+
49+
-- If WorldEdit needs to change a format in the database the database will be backuped first before changing.
50+
-- This doesn't mean when adding or removing data the database will be backed up. Only when the used database is outdated.
51+
BackupDatabaseWhenUpdating = true,
52+
}

main.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
-- First of all load all the library expansions
11-
dofolder(cPluginManager:GetCurrentPlugin():GetLocalFolder() .. "/LibrariesExpansion")
11+
dofolder(cPluginManager:Get():GetCurrentPlugin():GetLocalFolder() .. "/LibrariesExpansion")
1212

1313

1414

@@ -18,6 +18,7 @@ dofolder(cPluginManager:GetCurrentPlugin():GetLocalFolder() .. "/LibrariesExpans
1818
g_ExcludedFolders = table.todictionary{
1919
"craftscripts",
2020
"LibrariesExpansion",
21+
"Tests",
2122
".",
2223
"..",
2324
}
@@ -27,7 +28,7 @@ g_ExcludedFolders = table.todictionary{
2728

2829

2930
-- Load all the folders
30-
local WorldEditPath = cPluginManager:GetCurrentPlugin():GetLocalFolder()
31+
local WorldEditPath = cPluginManager:Get():GetCurrentPlugin():GetLocalFolder()
3132
for _, Folder in ipairs(cFile:GetFolderContents(WorldEditPath)) do repeat
3233
local Path = WorldEditPath .. "/" .. Folder
3334
if (not cFile:IsFolder(Path)) then
@@ -41,13 +42,13 @@ for _, Folder in ipairs(cFile:GetFolderContents(WorldEditPath)) do repeat
4142
dofolder(Path)
4243
until true end
4344

44-
PLUGIN = nil
45+
46+
4547

4648

4749
function Initialize(a_Plugin)
48-
PLUGIN = a_Plugin
49-
PLUGIN:SetName(g_PluginInfo.Name)
50-
PLUGIN:SetVersion(g_PluginInfo.Version)
50+
a_Plugin:SetName(g_PluginInfo.Name)
51+
a_Plugin:SetVersion(g_PluginInfo.Version)
5152

5253
InitializeConfiguration(a_Plugin:GetLocalFolder() .. "/config.cfg")
5354

0 commit comments

Comments
 (0)