Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Started working for scenario tests for CuberitePluginChecker #109

Merged
merged 7 commits into from
Aug 4, 2024
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
17 changes: 14 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@ jobs:

- name: Install Lua
run: |
sudo apt install lua5.1 luarocks
sudo apt install lua5.1 luarocks libsqlite3-dev
sudo luarocks install luafilesystem
sudo luarocks install lsqlite3
sudo luarocks install luasocket
sudo luarocks install luacheck
sudo luarocks install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu

- name: Set up environment
run: |
wget -O .luacheckrc 'https://ci.appveyor.com/api/projects/cuberite/cuberite/artifacts/.luacheckrc?job=Windows-x64&pr=false&branch=master'
wget -O ../InfoReg.lua https://raw.githubusercontent.com/cuberite/cuberite/master/Server/Plugins/InfoReg.lua
mkdir ~/AutoAPI
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'
unzip ~/AutoAPI.zip -d ~/AutoAPI
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'
unzip ~/ManualAPI.zip -d ~
git clone https://github.com/cuberite/CuberitePluginChecker ~/Checker
wget -O .luacheckrc --no-check-certificate 'https://ci.appveyor.com/api/projects/cuberite/cuberite/artifacts/.luacheckrc?job=Windows-x64&pr=false&branch=master'

- name: Run tests
run: |
luacheck . --codes
cd ~/Checker && lua CuberitePluginChecker.lua -p $GITHUB_WORKSPACE -a ~/AutoAPI -e ~/ManualAPI.lua -i APIImpl/All.lua -s $GITHUB_WORKSPACE/Tests/selection.lua -g
cd $GITHUB_WORKSPACE && luacheck . --codes --exclude-files Tests/*
4 changes: 4 additions & 0 deletions Classes/PlayerState.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,7 @@ end
-- Register the hooks needed:
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_DESTROYED, OnPlayerDestroyed)
cPluginManager:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage)




8 changes: 5 additions & 3 deletions Classes/ToolRegistrator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ end


-- Register the hooks needed:
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, RightClickToolsHook);
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_LEFT_CLICK, LeftClickToolsHook);
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_ANIMATION, LeftClickToolsAnimationHook);
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICK, RightClickToolsHook);
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_LEFT_CLICK, LeftClickToolsHook);
cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_ANIMATION, LeftClickToolsAnimationHook);


2 changes: 1 addition & 1 deletion Commands/Special.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end
function HandleWorldEditVersionCommand(a_Split, a_Player)
-- /we version

a_Player:SendMessage(cChatColor.LightPurple .. "This is version " .. PLUGIN:GetVersion())
a_Player:SendMessage(cChatColor.LightPurple .. "This is version " .. cPluginManager:GetCurrentPlugin():GetVersion())
return true
end

Expand Down
2 changes: 1 addition & 1 deletion Config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ g_Config = {}
-- Create an environment for the config loader where the admin can use item names directly without quotes.
local g_LoaderEnv = {}
for Key, Value in pairs(_G) do
if (Key:match("E_.*")) then
if (Key:match("^E_.*")) then
g_LoaderEnv[ItemTypeToString(Value)] = Value
end
end
Expand Down
46 changes: 46 additions & 0 deletions Tests/selection.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- selection.lua

-- These files are used with the CuberitePluginChecker script.
-- This test tests the selection and actions on the selection.
-- Usage: lua CuberitePluginChecker.lua -a AutoAPI -e ManualAPI.lua -i APIImpl/All.lua -p <WorldEditPath> -s <WorldEditPath>/selection.lua -f ^E_





scenario
{
redirectPluginFiles
{
-- Redirect the default config file.
-- 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.
["config.cfg"] = "test.config.cfg"
},
world
{
name = "world"
},
initializePlugin(),
connectPlayer
{
name = "TestUser"
},
playerCommand
{
playerName = "TestUser",
command = "//pos1",
},
playerCommand
{
playerName = "TestUser",
command = "//pos2",
},
playerCommand
{
playerName = "TestUser",
command = "//set 0",
},
}



52 changes: 52 additions & 0 deletions Tests/test.config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
WandItem = 271,
Limits =
{
ButcherRadius = -1,
MaxBrushRadius = 5,
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},
},

Defaults =
{
ButcherRadius = 20,
},

NavigationWand =
{
Item = 345,
MaxDistance = 120,
TeleportNoHit = true,
},

Scripting =
{
-- If true it logs an error when a craftscript failed
Debug = false,

-- The amount of seconds that a script may be active. Any longer and the script will be aborted.
-- If negative the time a script can run is unlimited.
MaxExecutionTime = 5,
},

Schematics =
{
OverrideExistingFiles = true,
},

Updates =
{
CheckForUpdates = false,
NumAttempts = 3,
ShowMessageWhenUpToDate = true,
DownloadNewerVersion = true,
},

Storage =
{
-- If set to true the selection of a player will be remembered once he leaves.
RememberPlayerSelection = true,

-- If WorldEdit needs to change a format in the database the database will be backuped first before changing.
-- This doesn't mean when adding or removing data the database will be backed up. Only when the used database is outdated.
BackupDatabaseWhenUpdating = true,
}
13 changes: 7 additions & 6 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


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



Expand All @@ -18,6 +18,7 @@ dofolder(cPluginManager:GetCurrentPlugin():GetLocalFolder() .. "/LibrariesExpans
g_ExcludedFolders = table.todictionary{
"craftscripts",
"LibrariesExpansion",
"Tests",
".",
"..",
}
Expand All @@ -27,7 +28,7 @@ g_ExcludedFolders = table.todictionary{


-- Load all the folders
local WorldEditPath = cPluginManager:GetCurrentPlugin():GetLocalFolder()
local WorldEditPath = cPluginManager:Get():GetCurrentPlugin():GetLocalFolder()
for _, Folder in ipairs(cFile:GetFolderContents(WorldEditPath)) do repeat
local Path = WorldEditPath .. "/" .. Folder
if (not cFile:IsFolder(Path)) then
Expand All @@ -41,13 +42,13 @@ for _, Folder in ipairs(cFile:GetFolderContents(WorldEditPath)) do repeat
dofolder(Path)
until true end

PLUGIN = nil




function Initialize(a_Plugin)
PLUGIN = a_Plugin
PLUGIN:SetName(g_PluginInfo.Name)
PLUGIN:SetVersion(g_PluginInfo.Version)
a_Plugin:SetName(g_PluginInfo.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we should make an exception in the Checker to allow this one specific case.

Copy link
Member Author

@NiLSPACE NiLSPACE Oct 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably, but I was planning on removing it here anyway. I find it to be quite ugly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception added. But yes, this kind of code is ugly, especially all-caps variable names.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should cWorld also be an exception? Technically they can be stored right? Since we do have the cRoot:GetWorld method.

a_Plugin:SetVersion(g_PluginInfo.Version)

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

Expand Down