diff options
author | Sergio Martins <smartins@kde.org> | 2018-03-02 20:47:40 +0000 |
---|---|---|
committer | Sergio Martins <smartins@kde.org> | 2018-03-02 20:52:04 +0000 |
commit | 58dd15f61c0fbe11e4579d4c996afd346279d476 (patch) | |
tree | a4dd270490b3bfb39379dd675ab5c40c285244b5 /dev-scripts | |
parent | a67690085e7abbce14990e1218fbd103dc64a189 (diff) |
generate.py: Generate unit-test folder and files
Diffstat (limited to 'dev-scripts')
-rwxr-xr-x | dev-scripts/generate.py | 20 | ||||
-rw-r--r-- | dev-scripts/templates/test-config.json | 7 | ||||
-rw-r--r-- | dev-scripts/templates/test-main.cpp | 6 |
3 files changed, 33 insertions, 0 deletions
diff --git a/dev-scripts/generate.py b/dev-scripts/generate.py index 7d6668df..9ff6eb49 100755 --- a/dev-scripts/generate.py +++ b/dev-scripts/generate.py @@ -25,6 +25,7 @@ _license_text = \ """ import sys, os, json, argparse +from shutil import copyfile CHECKS_FILENAME = 'checks.json' _checks = [] @@ -293,6 +294,24 @@ def create_readmes(checks): f.close() print("Created " + check.readme_path()) #------------------------------------------------------------------------------- +def create_unittests(checks): + for check in checks: + unittest_folder = clazy_source_path() + "tests/" + check.name + if not os.path.exists(unittest_folder): + os.mkdir(unittest_folder) + print("Created " + unittest_folder) + + configjson_file = unittest_folder + "/config.json" + if not os.path.exists(configjson_file): + copyfile(templates_path() + "test-config.json", configjson_file) + print("Created " + configjson_file) + + testmain_file = unittest_folder + "/main.cpp" + if not os.path.exists(testmain_file) and check.name != 'non-pod-global-static': + copyfile(templates_path() + "test-main.cpp", testmain_file) + print("Created " + testmain_file) + +#------------------------------------------------------------------------------- def generate_readme(checks): filename = clazy_source_path() + "README.md" @@ -350,5 +369,6 @@ if args.generate: generate_cmake_file(_checks) generate_readme(_checks) create_readmes(_checks) + create_unittests(_checks) else: parser.print_help(sys.stderr) diff --git a/dev-scripts/templates/test-config.json b/dev-scripts/templates/test-config.json new file mode 100644 index 00000000..e7e6e0cb --- /dev/null +++ b/dev-scripts/templates/test-config.json @@ -0,0 +1,7 @@ +{ + "tests" : [ + { + "filename" : "main.cpp" + } + ] +} diff --git a/dev-scripts/templates/test-main.cpp b/dev-scripts/templates/test-main.cpp new file mode 100644 index 00000000..5ca75994 --- /dev/null +++ b/dev-scripts/templates/test-main.cpp @@ -0,0 +1,6 @@ +#include <QtCore/QObject> +#include <QtCore/QString> + +void test() +{ +} |