Skip to content

Commit

Permalink
refactor integration tests (#281)
Browse files Browse the repository at this point in the history
* refactor integration tests

* set deprecated_lua_api_handling to 'error'

Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
  • Loading branch information
BuckarooBanzay and BuckarooBanzay committed Aug 4, 2022
1 parent 5dbb061 commit b4cde13
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 116 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/integration-test-latest.yml

This file was deleted.

10 changes: 8 additions & 2 deletions .github/workflows/integration-test.yml
Expand Up @@ -6,9 +6,15 @@ jobs:
build:

runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
ENGINE_VERSION: [5.3.0, 5.4.0, 5.5.0, latest]

steps:
- uses: actions/checkout@v2

with:
fetch-depth: 0
submodules: recursive
- name: test
run: MINETEST_VERSION=5.2.0 ./integration-test.sh
run: docker-compose up --exit-code-from test
17 changes: 0 additions & 17 deletions .github/workflows_disabled/luacheck.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .luacheckrc
Expand Up @@ -27,7 +27,7 @@ read_globals = {
"unified_inventory", "protector",
"unifieddyes", "digiline_remote",
"drawers", "mg",
"craftguide", "i3",
"craftguide", "i3", "mtt",

-- Only used in technic/machines/MV/lighting.lua (disabled)
"isprotect", "homedecor_expect_infinite_stacks",
Expand Down
11 changes: 11 additions & 0 deletions .test/Dockerfile
@@ -0,0 +1,11 @@
ARG ENGINE_VERSION=5.5.0
FROM registry.gitlab.com/minetest/minetest/server:${ENGINE_VERSION}

USER root
RUN apk add git &&\
mkdir -p /root/.minetest/worlds/world/worldmods/ &&\
cd /root/.minetest/worlds/world/worldmods/ &&\
git clone --depth 1 https://github.com/BuckarooBanzay/mtt &&\
git clone --recurse-submodules --depth 1 https://github.com/mt-mods/basic_materials.git &&\
git clone --depth 1 https://github.com/mt-mods/pipeworks.git &&\
git clone --depth 1 https://github.com/minetest-mods/moreores.git
4 changes: 4 additions & 0 deletions .test/minetest.conf
@@ -0,0 +1,4 @@
default_game = minetest_game
mg_name = v7
mtt_enable = true
deprecated_lua_api_handling = error
176 changes: 176 additions & 0 deletions .test/registered_nodes.txt
@@ -0,0 +1,176 @@
technic:dummy_light_source
technic:lv_lamp_active
technic:lv_cable_plate_2
technic:lv_cable_plate_6
technic:lv_battery_box0
technic:mv_electric_furnace_active
technic:mv_alloy_furnace_active
technic:mv_compressor
technic:mv_grinder
technic:mv_grinder_active
technic:lv_battery_box1
technic:lv_battery_box2
technic:mv_cable_plate_6
technic:mv_battery_box3
technic:power_monitor
technic:mv_battery_box4
technic:mv_battery_box5
technic:mv_battery_box7
technic:mv_battery_box8
technic:mv_generator
technic:mv_solar_array
technic:hydro_turbine
technic:lv_cable_plate_1
technic:mv_cable_plate_1
technic:hv_cable
technic:hv_cable_plate_1
technic:lv_battery_box3
technic:lv_battery_box7
technic:solar_panel
technic:lv_solar_array
technic:geothermal
technic:water_mill_active
technic:supply_converter
technic:lv_generator
technic:lv_generator_active
technic:admin_anchor
technic:coal_alloy_furnace_active
technic:constructor_mk3_on
technic:constructor_mk1_off
technic:constructor_mk2_on
technic:constructor_mk2_off
technic:lv_grinder
technic:constructor_mk1_on
technic:injector
technic:switching_station
technic:hv_compressor_active
technic:hv_compressor
technic:lv_led
technic:hv_grinder_active
technic:hv_grinder
technic:hv_electric_furnace_active
technic:hv_electric_furnace
technic:forcefield
technic:lv_compressor
technic:hv_nuclear_reactor_core
technic:hv_solar_array
technic:hv_battery_box8
technic:hv_battery_box7
technic:hv_battery_box5
technic:hv_battery_box4
technic:hv_battery_box3
technic:hv_battery_box1
technic:hv_battery_box0
technic:uranium1_block
technic:uranium20_block
technic:hv_cable_plate_3
technic:uranium31_block
technic:hv_cable_plate_2
technic:mv_freezer_active
technic:mv_freezer
technic:tool_workshop
technic:mv_centrifuge_active
technic:mv_centrifuge
technic:mv_compressor_active
technic:mv_extractor_active
technic:mv_extractor
technic:mv_electric_furnace
technic:mv_alloy_furnace
technic:hydro_turbine_active
technic:mv_generator_active
technic:mv_battery_box6
technic:mv_battery_box2
technic:mv_battery_box1
technic:uranium33_block
technic:mv_battery_box0
technic:mv_cable_plate_5
technic:mv_cable_plate_4
technic:mv_cable_plate_3
technic:mv_cable_plate_2
technic:mv_cable
technic:uranium34_block
technic:lv_lamp
technic:lv_led_active
technic:music_player
technic:uranium35_block
technic:lv_compressor_active
technic:lv_extractor_active
technic:uranium9_block
technic:lv_extractor
technic:lv_grinder_active
technic:lv_electric_furnace_active
technic:lv_electric_furnace
technic:uranium10_block
technic:lv_alloy_furnace_active
technic:lv_alloy_furnace
technic:carbon_steel_block
technic:stainless_steel_block
technic:water_mill
technic:sulfur_block
technic:geothermal_active
technic:lv_battery_box8
technic:lv_battery_box6
technic:lv_battery_box5
technic:lv_battery_box4
technic:uranium12_block
technic:lv_cable_plate_5
technic:lv_cable_plate_4
technic:lv_cable_plate_3
technic:lv_cable
technic:uranium13_block
technic:chernobylite_block
technic:uranium8_block
technic:uranium11_block
technic:uranium32_block
technic:uranium30_block
technic:uranium29_block
technic:uranium28_block
technic:uranium27_block
technic:uranium26_block
technic:uranium25_block
technic:uranium24_block
technic:uranium23_block
technic:hv_cable_plate_4
technic:uranium16_block
technic:hv_cable_plate_5
technic:hv_cable_plate_6
technic:uranium18_block
technic:uranium17_block
technic:uranium15_block
technic:uranium14_block
technic:corium_flowing
technic:corium_source
technic:hv_battery_box2
technic:uranium2_block
technic:uranium19_block
technic:uranium0_block
technic:hv_battery_box6
technic:mineral_chromium
technic:mineral_lead
technic:mineral_sulfur
technic:granite
technic:uranium21_block
technic:granite_bricks
technic:marble
technic:marble_bricks
technic:uranium_block
technic:chromium_block
technic:uranium22_block
technic:zinc_block
technic:lead_block
technic:cast_iron_block
technic:uranium3_block
technic:uranium4_block
technic:uranium5_block
technic:uranium6_block
technic:hv_nuclear_reactor_core_active
technic:hv_generator
technic:hv_generator_active
technic:machine_casing
technic:mineral_uranium
technic:quarry
technic:forcefield_emitter_off
technic:constructor_mk3_off
technic:coal_alloy_furnace
technic:mineral_zinc
technic:forcefield_emitter_on
20 changes: 20 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,20 @@
version: "3.6"

services:
test:
build:
context: ./.test
args:
ENGINE_VERSION: ${ENGINE_VERSION:-5.5.0}
entrypoint: "minetestserver --config /minetest.conf"
user: root
volumes:
- "./:/root/.minetest/worlds/world/worldmods/technic/"
- "./.test/minetest.conf:/minetest.conf"
- "./.test/registered_nodes.txt:/root/.minetest/worlds/world/registered_nodes.txt"
- "world:/root/.minetest/worlds/world"
ports:
- "30000:30000/udp"

volumes:
world: {}
27 changes: 0 additions & 27 deletions integration-test.sh

This file was deleted.

2 changes: 1 addition & 1 deletion technic/init.lua
Expand Up @@ -55,6 +55,6 @@ if minetest.settings:get_bool("log_mods") then
print(S("[Technic] Loaded in @1 seconds", os.clock() - load_start))
end

if minetest.settings:get_bool("enable_technic_integration_test") then
if minetest.get_modpath("mtt") then
dofile(modpath.."/integration_test.lua")
end
62 changes: 9 additions & 53 deletions technic/integration_test.lua
@@ -1,56 +1,12 @@

minetest.log("warning", "[technic] integration-test enabled!")
-- check if all required nodenames are registered
mtt.validate_nodenames(minetest.get_worldpath().."/registered_nodes.txt")

-- those mods have to be present
local assert_mods = {
"technic",
"pipeworks"
}
-- test mapgen
mtt.emerge_area({x=0, y=0, z=0}, {x=48, y=48, z=48})

-- those nodes have to be present
local assert_nodes = {
"technic:admin_anchor"
}

-- defered integration test function
minetest.register_on_mods_loaded(function()
minetest.log("warning", "[technic] all mods loaded, starting delayed test-function")

minetest.after(1, function()
minetest.log("warning", "[technic] starting integration test")

-- export stats
local file = io.open(minetest.get_worldpath().."/registered_nodes.txt", "w" );
if file then
for name in pairs(minetest.registered_nodes) do
file:write(name .. '\n')
end
file:close()
end

-- check mods
for _, modname in ipairs(assert_mods) do
if not minetest.get_modpath(modname) then
error("Mod not present: " .. modname)
end
end

-- check nodes
for _, nodename in ipairs(assert_nodes) do
if not minetest.registered_nodes[nodename] then
error("Node not present: " .. nodename)
end
end

-- write success flag
local data = minetest.write_json({ success = true }, true);
file = io.open(minetest.get_worldpath().."/integration_test.json", "w" );
if file then
file:write(data)
file:close()
end

minetest.log("warning", "[technic] integration tests done!")
minetest.request_shutdown("success")
end)
end)
mtt.register("technic.max_lag", function(callback)
local lag = technic.get_max_lag()
assert(lag ~= nil and lag > 0)
callback()
end)
2 changes: 1 addition & 1 deletion technic/mod.conf
@@ -1,3 +1,3 @@
name = technic
depends = default, pipeworks, technic_worldgen, basic_materials, moreores
optional_depends = bucket, mesecons, mesecons_mvps, digilines, digiline_remote, unified_inventory, vector_extras, dye, craftguide, i3
optional_depends = bucket, mesecons, mesecons_mvps, digilines, digiline_remote, unified_inventory, vector_extras, dye, craftguide, i3, mtt

0 comments on commit b4cde13

Please sign in to comment.