Skip to content

Commit

Permalink
Tests and wokflows updated
Browse files Browse the repository at this point in the history
Tests for power tools
  • Loading branch information
S-S-X committed Jan 7, 2025
1 parent 0aae827 commit 9b1a188
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 13 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
on: [push, pull_request]
name: luacheck
on: [push, pull_request]
jobs:
lint:
luacheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: lint
uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: ""
- name: Checkout
uses: actions/checkout@master
- name: Luacheck
uses: lunarmodules/luacheck@master
12 changes: 6 additions & 6 deletions .github/workflows/mineunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ name: mineunit
on: [push, pull_request]

jobs:
build:
mineunit:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/checkout@v3

- id: mineunit
uses: mt-mods/mineunit-actions@master
with:
working-directory: ./technic
mineunit-args: --engine-version 5.4.1
badge-label: Test coverage

- uses: RubbaBoy/BYOB@v1.2.0
- uses: RubbaBoy/BYOB@v1.3.0
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
NAME: "${{ steps.mineunit.outputs.badge-name }}"
Expand All @@ -40,6 +39,7 @@ jobs:
--------------------------------------------------------------
${{ steps.mineunit.outputs.mineunit-report }}
```
### Raw test runner output for geeks:
```
${{ steps.mineunit.outputs.mineunit-stdout }}
Expand All @@ -53,7 +53,7 @@ jobs:
comment: |
<details><summary><i>Mineunit failed regression tests, click for details</i></summary>
### Regression test log for technic:
### Regression test log for Technic:
```
${{ steps.mineunit.outputs.mineunit-stdout }}
```
Expand Down
32 changes: 32 additions & 0 deletions technic/spec/fixtures/default.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
mineunit:set_modpath("default", "spec/fixtures")

local function register_node(name, groups, additional_definition)
local definition = {
description = name.." description",
tiles = { "default_"..name },
groups = groups,
}
for k,v in pairs(additional_definition or {}) do definition[k] = v end
minetest.register_node(":default:"..name, definition)
end

local function register_item(name)
minetest.register_craftitem(":default:"..name, {
description = name.." description",
})
end

-- Register some basic nodes for cutting, grinding, digging, registering recipes etc.
register_node("stone", {cracky = 3, stone = 1}, {is_ground_content = true, drop = "default:cobble"})
register_node("cobble", {cracky=3, stone = 2})
register_node("sand", {snappy=2, choppy=2, oddly_breakable_by_hand=2})
register_node("wood", {tree=1, choppy=2, oddly_breakable_by_hand=2})
register_node("dirt", {crumbly = 3, soil = 1})
register_node("sandstone", {crumbly = 1, cracky = 3})
register_node("steelblock", {cracky = 1, level = 2})
register_node("furnace", {cracky=2})
register_node("furnace_active", {cracky=2, not_in_creative_inventory=1}, {drop = "default:furnace"})

register_item("steel_ingot")

screwdriver = {}
36 changes: 36 additions & 0 deletions technic/spec/fixtures/digilines.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- Simple digilines mod fixture that logs sent messages, works with some simple digiline mods

mineunit:set_modpath("digilines", "spec/fixtures")

digilines = {
_msg_log = {},
receptor_send = function(pos, rules, channel, msg)
table.insert(digilines._msg_log, {
pos = pos,
rules = rules,
channel = channel,
msg = msg,
})
end,
rules = {
default = {
{x=0, y=0, z=-1},
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{x=1, y=1, z=0},
{x=1, y=-1, z=0},
{x=-1, y=1, z=0},
{x=-1, y=-1, z=0},
{x=0, y=1, z=1},
{x=0, y=-1, z=1},
{x=0, y=1, z=-1},
{x=0, y=-1, z=-1}
}
}
}

digilines = setmetatable(digilines, {
__call = function(self,...) return self end,
__index = function(...) return function(...)end end,
})
27 changes: 27 additions & 0 deletions technic/spec/fixtures/mesecons.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
mineunit:set_modpath("mesecons", "spec/fixtures")
mineunit:set_modpath("mesecons_mvps", "spec/fixtures")

mesecon = {
state = {},
rules = {
default = {
{x = 0, y = 0, z = -1},
{x = 1, y = 0, z = 0},
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 1, y = 1, z = 0},
{x = 1, y = -1, z = 0},
{x = -1, y = 1, z = 0},
{x = -1, y = -1, z = 0},
{x = 0, y = 1, z = 1},
{x = 0, y = -1, z = 1},
{x = 0, y = 1, z = -1},
{x = 0, y = -1, z = -1},
}
}
}

mesecon = setmetatable(mesecon, {
__call = function(self,...) return self end,
__index = function(...) return function(...)end end,
})
Empty file.
27 changes: 27 additions & 0 deletions technic/spec/fixtures/technic.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
enable_cans = true
enable_chainsaw = true
enable_flashlight = true
enable_mining_drill = true
enable_mining_laser = true
enable_multimeter = true
enable_prospector = true
enable_sonic_screwdriver = true
enable_tree_tap = true
enable_vacuum = true

multimeter_remote_start_ttl = 300

enable_wind_mill = true
enable_nuclear_reactor_digiline_selfdestruct = true
quarry_max_depth = 100
quarry_time_limit = 5000

switch_off_delay_seconds = 1800
network_overload_reset_time = 20
admin_priv = basic_privs
enable_corium_griefing = true
enable_radiation_protection = true
enable_radiation_throttling = true
enable_entity_radiation_damage = true
enable_longterm_radiation_damage = true
max_lag_reduction_multiplier = 0.99
22 changes: 22 additions & 0 deletions technic/spec/fixtures/technic.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- Use this fixture when loading full Technic mod.
-- Loads all required modules and fixtures for technic

-- Load modules required by tests
mineunit("core")
mineunit("player")
mineunit("protection")
mineunit("common/after")
mineunit("server")
mineunit("voxelmanip")
if mineunit:config("engine_version") ~= "mineunit" then
mineunit("game/voxelarea")
end

-- Load fixtures required by tests
fixture("default")
fixture("mesecons")
fixture("digilines")
fixture("pipeworks")

-- Load technic_worldgen
fixture("technic_worldgen")
7 changes: 7 additions & 0 deletions technic/spec/fixtures/technic_worldgen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Load technic_worldgen mod

mineunit:set_modpath("technic_worldgen", "../technic_worldgen")

mineunit:set_current_modname("technic_worldgen")
sourcefile("../technic_worldgen/init")
mineunit:restore_current_modname()
11 changes: 11 additions & 0 deletions technic/spec/mineunit.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
deprecated = "ignore"
time_step = 100
exclude = {
-- Integration tests are not part of mod code
"integration_test",
-- These are commented out, not part of mod without manually editing code
"machines/MV/lighting",
"machines/MV/power_radiator",
-- Exclude everything outside of technic directory, some are tested but we do not want stats for these
"^../"
}
Loading

0 comments on commit 9b1a188

Please sign in to comment.