From 58dd15f61c0fbe11e4579d4c996afd346279d476 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Fri, 2 Mar 2018 20:47:40 +0000 Subject: generate.py: Generate unit-test folder and files --- dev-scripts/generate.py | 20 ++++++++++++++++++++ dev-scripts/templates/test-config.json | 7 +++++++ dev-scripts/templates/test-main.cpp | 6 ++++++ 3 files changed, 33 insertions(+) create mode 100644 dev-scripts/templates/test-config.json create mode 100644 dev-scripts/templates/test-main.cpp (limited to 'dev-scripts') 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 +#include + +void test() +{ +} -- cgit v1.2.3