From f31cb238cd67ac2df231ab62e0c2f33268f8d8bc Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: May 23 2017 08:08:44 +0000 Subject: rename 'generator' script to 'mtf-generator' Rename the script to 'mtf-generator' and install a 'generator' wrapper that prints out a warning that this name is deprecated. --- diff --git a/README.md b/README.md index 16d0f49..21a86be 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ * Now it just expect to end with `0` return code of command (like: `ls / |grep sbin` directory sbin exists in root dir) * It can contain multiple lines * It generates python covered bash tests - * You has to call `generator` binary explicitly, it then create these pythonish tests with bash inside, *Unittest* doesn not allow to have dynamic tests. + * You has to call `mtf-generator` binary explicitly, it then create these pythonish tests with bash inside, *Unittest* doesn not allow to have dynamic tests. * __Avocado tests__ * There is wrapper class what helps you to tests modules not focusing on module type @@ -90,7 +90,7 @@ pip install avocado-framework yaml json behave * ```dnf copr enable phracek/Modularity-testing-framework``` * install it by command: ```dnf install -y modularity-testing-framework``` * CREATE your config.yaml (see example https://pagure.io/modularity-testing-framework/blob/master/f/docs/example-config.yaml) - * If you have tests in config file call: `/usr/bin/generator` or simply `generator`. + * If you have tests in config file call: `/usr/bin/mtf-generator` or simply `mtf-generator`. * Call command for running all python tests: `MODULE=docker avocado run /usr/share/moduleframework/tools/modulelint.py ./*.py` * __additional tests__ - see tests in https://pagure.io/modularity-testing-framework/blob/master/f/examples/testing-module directory as an example for you diff --git a/distro/modularity-testing-framework.spec b/distro/modularity-testing-framework.spec index 84dd449..ba41fdb 100644 --- a/distro/modularity-testing-framework.spec +++ b/distro/modularity-testing-framework.spec @@ -38,6 +38,7 @@ chmod a+x %{buildroot}%{python_sitelib}/%{framework_name}/{module_framework,gene %doc CHANGELOG %{_bindir}/moduleframework-cmd %{_bindir}/modulelint +%{_bindir}/mtf-generator %{_bindir}/generator %{python2_sitelib}/moduleframework/ %{python2_sitelib}/modularity_testing_framework-*.egg-info/ diff --git a/docs/howtowriteyamlconf.md b/docs/howtowriteyamlconf.md index afe6721..9403361 100644 --- a/docs/howtowriteyamlconf.md +++ b/docs/howtowriteyamlconf.md @@ -82,4 +82,4 @@ testhost: * next level like __processrunning__ is test name what will be visible on output of avocado run, then all lines will be run as commands for this test * `testhost:` it is similar to *test*, just difference is that it runs commands on host machine so that there could be more dependencies than just are in module. I', not sure if this part is useful, will see after discussion *(Optional)* * other specification is same as `test` - * you have to call `generator` binary to generate python files from that (because unittests does not allow to have dynamically created tests) + * you have to call `mtf-generator` binary to generate python files from that (because unittests does not allow to have dynamically created tests) diff --git a/docs/overview.rst b/docs/overview.rst index a1f6583..6245f4a 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -18,7 +18,7 @@ Modularity prototype testing - Now it just expect to end with *0* return code of command (like: *ls / |grep sbin* directory sbin exists in root dir) - It can contain multiple lines - It generates python covered bash tests - - You has to call `generator` binary explicitly, it then create these pythonish tests with bash inside, *Unittest* doesn not allow to have dynamic tests. + - You has to call `mtf-generator` binary explicitly, it then create these pythonish tests with bash inside, *Unittest* doesn not allow to have dynamic tests. - **Avocado tests** - There is wrapper class what helps you to tests modules not focusing on module type @@ -107,7 +107,7 @@ How to write tests - *dnf copr enable phracek/Modularity-testing-framework* - install it by command: *dnf install -y modularity-testing-framework* - CREATE your config.yaml (see example `https://pagure.io/modularity-testing-framework/blob/master/f/docs/example-config.yaml`) -- If you have tests in config file call: */usr/bin/generator* or simply *generator*. +- If you have tests in config file call: */usr/bin/mtf-generator* or simply *mtf-generator*. - Call command for running all python tests: **MODULE=docker avocado run /usr/share/moduleframework/tools/modulelint.py ./*.py** - **additional tests** - see tests in `https://pagure.io/modularity-testing-framework/blob/master/f/examples/testing-module` directory as an example for you diff --git a/moduleframework/generator.py b/moduleframework/generator.py index 37f05de..cd48750 100755 --- a/moduleframework/generator.py +++ b/moduleframework/generator.py @@ -21,6 +21,8 @@ # Authors: Jan Scotka # +from __future__ import print_function + from moduleframework.module_framework import CommonFunctions @@ -63,7 +65,7 @@ class GeneratedTestsConfig(module_framework.AvocadoTest): """ % testname for line in testlines: self.output = self.output + ' self.%s(""" %s """, shell=True)\n' % (method, line) - print "Added test (runmethod: %s): %s" % (method, testname) + print("Added test (runmethod: %s): %s" % (method, testname)) def main(): @@ -73,5 +75,12 @@ def main(): configout.close() +def deprecated_main(): + import sys + print("The 'generator' name is deprecated and will go away eventually, " + "please use\n'mtf-generator' instead!", file=sys.stderr) + main() + + if __name__ == '__main__': main() diff --git a/setup.py b/setup.py index dd55d2a..ada969b 100755 --- a/setup.py +++ b/setup.py @@ -80,7 +80,8 @@ setup( 'console_scripts': [ 'moduleframework-cmd = moduleframework.bashhelper:main', 'modulelint = moduleframework.modulelint:main', - 'generator = moduleframework.generator:main', + 'mtf-generator = moduleframework.generator:main', + 'generator = moduleframework.generator:deprecated_main', ] }, setup_requires=[],