A nifty and interactive command-line tool for efficient management and execution of commands grouped in hierarchical structures.
pip install nifty --upgrade
PyPI link here.
Suppose you are working on a large project that spans multiple components and touches many files in the codebase. During the development process you constantly have to make changes in different files and components, and each change can impact the entire project.
In order to make sure that your changes do not break the existing behavior of the system, regardless of how big or small they are, you have to run your unit tests and integration tests continuously.
However, it's not always trivial to manage and run all the tests you need in a complex project. Sometimes you just want to run a subset of a group of tests, but occasionally you want to run a multitude of tests across different parts of the project. Moreover, there might not be any test scripts provided to you that are sufficiently flexible to allow you to run any individual tests or combinations of them efficiently.
Well, despair no more, nifty was designed to address this problem. All you
have do is to specify all the tests in a
.yaml config file in a hierarchical
structure that makes sense to you.
Below is a hypothetical example:
unittests: backend: - 'base/utils/tests/utils_test.test' - 'components/models/tests/models_test.test' - 'servlet/v1/handlers/tests/handlers_test.test' logic: - 'logic/core/encapsulation/tests/encapsulation_test.test' - 'logic/core/request_delegation/tests/request_delegation.test' frontend: - 'www/servlet/tests/servlet_test.test' - 'rendering/tests/rendering_test.test' - 'js/tests/js_test.test' integrations: - 'v1/integrations/integration_test_1.test' - 'v1/integrations/integration_test_2.test' - 'v1/integrations/integration_test_3.test'
Say you put this file under
test_configs/project.yaml, all you have to do is
to run this with nifty:
nifty test_configs/project.yaml -c testrunner -r '--verbose'
In a nutshell, you pass in the path of the config file, in this case it's
test_configs/project.yaml, then followed by the command
that's used to run the tests, in this case it's a hypothetical command
testrunner, following right after either
Additionally, you can also specify extra arguments that get passed to the
command followed by either
--arguments (in this case it's
Note: for the current version, only the most bottom level items can be arranged into lists. This is by design for the time being, and will probably be changed later on for greater flexibility.
Last, if you still feel lost, just do
Nifty allows you to select one or more items simultaneously. For the sample config file above, the following is shown:
From config file: test_configs/project.yaml  unittests  logic  logic/core/encapsulation/tests/encapsulation_test.test  logic/core/request_delegation/tests/request_delegation.test  frontend  www/servlet/tests/servlet_test.test  rendering/tests/rendering_test.test  js/tests/js_test.test  backend  base/utils/tests/utils_test.test  components/models/tests/models_test.test  servlet/v1/handlers/tests/handlers_test.test  integrations  v1/integrations/integration_test_1.test  v1/integrations/integration_test_2.test  v1/integrations/integration_test_3.test Please enter: a) One or more paths (e.g. '1.2, 3.4.5') b) "all" c) "exit" >>
If you just want to select a single item, just enter an integer that's
labeled for the desired item, and the interactive prompt will step into that
item. For example, if you want to select all integration tests, just enter
the result will look like this:
From config file: test_configs/project.yaml  v1/integrations/integration_test_1.test  v1/integrations/integration_test_2.test  v1/integrations/integration_test_3.test Please enter: a) One or more paths (e.g. '1.2, 3.4.5') b) "all" c) "exit" >>
You can also select one or more items that may not be in the same logical group,
using dot-separated paths, with each path separated by a comma.
For example, if you want to select
v1/integrations/integration_test_1.test together, you can enter
1.2.3, 1.3.1, 2.1.
The result will look like this:
Please enter: a) One or more paths (e.g. '1.2, 3.4.5') b) "all" c) "exit" >> 1.2.3, 1.3.1, 2.1 Going to execute the following 3 item(s) with the command testrunner:  js/tests/js_test.test  base/utils/tests/utils_test.test  v1/integrations/integration_test_1.test
Last, there are two more options that can be convenient from time to time.
--list lists all the targets without running them and
runs all targets.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004
Copyright (C) 2014 Yanzheng Li
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION