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

Extended Mineunit tests #208

Merged
merged 4 commits into from
Nov 6, 2021
Merged

Extended Mineunit tests #208

merged 4 commits into from
Nov 6, 2021

Conversation

S-S-X
Copy link
Member

@S-S-X S-S-X commented Sep 6, 2021

Generic and targeted extended tests for Technic modpack

Not sure if this is good or wanted, Mineunit supports a lot of things but still not even nearly everything.

This PR extends testing a lot but might be too fixed, it might be good thing as it enforces updating tests when there's big changes.
But for exact same reason it might not be wanted, dropping PR here anyway.

Current status

See comment #208 (comment) for complete list of current tests as of 957c2b8.

Old report: Test coverage report for technic 9.62% in 10/103 files
New report: Test coverage report for technic 64.48% in 117/117 files

Fixed annoyances

Also mineunit spamming a lot of warning InvRef:get_list returning list src as reference, this can lead to unxpected results, that's mineunit issue and not technic or regression test issue.
I do remember adding that warning to mineunit InvRef implementation just because I was not sure if actual minetest engine returns those as references or if it uses deep copies / copy-on-write objects of direct references to original object.

Test run on local machine, how many times these tests complain about possible "unxpected results" (yeah, just noticed typo too 🤣):

$ mineunit | grep 'as reference, this can lead to unxpected results' | wc -l
836

BuckarooBanzay
BuckarooBanzay previously approved these changes Sep 9, 2021
@github-actions

This comment has been minimized.

@S-S-X

This comment has been minimized.

@S-S-X
Copy link
Member Author

S-S-X commented Oct 19, 2021

Long list of things tests are currently doing:
  • CNC API
    • Machine control
      • returns product item string
      • configures new program
      • fails configuring invalid program
      • machine is enabled by default
      • disables machine
      • enables machine
      • manufactures products
      • fails manufacturing products
    • Machine registration
      • registers example machine
  • CNC formspec interaction
    • allows placing materials
    • allows placing materials protected
    • disallows placing materials protected
    • does not check protection for noop actions
    • checks protection for programming
    • sets metadata on form submit
    • manufactures products
    • updates old machines
  • CNC digiline API
    • handles invalid messages
    • sets program and size
    • disables machine
    • enables machine
    • returns programs
  • Technic CNC
    • technic:cnc
      • produces items
      • uses energy
    • technic:cnc_mk2
      • produces items
      • uses energy
  • Power network building
    • cable building
      • does not crash
      • is added to network
      • adds all network nodes
      • adds connected machines to network without duplicates
    • cable building to machine
      • does not crash
      • is added to network
      • adds all network nodes
      • adds connected machines to network without duplicates
      • does not add unconnected cables to network
      • does not duplicate already added machine
    • machine building
      • does not crash
      • is added to network without duplicates
      • does not remove connected machines from network
      • does not remove network
      • does not add cables to network
      • overloads network
    • cable building between networks
      • does not crash
      • removes network
    • cable cutting
      • does not crash
      • is removed from network
      • removes connected cables from network
      • removes connected machines from network
      • removes network
    • cable digging below machine
      • does not crash
      • is removed from network
      • removes connected machines from network
      • does not remove network
      • keeps connected machines in network
    • machine digging
      • does not crash
      • is removed from network
      • does not remove other nodes from network
      • does not remove connected machines from network
      • does not remove network
  • HV machine network
    • executes network
    • kills network when switching station disappear
    • charges battery box
    • smelts ores
    • grinds ores
  • LV machine network
    • executes network
    • kills network when switching station disappear
    • charges battery box
    • smelts ores
    • grinds ores
    • comperess sand
    • cuts power when generators disappear
  • Power network helper
    • network lookup functions
      • does not fail if network missing
      • returns correct position for network
      • returns correct network for position
      • returns nil tier for empty position
      • returns correct tier for switching station position
    • network constructors/destructors
      • creates network
      • builds network
      • does not add duplicates to network
      • removes network
    • Power network timeout functions technic.touch_node and technic.get_timeout
      • returns zero if no data available
      • returns timeout if data is available
  • technic.merge_networks
    • function behavior
      • merges networks
      • merges networks again
    • network building behavior
      • stops network building after first iteration
      • continues network building
      • merges with second network
      • finishes network build
  • Supply converter
    • building
      • does not crash
      • is added to network without duplicates
      • does not remove connected machines from network
      • does not remove networks
      • does not add cables to network
      • overloads network
    • digging
      • does not crash
      • is removed from network
      • does not remove other nodes from network
      • does not remove network
    • formspec
      • is protected

@S-S-X
Copy link
Member Author

S-S-X commented Oct 21, 2021

Performance update for Mineunit was good too:

  • Old: 73 successes / 0 failures / 0 errors / 1 pending : 17.358583 seconds
  • New: 150 successes / 0 failures / 0 errors / 1 pending : 6.409515 seconds

77 new tests are 77 nodes registered during tests (ignoring not_in_creative_inventory nodes).

@S-S-X
Copy link
Member Author

S-S-X commented Nov 1, 2021

@OgelGames / @BuckarooBanzay to be able to add better tests for new API updates I would like to get this merged.

So here's the question:

This PR extends testing a lot but might be too fixed, it might be good thing as it enforces updating tests when there's big changes.
But for exact same reason it might not be wanted

That's also reason why I'd like to have this while doing API upgrades for v2.0 release: guard new API against changes in interface and verify that updated API will actually follow specification.
Especially I'd like to integrate this into #230, #232 and #233 as all those introduce API changes for upcoming release, from there it would be good to get immediate notification if changing anything might also affect API.

It seems like this should not cause any big troubles, been working fine over multiple changes and seems to be stable enough. I've tested this against all open pull requests and also for multiple stages in some branches.

Executed LoC goes from 631 to 5890, this count include only lines of code that actually do something.
For example end, local varname, else and so on is excluded from counts mentioned.
Currently master branch has about 9219 lines of code counted like that (includes some of technic_worldgen and technic_cnc).

@S-S-X S-S-X added Documentation Enhancement New feature or request and removed Testing needed labels Nov 1, 2021
@BuckarooBanzay
Copy link
Member

This PR extends testing a lot but might be too fixed, it might be good thing as it enforces updating tests when there's big changes.
But for exact same reason it might not be wanted

IMO: More tests are better, updating the tests if there are big changes isn't really much more work (hopefully)

Lets merge it and see where it leads to...?

@S-S-X
Copy link
Member Author

S-S-X commented Nov 4, 2021

IMO: More tests are better, updating the tests if there are big changes isn't really much more work (hopefully)

Should not be, at least I've been writing temporary tests for things because it is way faster than starting Minetest world, logging in and clicking things. Fixing tests takes time but compatibility/behavior/API has changed when it has to be done.

If something goes wrong with Minetest and it crashes then you'll fix that thing and start over, if something goes wrong with Mineunit and it crashes then it happily proceeds to reset world and execute all of the remaining tests anyway.

At least for me tests allows faster big changes to underlying API while providing confidence without a lot of manual testing, actually since I've started Mineunit most of my play testing has been single last verification instead of finding and correcting typos or other stupid mistakes.

I'll review whole test set and clean up this updating for latest Mineunit where appropriate.

@github-actions
Copy link

github-actions bot commented Nov 5, 2021

Click for detailed source code test coverage report

Test coverage report for Technic CNC 79.01% in 10/14 files:

File                             Hits Missed Coverage
-----------------------------------------------------
programs.lua                   263  0      100.00%
materials/basic_materials.lua  17   0      100.00%
materials/default.lua          177  4      97.79%
cnc.lua                        50   3      94.34%
materials/init.lua             13   1      92.86%
formspec.lua                   103  8      92.79%
digilines.lua                  39   8      82.98%
init.lua                       19   6      76.00%
api.lua                        160  83     65.84%
pipeworks.lua                  25   13     65.79%
materials/technic_worldgen.lua 0    25     0.00%
materials/moreblocks.lua       0    29     0.00%
materials/ethereal.lua         0    37     0.00%
materials/bakedclay.lua        0    13     0.00%

Test coverage report for technic chests 45.24% in 6/6 files:

File          Hits Missed Coverage
----------------------------------
chests.lua    98   18     84.48%
init.lua      34   18     65.38%
register.lua  84   78     51.85%
formspec.lua  76   93     44.97%
inventory.lua 10   100    9.09%
digilines.lua 2    61     3.17%

Test coverage report for technic 64.48% in 117/117 files:

File                                      Hits Missed Coverage
--------------------------------------------------------------
max_lag.lua                                   12   0      100.00%
machines/register/init.lua                    22   0      100.00%
machines/register/grinder.lua                 6    0      100.00%
machines/register/freezer_recipes.lua         13   0      100.00%
machines/register/freezer.lua                 6    0      100.00%
machines/register/extractor.lua               6    0      100.00%
machines/register/electric_furnace.lua        6    0      100.00%
machines/register/compressor.lua              6    0      100.00%
machines/register/centrifuge.lua              6    0      100.00%
machines/other/init.lua                       8    0      100.00%
machines/MV/solar_array.lua                   9    0      100.00%
machines/MV/init.lua                          17   0      100.00%
machines/MV/grinder.lua                       8    0      100.00%
machines/MV/generator.lua                     9    0      100.00%
machines/MV/freezer.lua                       8    0      100.00%
machines/MV/extractor.lua                     8    0      100.00%
machines/MV/electric_furnace.lua              8    0      100.00%
machines/MV/compressor.lua                    8    0      100.00%
machines/MV/centrifuge.lua                    14   0      100.00%
machines/MV/battery_box.lua                   17   0      100.00%
machines/MV/alloy_furnace.lua                 8    0      100.00%
machines/LV/solar_array.lua                   8    0      100.00%
machines/LV/init.lua                          17   0      100.00%
machines/LV/grinder.lua                       9    0      100.00%
machines/LV/generator.lua                     9    0      100.00%
machines/LV/electric_furnace.lua              8    0      100.00%
machines/LV/compressor.lua                    13   0      100.00%
machines/LV/battery_box.lua                   15   0      100.00%
machines/LV/alloy_furnace.lua                 8    0      100.00%
machines/HV/solar_array.lua                   8    0      100.00%
machines/HV/init.lua                          12   0      100.00%
machines/HV/grinder.lua                       8    0      100.00%
machines/HV/generator.lua                     9    0      100.00%
machines/HV/electric_furnace.lua              8    0      100.00%
machines/HV/compressor.lua                    8    0      100.00%
machines/HV/battery_box.lua                   17   0      100.00%
legacy.lua                                    33   0      100.00%
items.lua                                     128  0      100.00%
crafts.lua                                    133  0      100.00%
../technic_worldgen/nodes.lua                 109  0      100.00%
../technic_worldgen/crafts.lua                103  0      100.00%
../technic_worldgen/config.lua                9    0      100.00%
../technic_cnc/programs.lua                   263  0      100.00%
../technic_cnc/materials/technic_worldgen.lua 32   0      100.00%
../technic_cnc/materials/init.lua             14   0      100.00%
../technic_cnc/materials/basic_materials.lua  17   0      100.00%
machines/LV/led.lua                           73   1      98.65%
../technic_cnc/materials/default.lua          178  4      97.80%
machines/register/compressor_recipes.lua      36   1      97.30%
machines/LV/geothermal.lua                    75   3      96.15%
config.lua                                    49   2      96.08%
machines/LV/solar_panel.lua                   42   2      95.45%
machines/register/solar_array.lua             40   2      95.24%
machines/register/cables.lua                  208  12     94.55%
../technic_cnc/cnc.lua                        50   3      94.34%
tools/init.lua                                13   1      92.86%
machines/LV/water_mill.lua                    67   6      91.78%
machines/network.lua                          323  31     91.24%
machines/LV/lamp.lua                          111  13     89.52%
machines/register/grindings.lua               42   5      89.36%
../technic_worldgen/overrides.lua             39   5      88.64%
init.lua                                      29   4      87.88%
machines/register/grinder_recipes.lua         106  16     86.89%
../technic_worldgen/rubber.lua                64   10     86.49%
../technic_worldgen/init.lua                  19   3      86.36%
../technic_worldgen/oregen.lua                155  28     84.70%
machines/register/machine_base.lua            164  41     80.00%
../technic_cnc/formspec.lua                   88   23     79.28%
../technic_cnc/init.lua                       19   6      76.00%
machines/register/recipes.lua                 62   20     75.61%
tools/flashlight.lua                          65   21     75.58%
machines/switching_station.lua                76   25     75.25%
machines/register/centrifuge_recipes.lua      21   7      75.00%
machines/register/battery_box.lua             219  73     75.00%
../technic_cnc/api.lua                        194  66     74.62%
effects.lua                                   5    2      71.43%
radiation.lua                                 245  100    71.01%
machines/LV/extractor.lua                     11   5      68.75%
machines/MV/wind_mill.lua                     46   22     67.65%
machines/other/coal_furnace.lua               2    1      66.67%
machines/supply_converter.lua                 93   48     65.96%
../technic_cnc/pipeworks.lua                  25   13     65.79%
machines/switching_station_globalstep.lua     40   21     65.57%
machines/register/alloy_recipes.lua           28   15     65.12%
machines/other/injector.lua                   72   39     64.86%
machines/MV/hydro_turbine.lua                 43   26     62.32%
machines/MV/tool_workshop.lua                 56   34     62.22%
machines/register/generator.lua               122  88     58.10%
register.lua                                  21   19     52.50%
tools/cans.lua                                53   48     52.48%
machines/power_monitor.lua                    40   38     51.28%
machines/other/coal_alloy_furnace.lua         63   63     50.00%
machines/LV/music_player.lua                  46   46     50.00%
tools/mining_lasers.lua                       39   40     49.37%
machines/other/constructor.lua                67   69     49.26%
machines/MV/cables.lua                        10   11     47.62%
machines/LV/cables.lua                        10   11     47.62%
machines/init.lua                             49   54     47.57%
tools/vacuum.lua                              19   21     47.50%
tools/tree_tap.lua                            24   27     47.06%
machines/HV/cables.lua                        9    11     45.00%
machines/HV/forcefield.lua                    101  157    39.15%
machines/HV/quarry.lua                        124  217    36.36%
machines/HV/nuclear_reactor.lua               116  208    35.80%
machines/register/common.lua                  39   75     34.21%
machines/register/alloy_furnace.lua           10   20     33.33%
tools/chainsaw.lua                            40   83     32.52%
tools/multimeter.lua                          71   149    32.27%
tools/sonic_screwdriver.lua                   18   40     31.03%
machines/other/frames.lua                     184  445    29.25%
helpers.lua                                   33   83     28.45%
tools/mining_drill.lua                        76   226    25.17%
machines/other/anchor.lua                     14   74     15.91%
machines/compat/digtron.lua                   2    11     15.38%
tools/prospector.lua                          16   92     14.81%
util/throttle.lua                             1    10     9.09%
machines/register/extractor_recipes.lua       6    65     8.45%

Raw test runner output for geeks:

CNC:

●●●●●●●●●●●●●●●●●●●●●●
22 successes / 0 failures / 0 errors / 0 pending : 0.146917 seconds

Chests:

W:	Configuration: invalid key	exclude_textures
W:	Configuration: invalid key	validate_textures
●●●●●
5 successes / 0 failures / 0 errors / 0 pending : 0.028 seconds

Technic:

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●◌●●●●●
169 successes / 0 failures / 0 errors / 1 pending : 6.642712 seconds

Pending → spec/supply_converter_spec.lua @ 78
Supply converter building overloads network
spec/supply_converter_spec.lua:78: overload does not work with supply converter

@S-S-X
Copy link
Member Author

S-S-X commented Nov 5, 2021

Cleaned up reducing duplicate initialization code and verified that set passes with master, machine API updates (after renaming solar arrays) and tool API updates. @OgelGames / @BuckarooBanzay want to still review this stuff?

Copy link
Contributor

@OgelGames OgelGames left a comment

Choose a reason for hiding this comment

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

Seems good to me 👍

@S-S-X S-S-X merged commit 6cee944 into master Nov 6, 2021
@OgelGames OgelGames deleted the extended-tests branch November 25, 2021 03:55
@Athozus Athozus added this to the 2.0.0 milestone Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants