Commit d02a7d83 by Vicent Marti

Update Clay

parent 35e9407c
......@@ -4,45 +4,19 @@ from __future__ import with_statement
from string import Template
import re, fnmatch, os
VERSION = "0.7.0"
VERSION = "0.8.0"
TEST_FUNC_REGEX = r"^(void\s+(test_%s__(\w+))\(\s*(void)?\s*\))\s*\{"
TEMPLATE_MAIN = Template(
r"""
CLAY_HEADER = """
/*
* Clay v${version}
* Clay v0.7.0
*
* This is an autogenerated file. Do not modify.
* To add new unit tests or suites, regenerate the whole
* file with `./clay`
*/
#define clay_print(...) ${clay_print}
${clay_library}
${extern_declarations}
static const struct clay_func _all_callbacks[] = {
${test_callbacks}
};
static const struct clay_suite _all_suites[] = {
${test_suites}
};
static const char _suites_str[] = "${suites_str}";
int _CC main(int argc, char *argv[])
{
return clay_test(
argc, argv, _suites_str,
_all_callbacks, ${cb_count},
_all_suites, ${suite_count}
);
}
""")
"""
TEMPLATE_SUITE = Template(
r"""
......@@ -60,7 +34,6 @@ def main():
parser = OptionParser()
parser.add_option('-c', '--clay-path', dest='clay_path')
parser.add_option('-o', '--output', dest='output')
parser.add_option('-v', '--report-to', dest='print_mode', default='stdout')
options, args = parser.parse_args()
......@@ -68,14 +41,13 @@ def main():
for folder in args:
builder = ClayTestBuilder(folder,
clay_path = options.clay_path,
output_folder = options.output,
print_mode = options.print_mode)
builder.render()
class ClayTestBuilder:
def __init__(self, folder_name, output_folder = None, clay_path = None, print_mode = 'stdout'):
def __init__(self, path, clay_path = None, print_mode = 'stdout'):
self.declarations = []
self.callbacks = []
self.suites = []
......@@ -84,22 +56,17 @@ class ClayTestBuilder:
self.clay_path = os.path.abspath(clay_path) if clay_path else None
self.print_mode = print_mode
folder_name = os.path.abspath(folder_name)
if not output_folder:
output_folder = folder_name
self.output = os.path.join(output_folder, "clay_main.c")
self.output_header = os.path.join(output_folder, "clay.h")
self.modules = ["clay.c", "clay_sandbox.c", "clay_fixtures.c", "clay_fs.c"]
self.path = os.path.abspath(path)
self.modules = ["clay_sandbox.c", "clay_fixtures.c", "clay_fs.c"]
print("Loading test suites...")
for root, dirs, files in os.walk(folder_name):
module_root = root[len(folder_name):]
for root, dirs, files in os.walk(self.path):
module_root = root[len(self.path):]
module_root = [c for c in module_root.split(os.sep) if c]
tests_in_module = fnmatch.filter(files, "*.c")
tests_in_module.sort()
for test_file in tests_in_module:
full_path = os.path.join(root, test_file)
......@@ -113,29 +80,36 @@ class ClayTestBuilder:
'No tests found under "%s"' % folder_name)
def render(self):
template = TEMPLATE_MAIN.substitute(
version = VERSION,
clay_print = self._get_print_method(),
clay_library = self._get_library(),
extern_declarations = "\n".join(self.declarations),
main_file = os.path.join(self.path, 'clay_main.c')
with open(main_file, "w") as out:
template = Template(self._load_file('clay.c'))
output = template.substitute(
clay_print = self._get_print_method(),
clay_modules = self._get_modules(),
suites_str = ", ".join(self.suite_list),
suites_str = ", ".join(self.suite_list),
test_callbacks = ",\n\t".join(self.callbacks),
cb_count = len(self.callbacks),
test_callbacks = ",\n\t".join(self.callbacks),
cb_count = len(self.callbacks),
test_suites = ",\n\t".join(self.suites),
suite_count = len(self.suites),
)
test_suites = ",\n\t".join(self.suites),
suite_count = len(self.suites),
)
out.write(output)
with open(self.output, "w") as out:
out.write(template)
header_file = os.path.join(self.path, 'clay.h')
with open(header_file, "w") as out:
template = Template(self._load_file('clay.h'))
output = template.substitute(
extern_declarations = "\n".join(self.declarations),
)
with open(self.output_header, "w") as out:
out.write(self._load_file('clay.h'))
out.write(output)
print ('Written test suite to "%s"' % self.output)
print ('Written header to "%s"' % self.output_header)
print ('Written Clay suite to "%s"' % self.path)
#####################################################
# Internal methods
......@@ -166,7 +140,7 @@ class ClayTestBuilder:
content = base64.b64decode(content)
return zlib.decompress(content)
def _get_library(self):
def _get_modules(self):
return "\n".join(self._load_file(f) for f in self.modules)
def _parse_comment(self, comment):
......@@ -217,11 +191,11 @@ class ClayTestBuilder:
print(" %s (%d tests)" % (clean_name, len(callbacks)))
CLAY_FILES = {
"clay.c" : r"""eJy9GF1v2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dzuouR/b9P+bEHO5Mg7qKjpnPPKlTEs4wqKuo51IJ+Y/XaSOpecPqYAIPj/P56cvQgtVd74Rtyt9hto5uArqt11fN3nR7jkMjdgrbe6YN7KnIH2pjOuqZSsWcoWxG+zaOnqkSXDy1a/AiTnimyykLtK9ufTEuB6cfjg3Ta7J+qSGQVsr9GEeCa2SVc9j14IT/vI4VmlymdtOSKOrOal/f29+4NqgEOdz5E2z/GF4ABeagMA=="""
}
if __name__ == '__main__':
......
......@@ -48,11 +48,46 @@ void cl_fixture_cleanup(const char *fixture_name);
#define cl_check_fail(expr) cl_check_fail_((expr), NULL)
#define cl_check(expr) cl_check_((expr), NULL)
/**
* Forced failure/warning
*/
#define cl_fail(desc) clay__assert(0, __FILE__, __LINE__, "Test failed.", desc, 1)
#define cl_warning(desc) clay__assert(0, __FILE__, __LINE__, "Warning during test execution:", desc, 0)
/**
* Test method declarations
*/
extern void test_core_dirent__dont_traverse_dot(void);
extern void test_core_dirent__traverse_subfolder(void);
extern void test_core_dirent__traverse_slash_terminated_folder(void);
extern void test_core_dirent__dont_traverse_empty_folders(void);
extern void test_core_dirent__traverse_weird_filenames(void);
extern void test_core_filebuf__0(void);
extern void test_core_filebuf__1(void);
extern void test_core_filebuf__2(void);
extern void test_core_path__0(void);
extern void test_core_path__1(void);
extern void test_core_path__2(void);
extern void test_core_path__5(void);
extern void test_core_path__6(void);
extern void test_core_rmdir__initialize(void);
extern void test_core_rmdir__delete_recursive(void);
extern void test_core_rmdir__fail_to_delete_non_empty_dir(void);
extern void test_core_string__0(void);
extern void test_core_string__1(void);
extern void test_core_vector__0(void);
extern void test_core_vector__1(void);
extern void test_core_vector__2(void);
extern void test_network_remotes__initialize(void);
extern void test_network_remotes__cleanup(void);
extern void test_network_remotes__parsing(void);
extern void test_network_remotes__refspec_parsing(void);
extern void test_network_remotes__fnmatch(void);
extern void test_network_remotes__transform(void);
extern void test_status_single__hash_single_file(void);
extern void test_status_worktree__initialize(void);
extern void test_status_worktree__cleanup(void);
extern void test_status_worktree__whole_repository(void);
extern void test_status_worktree__empty_repository(void);
#endif
/*
* Clay v0.7.0
*
* This is an autogenerated file. Do not modify.
* To add new unit tests or suites, regenerate the whole
* file with `./clay`
*/
#define clay_print(...) printf(__VA_ARGS__)
#include <assert.h>
#include <setjmp.h>
#include <stdlib.h>
......@@ -20,6 +9,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#define clay_print(...) printf(__VA_ARGS__)
#ifdef _WIN32
# include <windows.h>
# include <io.h>
......@@ -27,7 +18,7 @@
# include <direct.h>
# pragma comment(lib, "shell32")
# define _CC __cdecl
# define _MAIN_CC __cdecl
# define stat(path, st) _stat(path, st)
# define mkdir(path, mode) _mkdir(path)
......@@ -42,8 +33,9 @@
# endif
typedef struct _stat STAT_T;
#else
# include <sys/wait.h> /* waitpid(2) */
# include <unistd.h>
# define _CC
# define _MAIN_CC
typedef struct stat STAT_T;
#endif
......@@ -455,8 +447,11 @@ static int build_sandbox_path(void)
#ifdef _MSC_VER
if (_mktemp_s(_clay_path, sizeof(_clay_path)) != 0)
return -1;
if (mkdir(_clay_path, 0700) != 0)
return -1;
#else
if (mktemp(_clay_path) == NULL)
if (mkdtemp(_clay_path) == NULL)
return -1;
#endif
......@@ -468,9 +463,6 @@ static int clay_sandbox(void)
if (_clay_path[0] == '\0' && build_sandbox_path() < 0)
return -1;
if (mkdir(_clay_path, 0700) != 0)
return -1;
if (chdir(_clay_path) != 0)
return -1;
......@@ -665,39 +657,6 @@ cl_fs_cleanup(void)
#endif
extern void test_core_dirent__dont_traverse_dot(void);
extern void test_core_dirent__traverse_subfolder(void);
extern void test_core_dirent__traverse_slash_terminated_folder(void);
extern void test_core_dirent__dont_traverse_empty_folders(void);
extern void test_core_dirent__traverse_weird_filenames(void);
extern void test_core_filebuf__0(void);
extern void test_core_filebuf__1(void);
extern void test_core_filebuf__2(void);
extern void test_core_path__0(void);
extern void test_core_path__1(void);
extern void test_core_path__2(void);
extern void test_core_path__5(void);
extern void test_core_path__6(void);
extern void test_core_rmdir__initialize(void);
extern void test_core_rmdir__delete_recursive(void);
extern void test_core_rmdir__fail_to_delete_non_empty_dir(void);
extern void test_core_string__0(void);
extern void test_core_string__1(void);
extern void test_core_vector__0(void);
extern void test_core_vector__1(void);
extern void test_core_vector__2(void);
extern void test_network_remotes__initialize(void);
extern void test_network_remotes__cleanup(void);
extern void test_network_remotes__parsing(void);
extern void test_network_remotes__refspec_parsing(void);
extern void test_network_remotes__fnmatch(void);
extern void test_network_remotes__transform(void);
extern void test_status_single__hash_single_file(void);
extern void test_status_worktree__initialize(void);
extern void test_status_worktree__cleanup(void);
extern void test_status_worktree__whole_repository(void);
extern void test_status_worktree__empty_repository(void);
static const struct clay_func _all_callbacks[] = {
{"dont_traverse_dot", &test_core_dirent__dont_traverse_dot, 0},
{"traverse_subfolder", &test_core_dirent__traverse_subfolder, 0},
......@@ -787,7 +746,7 @@ static const struct clay_suite _all_suites[] = {
static const char _suites_str[] = "core::dirent, core::filebuf, core::path, core::rmdir, core::string, core::vector, network::remotes, status::single, status::worktree";
int _CC main(int argc, char *argv[])
int _MAIN_CC main(int argc, char *argv[])
{
return clay_test(
argc, argv, _suites_str,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment