Commit 0ba4562f authored by Petter Reinholdtsen's avatar Petter Reinholdtsen

Added 1000-busted-test.patch and use it to run simple test of lua code.

parent a3f973de
......@@ -4,6 +4,7 @@ Priority: optional
Maintainer: Debian Games Team <pkg-games-devel@lists.alioth.debian.org>
Uploaders: Petter Reinholdtsen <pere@debian.org>
Build-Depends: debhelper (>= 10)
, lua-busted
Standards-Version: 4.2.0
Homepage: https://github.com/sprintingkiwi/pycraft_mod
Vcs-Git: https://salsa.debian.org/games-team/unfinished/minetest-mod-pycraft.git
......
Description: Add simple unit test for lua module.
Author: Petter Reinholdtsen <pere@debian.org>
are templates for supplementary fields that you might want to add:
Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2018-12-02
--- /dev/null
+++ minetest-mod-pycraft-0.20+git20180331.0376a0a/tests/pycraft_spec.lua
@@ -0,0 +1,73 @@
+-- unit tests using busted
+-- based on https://rubenwardy.com/minetest_modding_book/en/quality/unit_testing.html
+
+-- Look for required things in
+package.path = "../?.lua;" .. package.path
+
+_G.minetest = {}
+minetest.registered_nodes = {}
+
+-- Define the mock functions
+function minetest.get_current_modname()
+ return "something"
+end
+function minetest.get_modpath()
+ return "some/path"
+end
+function minetest.register_globalstep(f)
+ minetest.globalstep = f
+end
+function minetest.register_on_shutdown(f)
+end
+function minetest.register_on_joinplayer(f)
+end
+function minetest.register_on_leaveplayer(f)
+end
+function minetest.register_on_punchnode(f)
+end
+function minetest.register_chatcommand(f)
+end
+function minetest.register_on_chat_message(f)
+end
+
+_G.Settings = {}
+Settings.__index = Settings
+setmetatable(Settings, {
+ __call = function (cls, ...)
+ return cls.new(...)
+ end,
+})
+function Settings.get(self,field)
+ print("get", field)
+ return self.vars[field]
+end
+function Settings:get_bool(field)
+ print("get_bool", field)
+ return self.vars[field]
+end
+function Settings:set(field, value)
+ print("set", field, value)
+ self.vars[field] = value
+ return
+end
+function Settings.new(filepath)
+ local self = setmetatable({}, MyClass)
+ self.filepath = filepath
+ self.vars = {}
+ self.vars["python"] = "python"
+ self.vars["restrict_to_local_connections"] = true
+ self.vars["support_websockets"] = true
+ self.get=Settings.get
+ self.get_bool=Settings.get_bool
+ self.set=Settings.set
+ return self
+end
+
+mod = require("init")
+
+describe("simple", function()
+ it("test", function()
+ minetest.globalstep(1)
+-- assert.equals(0, some-call)
+ end)
+end)
0xxx: Grabbed from upstream development.
1xxx: Possibly relevant for upstream adoption.
2xxx: Only relevant for official Debian release.
1000-busted-test.patch
......@@ -8,3 +8,6 @@ override_dh_install:
chmod a-x debian/minetest-mod-pycraft/usr/share/games/minetest/mods/pycraft/*
chmod a-x debian/python3-minecraftpi/usr/lib/python3/dist-packages/mcpi/*
chmod a-x debian/python3-minecraftpi/usr/share/doc/python3-minecraftpi/examples/*
override_dh_auto_test:
busted .
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment