Code Monkey home page Code Monkey logo

qa_block's Introduction

QA Block to run checking scripts for better quality assurance of code

License GPL-V3: https://www.gnu.org/licenses/gpl-3.0.html

This is a developer helper mod. It allows to run any lua code for testing reason. The mod can list and run lua-scripts placed in checks subfolder. Some check scripts are provided with the mod. The second part allows to display global lua-tables variables tree for debugging.

Features

  • redirection of print() output to minetest chat
  • redirection of print() output to a log file in the world directory. The output is sorted so that it can be compared to find regressions
  • robust call of the scripts trough "pcall" does not crash the game in case of syntax- or runtime errors
  • all functionality available through chat commands and the QA-Block node
  • refresh and list the checks script list at runtime
  • edit the code before calling them
  • type code and run it
  • explore global variables/lua tables

Screenshot Screenshot

https://forum.minetest.net/viewtopic.php?f=11&t=15759

Dependencies

  • none
    • smartfs(provided) - GUI for check selection and manipulation. Optional, but without smartfs there is limited functionality

Provided check modules

  • broken_recipe - Find crafting recipes which require unknown items
  • empty - Empty file for your own checks
  • get_item_csv - Export all registered items in a .CSV file
  • global_variables - List suspicious global variables
  • graphviz_recipes_all - Make a graphviz .dot file of all items in a recipe dependency tree
  • is_ground_content - This checker lists all nodes for which is_ground_content == true
  • list_entities - Lists all the registered entities (except builtin)
  • list_spawning_mobs - List entities that are mobs from mobs_redo or compatible framework
  • no_doc_items_help - Lists all items without item usage help or long description
  • no_item_description - Lists all items without description
  • no_sounds - Find nodes that don't have any sounds associated when dug, walked on, etc.
  • redundant_items - Lists items which seem redundant
  • same_recipe - Find duplicate crafting recipes
  • unobtainable_items - Lists items which seem to be unobtainable
  • useless_items - Lists all items which are probably useless

How to use:

add the mod to the game you like to test

Using chat command /qa

  • /qa help - print available chat commands
  • /qa ls - list all available check modules
  • /qa set checkname - set default check
  • /qa ui - display and run check using the selection dialog. Browse trough globals (smartfs only)
  • /qa checkname - run check
  • /qa - run default check

Using the block

  1. get the QA-Block from creative inventory
  2. place the block somewhere 3a - without smartfs - wait till the default check is finished and the block disappears 3b - with smartfs - start the check using selection dialog

In all cases - check the debug.txt for test results

Minetest Configuration Parameters

  • qa_block.print_to_chat, bool. Output QA check messages to chat
  • qa_block.log_to_file: bool. Output QA check messages to a file
  • qa_block.overwrite_log: bool. Overwrite the file at every game launch
  • qa_block.log_date_time: bool. Prepend a date and time stamp to log messages
  • qa_block.date_and_time_format: string. Date and time stamp format

Credits

  • Wuzzy2 - thanks for ideas, code optimizations and most check scripts
  • dacmot - for adding output to log file and configuration parameters

qa_block's People

Contributors

bell07 avatar dacmot avatar hybriddog avatar wuzzy2 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

qa_block's Issues

Mod does not work with developer version of Minetest

As of Minetest commit cc7c31a5bc44ab0010997e86c0a8c9f5f832b398, qa_block does not work. When I start the world, I immediately get this error:

2016-12-21 13:11:01: ERROR[Main]: ModError: Failed to load and run script from /home/wuzzy/src/minetest/git/minetest/bin/../mods/qa_block/init.lua:
2016-12-21 13:11:01: ERROR[Main]: .../src/minetest/git/minetest/bin/../mods/qa_block/init.lua:63: bad argument #1 to 'ipairs' (table expected, got string)
2016-12-21 13:11:01: ERROR[Main]: stack traceback:
2016-12-21 13:11:01: ERROR[Main]: 	[C]: in function 'ipairs'
2016-12-21 13:11:01: ERROR[Main]: 	.../src/minetest/git/minetest/bin/../mods/qa_block/init.lua:63: in function 'print'
2016-12-21 13:11:01: ERROR[Main]: 	.../src/minetest/git/minetest/bin/../mods/qa_block/init.lua:138: in main chunk

Hide core variables from Lua itself and Minetest's Lua API

In the globals tab, there are many variables which come from the core APIs.

I mean global Lua variables like:

  • _G
  • _VERSION
  • string
  • math
  • xpcall
  • dofile

And global Minetest variables like:

  • minetest
  • core
  • dump
  • dump2

It is not really useful to have these in the list as they just clutter the view IMO. I am mostly interested in the globals which come from mods.

I like to have a checkbox which allows me to filter out anything which comes from the core APIs (either Lua or Minetest).

Activating the checkbox should filter out:

  • Functions which have “=[C]” as the source (this automatically means they come either from Lua or Minetest)
  • Functions in the path of builtin (more Lua API stuff)
  • For the remaining variables which are not functions:

The first 2 checks can be done automatically. The non-function variables can be filtered out by a hard-coded list.

Multi-line string in globals list breaks the display

If there is a string variable with line breaks, it is displayed incorrectly in the list; the list looks broken in this case because text gets written “over” other text.

This can be easily tested by adding any global multi-line string variable in any mod.

A possible solution would be just to eliminate all newlines before they get printed on the list and by replacing them with a literal “\n”.

Add help for the QA block

I suggest to add help texts for the QA block by supporting the doc_items mod.

Support is very simple, you don't need to depend. You just need to add
_doc_items_longdesc = "<long description of what the QA block is good for goes here>"
and
_doc_items_usagehelp = "<explanation on how the QA block can be used goes here>"

to the node def. of the QA block. There is no length limit.
The QA block is quite complex now, so I (and especially other users) would appreciate a good and understandable explanation. :-)

You can test the help entry by installing the Help modpack:
https://forum.minetest.net/viewtopic.php?f=9&t=15912

minetest.chat_send_all --> log

Hi,

can you change print function minetest.chat_send_all(outsting) to minetest.log(outsting)?

The reason is, that .log is logged into the debug.txt by default. It's easier to analyze it.

Variable editing menu should only open for numbers and strings

In the Globals tab, you can double-click booleans which opens the editing menu. But if you save, the variable becomes a string.
You can also overwrite an userdata variable like this and accidentally turn them into a string.

I think the editing menu should only open for strings and numbers, but not for any other data type because it is only able to save values of these types.

Add 'bit' to acceptable global variables

The global variables check complains about the bit table looking suspicious but this one is part of the official Lua API now for bit operations (see lua_api.txt).

So please add bit to the accepted global variables.

Global value smartfs_enabled

qa_block pollutes the global namespace with the variable smartfs_enabled but I think it should be made local.

Colorize the list of variables

I suggest to use color coding for the list of variables in the Globals tab.

Use a different color for different variable types.
For example:

  • Cyan for functions
  • Purple for strings
  • Yellow for numbers
  • White for tables

I don't care much about the actual colors, what is important they are easy on the eye and easy to distinguish.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.