Unverified Commit 043f3123 by Edward Thomson Committed by GitHub

Merge pull request #6113 from libgit2/ethomson/cmake3

Add missing-declarations warning globally
parents 7687948a 4a6ef5a4
...@@ -125,6 +125,7 @@ else() ...@@ -125,6 +125,7 @@ else()
enable_warnings(documentation) enable_warnings(documentation)
disable_warnings(documentation-deprecated-sync) disable_warnings(documentation-deprecated-sync)
disable_warnings(missing-field-initializers) disable_warnings(missing-field-initializers)
enable_warnings(missing-declarations)
enable_warnings(strict-aliasing) enable_warnings(strict-aliasing)
enable_warnings(strict-prototypes) enable_warnings(strict-prototypes)
enable_warnings(declaration-after-statement) enable_warnings(declaration-after-statement)
......
...@@ -110,22 +110,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo ...@@ -110,22 +110,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
return ret; return ret;
} }
void init_array(git_strarray *array, int argc, char **argv) static void print_usage(void)
{
unsigned int i;
array->count = argc;
array->strings = calloc(array->count, sizeof(char *));
assert(array->strings != NULL);
for (i = 0; i < array->count; i++) {
array->strings[i] = argv[i];
}
return;
}
void print_usage(void)
{ {
fprintf(stderr, "usage: add [options] [--] file-spec [file-spec] [...]\n\n"); fprintf(stderr, "usage: add [options] [--] file-spec [file-spec] [...]\n\n");
fprintf(stderr, "\t-n, --dry-run dry run\n"); fprintf(stderr, "\t-n, --dry-run dry run\n");
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "hash.h" #include "hash.h"
#include "commit_graph.h" #include "commit_graph.h"
#include "standalone_driver.h"
int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerInitialize(int *argc, char ***argv)
{ {
GIT_UNUSED(argc); GIT_UNUSED(argc);
......
...@@ -10,9 +10,11 @@ ...@@ -10,9 +10,11 @@
#include "git2.h" #include "git2.h"
#include "config_backend.h" #include "config_backend.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
int foreach_cb(const git_config_entry *entry, void *payload) static int foreach_cb(const git_config_entry *entry, void *payload)
{ {
UNUSED(entry); UNUSED(entry);
UNUSED(payload); UNUSED(payload);
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "git2/sys/transport.h" #include "git2/sys/transport.h"
#include "futils.h" #include "futils.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
struct fuzzer_buffer { struct fuzzer_buffer {
...@@ -130,7 +132,7 @@ static int fuzzer_subtransport_new( ...@@ -130,7 +132,7 @@ static int fuzzer_subtransport_new(
return 0; return 0;
} }
int fuzzer_subtransport_cb( static int fuzzer_subtransport_cb(
git_smart_subtransport **out, git_smart_subtransport **out,
git_transport *owner, git_transport *owner,
void *payload) void *payload)
...@@ -145,7 +147,7 @@ int fuzzer_subtransport_cb( ...@@ -145,7 +147,7 @@ int fuzzer_subtransport_cb(
return 0; return 0;
} }
int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param) static int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param)
{ {
git_smart_subtransport_definition def = { git_smart_subtransport_definition def = {
fuzzer_subtransport_cb, fuzzer_subtransport_cb,
...@@ -155,7 +157,7 @@ int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param) ...@@ -155,7 +157,7 @@ int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param)
return git_transport_smart(out, owner, &def); return git_transport_smart(out, owner, &def);
} }
void fuzzer_git_abort(const char *op) static void fuzzer_git_abort(const char *op)
{ {
const git_error *err = git_error_last(); const git_error *err = git_error_last();
fprintf(stderr, "unexpected libgit error: %s: %s\n", fprintf(stderr, "unexpected libgit error: %s: %s\n",
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "hash.h" #include "hash.h"
#include "midx.h" #include "midx.h"
#include "standalone_driver.h"
int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerInitialize(int *argc, char ***argv)
{ {
GIT_UNUSED(argc); GIT_UNUSED(argc);
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "git2.h" #include "git2.h"
#include "object.h" #include "object.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerInitialize(int *argc, char ***argv)
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "common.h" #include "common.h"
#include "str.h" #include "str.h"
#include "standalone_driver.h"
static git_odb *odb = NULL; static git_odb *odb = NULL;
static git_odb_backend *mempack = NULL; static git_odb_backend *mempack = NULL;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "patch.h" #include "patch.h"
#include "patch_parse.h" #include "patch_parse.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerInitialize(int *argc, char ***argv)
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
#include "futils.h" #include "futils.h"
#include "path.h" #include "path.h"
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); #include "standalone_driver.h"
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
static int run_one_file(const char *filename) static int run_one_file(const char *filename)
{ {
......
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_standalone_driver_h__
#define INCLUDE_standalone_driver_h__
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
#endif
...@@ -41,8 +41,6 @@ set(LIBGIT2_INCLUDES ...@@ -41,8 +41,6 @@ set(LIBGIT2_INCLUDES
set(LIBGIT2_SYSTEM_INCLUDES "") set(LIBGIT2_SYSTEM_INCLUDES "")
set(LIBGIT2_LIBS "") set(LIBGIT2_LIBS "")
enable_warnings(missing-declarations)
if(HAVE_FUTIMENS) if(HAVE_FUTIMENS)
set(GIT_USE_FUTIMENS 1) set(GIT_USE_FUTIMENS 1)
endif () endif ()
......
...@@ -25,7 +25,7 @@ if(MSVC_IDE) ...@@ -25,7 +25,7 @@ if(MSVC_IDE)
endif() endif()
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/clar.suite ${CMAKE_CURRENT_BINARY_DIR}/clar_suite.h
COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf . COMMAND ${PYTHON_EXECUTABLE} generate.py -o "${CMAKE_CURRENT_BINARY_DIR}" -f -xonline -xstress -xperf .
DEPENDS ${SRC_TEST} DEPENDS ${SRC_TEST}
WORKING_DIRECTORY ${CLAR_PATH} WORKING_DIRECTORY ${CLAR_PATH}
...@@ -48,6 +48,14 @@ target_include_directories(libgit2_tests PRIVATE ../src PUBLIC ../include) ...@@ -48,6 +48,14 @@ target_include_directories(libgit2_tests PRIVATE ../src PUBLIC ../include)
target_link_libraries(libgit2_tests ${LIBGIT2_LIBS}) target_link_libraries(libgit2_tests ${LIBGIT2_LIBS})
ide_split_sources(libgit2_tests) ide_split_sources(libgit2_tests)
#
# Old versions of gcc require us to declare our test functions; don't do
# this on newer compilers to avoid unnecessary recompilation.
#
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
add_definitions(-include \"clar_suite.h\")
endif()
if(MSVC_IDE) if(MSVC_IDE)
# Precompiled headers # Precompiled headers
set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h") set_target_properties(libgit2_tests PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
......
...@@ -509,7 +509,7 @@ void test_checkout_tree__can_disable_pattern_match(void) ...@@ -509,7 +509,7 @@ void test_checkout_tree__can_disable_pattern_match(void)
cl_assert(git_fs_path_isfile("testrepo/branch_file.txt")); cl_assert(git_fs_path_isfile("testrepo/branch_file.txt"));
} }
void assert_conflict( static void assert_conflict(
const char *entry_path, const char *entry_path,
const char *new_content, const char *new_content,
const char *parent_sha, const char *parent_sha,
...@@ -1034,7 +1034,8 @@ void test_checkout_tree__filemode_preserved_in_index(void) ...@@ -1034,7 +1034,8 @@ void test_checkout_tree__filemode_preserved_in_index(void)
git_index_free(index); git_index_free(index);
} }
mode_t read_filemode(const char *path) #ifndef GIT_WIN32
static mode_t read_filemode(const char *path)
{ {
git_str fullpath = GIT_STR_INIT; git_str fullpath = GIT_STR_INIT;
struct stat st; struct stat st;
...@@ -1050,6 +1051,7 @@ mode_t read_filemode(const char *path) ...@@ -1050,6 +1051,7 @@ mode_t read_filemode(const char *path)
return result; return result;
} }
#endif
void test_checkout_tree__filemode_preserved_in_workdir(void) void test_checkout_tree__filemode_preserved_in_workdir(void)
{ {
...@@ -1267,7 +1269,7 @@ void test_checkout_tree__case_changing_rename(void) ...@@ -1267,7 +1269,7 @@ void test_checkout_tree__case_changing_rename(void)
git_commit_free(master_commit); git_commit_free(master_commit);
} }
void perfdata_cb(const git_checkout_perfdata *in, void *payload) static void perfdata_cb(const git_checkout_perfdata *in, void *payload)
{ {
memcpy(payload, in, sizeof(git_checkout_perfdata)); memcpy(payload, in, sizeof(git_checkout_perfdata));
} }
...@@ -1296,7 +1298,7 @@ void test_checkout_tree__can_collect_perfdata(void) ...@@ -1296,7 +1298,7 @@ void test_checkout_tree__can_collect_perfdata(void)
git_object_free(obj); git_object_free(obj);
} }
void update_attr_callback( static void update_attr_callback(
const char *path, const char *path,
size_t completed_steps, size_t completed_steps,
size_t total_steps, size_t total_steps,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
int clar_summary_close_tag( static int clar_summary_close_tag(
struct clar_summary *summary, const char *tag, int indent) struct clar_summary *summary, const char *tag, int indent)
{ {
const char *indt; const char *indt;
...@@ -14,12 +14,12 @@ int clar_summary_close_tag( ...@@ -14,12 +14,12 @@ int clar_summary_close_tag(
return fprintf(summary->fp, "%s</%s>\n", indt, tag); return fprintf(summary->fp, "%s</%s>\n", indt, tag);
} }
int clar_summary_testsuites(struct clar_summary *summary) static int clar_summary_testsuites(struct clar_summary *summary)
{ {
return fprintf(summary->fp, "<testsuites>\n"); return fprintf(summary->fp, "<testsuites>\n");
} }
int clar_summary_testsuite(struct clar_summary *summary, static int clar_summary_testsuite(struct clar_summary *summary,
int idn, const char *name, const char *pkg, time_t timestamp, int idn, const char *name, const char *pkg, time_t timestamp,
double elapsed, int test_count, int fail_count, int error_count) double elapsed, int test_count, int fail_count, int error_count)
{ {
...@@ -42,7 +42,7 @@ int clar_summary_testsuite(struct clar_summary *summary, ...@@ -42,7 +42,7 @@ int clar_summary_testsuite(struct clar_summary *summary,
idn, name, pkg, iso_dt, elapsed, test_count, fail_count, error_count); idn, name, pkg, iso_dt, elapsed, test_count, fail_count, error_count);
} }
int clar_summary_testcase(struct clar_summary *summary, static int clar_summary_testcase(struct clar_summary *summary,
const char *name, const char *classname, double elapsed) const char *name, const char *classname, double elapsed)
{ {
return fprintf(summary->fp, return fprintf(summary->fp,
...@@ -50,7 +50,7 @@ int clar_summary_testcase(struct clar_summary *summary, ...@@ -50,7 +50,7 @@ int clar_summary_testcase(struct clar_summary *summary,
name, classname, elapsed); name, classname, elapsed);
} }
int clar_summary_failure(struct clar_summary *summary, static int clar_summary_failure(struct clar_summary *summary,
const char *type, const char *message, const char *desc) const char *type, const char *message, const char *desc)
{ {
return fprintf(summary->fp, return fprintf(summary->fp,
......
...@@ -150,7 +150,7 @@ static cl_perf_timer s_timer_run = CL_PERF_TIMER_INIT; ...@@ -150,7 +150,7 @@ static cl_perf_timer s_timer_run = CL_PERF_TIMER_INIT;
*/ */
static cl_perf_timer s_timer_test = CL_PERF_TIMER_INIT; static cl_perf_timer s_timer_test = CL_PERF_TIMER_INIT;
void _cl_trace_cb__event_handler( static void _cl_trace_cb__event_handler(
cl_trace_event ev, cl_trace_event ev,
const char *suite_name, const char *suite_name,
const char *test_name, const char *test_name,
......
...@@ -109,7 +109,7 @@ void test_clone_nonetwork__fail_with_already_existing_but_non_empty_directory(vo ...@@ -109,7 +109,7 @@ void test_clone_nonetwork__fail_with_already_existing_but_non_empty_directory(vo
cl_git_fail(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options)); cl_git_fail(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));
} }
int custom_origin_name_remote_create( static int custom_origin_name_remote_create(
git_remote **out, git_remote **out,
git_repository *repo, git_repository *repo,
const char *name, const char *name,
......
...@@ -111,7 +111,7 @@ void test_commit_commit__create_initial_commit_parent_not_current(void) ...@@ -111,7 +111,7 @@ void test_commit_commit__create_initial_commit_parent_not_current(void)
git_signature_free(s); git_signature_free(s);
} }
void assert_commit_summary(const char *expected, const char *given) static void assert_commit_summary(const char *expected, const char *given)
{ {
git_commit *dummy; git_commit *dummy;
...@@ -123,7 +123,7 @@ void assert_commit_summary(const char *expected, const char *given) ...@@ -123,7 +123,7 @@ void assert_commit_summary(const char *expected, const char *given)
git_commit__free(dummy); git_commit__free(dummy);
} }
void assert_commit_body(const char *expected, const char *given) static void assert_commit_body(const char *expected, const char *given)
{ {
git_commit *dummy; git_commit *dummy;
......
...@@ -39,7 +39,7 @@ void test_config_stress__dont_break_on_invalid_input(void) ...@@ -39,7 +39,7 @@ void test_config_stress__dont_break_on_invalid_input(void)
git_config_free(config); git_config_free(config);
} }
void assert_config_value(git_config *config, const char *key, const char *value) static void assert_config_value(git_config *config, const char *key, const char *value)
{ {
git_buf_dispose(&buf); git_buf_dispose(&buf);
cl_git_pass(git_config_get_string_buf(&buf, config, key)); cl_git_pass(git_config_get_string_buf(&buf, config, key));
......
...@@ -45,7 +45,8 @@ void test_core_copy__file_in_dir(void) ...@@ -45,7 +45,8 @@ void test_core_copy__file_in_dir(void)
cl_assert(!git_fs_path_isdir("an_dir")); cl_assert(!git_fs_path_isdir("an_dir"));
} }
void assert_hard_link(const char *path) #ifndef GIT_WIN32
static void assert_hard_link(const char *path)
{ {
/* we assert this by checking that there's more than one link to the file */ /* we assert this by checking that there's more than one link to the file */
struct stat st; struct stat st;
...@@ -54,6 +55,7 @@ void assert_hard_link(const char *path) ...@@ -54,6 +55,7 @@ void assert_hard_link(const char *path)
cl_git_pass(p_stat(path, &st)); cl_git_pass(p_stat(path, &st));
cl_assert(st.st_nlink > 1); cl_assert(st.st_nlink > 1);
} }
#endif
void test_core_copy__tree(void) void test_core_copy__tree(void)
{ {
......
...@@ -17,7 +17,7 @@ void test_diff_binary__cleanup(void) ...@@ -17,7 +17,7 @@ void test_diff_binary__cleanup(void)
cl_git_sandbox_cleanup(); cl_git_sandbox_cleanup();
} }
void test_patch( static void test_patch(
const char *one, const char *one,
const char *two, const char *two,
const git_diff_options *opts, const git_diff_options *opts,
......
...@@ -938,7 +938,7 @@ struct rename_expected ...@@ -938,7 +938,7 @@ struct rename_expected
size_t idx; size_t idx;
}; };
int test_names_expected(const git_diff_delta *delta, float progress, void *p) static int test_names_expected(const git_diff_delta *delta, float progress, void *p)
{ {
struct rename_expected *expected = p; struct rename_expected *expected = p;
......
...@@ -320,7 +320,7 @@ void test_diff_tree__checks_options_version(void) ...@@ -320,7 +320,7 @@ void test_diff_tree__checks_options_version(void)
err = git_error_last(); err = git_error_last();
} }
void process_tree_to_tree_diffing( static void process_tree_to_tree_diffing(
const char *old_commit, const char *old_commit,
const char *new_commit) const char *new_commit)
{ {
......
...@@ -408,7 +408,7 @@ static bool found_master; ...@@ -408,7 +408,7 @@ static bool found_master;
static bool found_haacked; static bool found_haacked;
static bool find_master_haacked_called; static bool find_master_haacked_called;
int find_master_haacked(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload) static int find_master_haacked(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload)
{ {
GIT_UNUSED(remote_url); GIT_UNUSED(remote_url);
GIT_UNUSED(oid); GIT_UNUSED(oid);
...@@ -466,7 +466,7 @@ struct prefix_count { ...@@ -466,7 +466,7 @@ struct prefix_count {
int expected; int expected;
}; };
int count_refs(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload) static int count_refs(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload)
{ {
int i; int i;
struct prefix_count *prefix_counts = (struct prefix_count *) payload; struct prefix_count *prefix_counts = (struct prefix_count *) payload;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "posix.h" #include "posix.h"
#include "filter.h" #include "filter.h"
#include "git2/sys/filter.h" #include "git2/sys/filter.h"
#include "custom_helpers.h"
#define VERY_SECURE_ENCRYPTION(b) ((b) ^ 0xff) #define VERY_SECURE_ENCRYPTION(b) ((b) ^ 0xff)
...@@ -128,7 +129,7 @@ git_filter *create_reverse_filter(const char *attrs) ...@@ -128,7 +129,7 @@ git_filter *create_reverse_filter(const char *attrs)
return filter; return filter;
} }
int erroneous_filter_stream( static int erroneous_filter_stream(
git_writestream **out, git_writestream **out,
git_filter *self, git_filter *self,
void **payload, void **payload,
......
...@@ -55,19 +55,19 @@ struct buf_writestream { ...@@ -55,19 +55,19 @@ struct buf_writestream {
git_str buf; git_str buf;
}; };
int buf_writestream_write(git_writestream *s, const char *buf, size_t len) static int buf_writestream_write(git_writestream *s, const char *buf, size_t len)
{ {
struct buf_writestream *stream = (struct buf_writestream *)s; struct buf_writestream *stream = (struct buf_writestream *)s;
return git_str_put(&stream->buf, buf, len); return git_str_put(&stream->buf, buf, len);
} }
int buf_writestream_close(git_writestream *s) static int buf_writestream_close(git_writestream *s)
{ {
GIT_UNUSED(s); GIT_UNUSED(s);
return 0; return 0;
} }
void buf_writestream_free(git_writestream *s) static void buf_writestream_free(git_writestream *s)
{ {
struct buf_writestream *stream = (struct buf_writestream *)s; struct buf_writestream *stream = (struct buf_writestream *)s;
git_str_dispose(&stream->buf); git_str_dispose(&stream->buf);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
from __future__ import with_statement from __future__ import with_statement
from string import Template from string import Template
import re, fnmatch, os, sys, codecs, pickle import re, fnmatch, os, sys, codecs, pickle, io
class Module(object): class Module(object):
class Template(object): class Template(object):
...@@ -147,7 +147,7 @@ class TestSuite(object): ...@@ -147,7 +147,7 @@ class TestSuite(object):
self.path = path self.path = path
self.output = output self.output = output
def should_generate(self, path): def maybe_generate(self, path):
if not os.path.isfile(path): if not os.path.isfile(path):
return True return True
...@@ -216,33 +216,82 @@ class TestSuite(object): ...@@ -216,33 +216,82 @@ class TestSuite(object):
return sum(len(module.callbacks) for module in self.modules.values()) return sum(len(module.callbacks) for module in self.modules.values())
def write(self): def write(self):
output = os.path.join(self.output, 'clar.suite') wrote_suite = self.write_suite()
wrote_header = self.write_header()
if not self.should_generate(output): if wrote_suite or wrote_header:
self.save_cache()
return True
return False
def write_output(self, fn, data):
if not self.maybe_generate(fn):
return False return False
with open(output, 'w') as data: current = None
try:
with open(fn, 'r') as input:
current = input.read()
except OSError:
pass
except IOError:
pass
if current == data:
return False
with open(fn, 'w') as output:
output.write(data)
return True
def write_suite(self):
suite_fn = os.path.join(self.output, 'clar.suite')
with io.StringIO() as suite_file:
modules = sorted(self.modules.values(), key=lambda module: module.name) modules = sorted(self.modules.values(), key=lambda module: module.name)
for module in modules: for module in modules:
t = Module.DeclarationTemplate(module) t = Module.DeclarationTemplate(module)
data.write(t.render()) suite_file.write(t.render())
for module in modules: for module in modules:
t = Module.CallbacksTemplate(module) t = Module.CallbacksTemplate(module)
data.write(t.render()) suite_file.write(t.render())
suites = "static struct clar_suite _clar_suites[] = {" + ','.join( suites = "static struct clar_suite _clar_suites[] = {" + ','.join(
Module.InfoTemplate(module).render() for module in modules Module.InfoTemplate(module).render() for module in modules
) + "\n};\n" ) + "\n};\n"
data.write(suites) suite_file.write(suites)
data.write("static const size_t _clar_suite_count = %d;\n" % self.suite_count()) suite_file.write(u"static const size_t _clar_suite_count = %d;\n" % self.suite_count())
data.write("static const size_t _clar_callback_count = %d;\n" % self.callback_count()) suite_file.write(u"static const size_t _clar_callback_count = %d;\n" % self.callback_count())
self.save_cache() return self.write_output(suite_fn, suite_file.getvalue())
return True
return False
def write_header(self):
header_fn = os.path.join(self.output, 'clar_suite.h')
with io.StringIO() as header_file:
header_file.write(u"#ifndef _____clar_suite_h_____\n")
header_file.write(u"#define _____clar_suite_h_____\n")
modules = sorted(self.modules.values(), key=lambda module: module.name)
for module in modules:
t = Module.DeclarationTemplate(module)
header_file.write(t.render())
header_file.write(u"#endif\n")
return self.write_output(header_fn, header_file.getvalue())
return False
if __name__ == '__main__': if __name__ == '__main__':
from optparse import OptionParser from optparse import OptionParser
...@@ -263,5 +312,5 @@ if __name__ == '__main__': ...@@ -263,5 +312,5 @@ if __name__ == '__main__':
suite.load(options.force) suite.load(options.force)
suite.disable(options.excluded) suite.disable(options.excluded)
if suite.write(): if suite.write():
print("Written `clar.suite` (%d tests in %d suites)" % (suite.callback_count(), suite.suite_count())) print("Written `clar.suite`, `clar_suite.h` (%d tests in %d suites)" % (suite.callback_count(), suite.suite_count()))
...@@ -328,7 +328,7 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[], ...@@ -328,7 +328,7 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[],
return 1; return 1;
} }
int dircount(void *payload, git_str *pathbuf) static int dircount(void *payload, git_str *pathbuf)
{ {
size_t *entries = payload; size_t *entries = payload;
size_t len = git_str_len(pathbuf); size_t len = git_str_len(pathbuf);
......
...@@ -65,4 +65,8 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[], ...@@ -65,4 +65,8 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[],
int merge_test_workdir(git_repository *repo, const struct merge_index_entry expected[], size_t expected_len); int merge_test_workdir(git_repository *repo, const struct merge_index_entry expected[], size_t expected_len);
void merge__dump_names(git_index *index);
void merge__dump_index_entries(git_vector *index_entries);
void merge__dump_reuc(git_index *index);
#endif #endif
...@@ -108,7 +108,7 @@ void test_network_fetchlocal__prune(void) ...@@ -108,7 +108,7 @@ void test_network_fetchlocal__prune(void)
git_repository_free(repo); git_repository_free(repo);
} }
int update_tips_fail_on_call(const char *ref, const git_oid *old, const git_oid *new, void *data) static int update_tips_fail_on_call(const char *ref, const git_oid *old, const git_oid *new, void *data)
{ {
GIT_UNUSED(ref); GIT_UNUSED(ref);
GIT_UNUSED(old); GIT_UNUSED(old);
...@@ -119,7 +119,7 @@ int update_tips_fail_on_call(const char *ref, const git_oid *old, const git_oid ...@@ -119,7 +119,7 @@ int update_tips_fail_on_call(const char *ref, const git_oid *old, const git_oid
return 0; return 0;
} }
void assert_ref_exists(git_repository *repo, const char *name) static void assert_ref_exists(git_repository *repo, const char *name)
{ {
git_reference *ref; git_reference *ref;
......
...@@ -29,7 +29,7 @@ void test_network_remote_push__cleanup(void) ...@@ -29,7 +29,7 @@ void test_network_remote_push__cleanup(void)
cl_fixture_cleanup("dummy.git"); cl_fixture_cleanup("dummy.git");
} }
int negotiation_cb(const git_push_update **updates, size_t len, void *payload) static int negotiation_cb(const git_push_update **updates, size_t len, void *payload)
{ {
const git_push_update *expected = payload; const git_push_update *expected = payload;
...@@ -69,7 +69,7 @@ void test_network_remote_push__delete_notification(void) ...@@ -69,7 +69,7 @@ void test_network_remote_push__delete_notification(void)
} }
void create_dummy_commit(git_reference **out, git_repository *repo) static void create_dummy_commit(git_reference **out, git_repository *repo)
{ {
git_index *index; git_index *index;
git_oid tree_id, commit_id; git_oid tree_id, commit_id;
......
...@@ -103,7 +103,7 @@ static int note_list_create_cb( ...@@ -103,7 +103,7 @@ static int note_list_create_cb(
return 0; return 0;
} }
void assert_notes_seen(struct note_create_payload payload[], size_t n) static void assert_notes_seen(struct note_create_payload payload[], size_t n)
{ {
size_t seen = 0, i; size_t seen = 0, i;
......
...@@ -221,7 +221,7 @@ void test_object_tag_write__deleting_with_an_invalid_name_returns_EINVALIDSPEC(v ...@@ -221,7 +221,7 @@ void test_object_tag_write__deleting_with_an_invalid_name_returns_EINVALIDSPEC(v
cl_assert_equal_i(GIT_EINVALIDSPEC, git_tag_delete(g_repo, "Inv@{id")); cl_assert_equal_i(GIT_EINVALIDSPEC, git_tag_delete(g_repo, "Inv@{id"));
} }
void create_annotation(git_oid *tag_id, const char *name) static void create_annotation(git_oid *tag_id, const char *name)
{ {
git_object *target; git_object *target;
git_oid target_id; git_oid target_id;
......
...@@ -187,7 +187,7 @@ void test_odb_loose__read_header(void) ...@@ -187,7 +187,7 @@ void test_odb_loose__read_header(void)
test_read_header(&some); test_read_header(&some);
} }
void test_write_object_permission( static void test_write_object_permission(
mode_t dir_mode, mode_t file_mode, mode_t dir_mode, mode_t file_mode,
mode_t expected_dir_mode, mode_t expected_file_mode) mode_t expected_dir_mode, mode_t expected_file_mode)
{ {
...@@ -228,7 +228,7 @@ void test_odb_loose__permissions_standard(void) ...@@ -228,7 +228,7 @@ void test_odb_loose__permissions_standard(void)
test_write_object_permission(0, 0, GIT_OBJECT_DIR_MODE, GIT_OBJECT_FILE_MODE); test_write_object_permission(0, 0, GIT_OBJECT_DIR_MODE, GIT_OBJECT_FILE_MODE);
} }
void test_odb_loose_permissions_readonly(void) void test_odb_loose__permissions_readonly(void)
{ {
test_write_object_permission(0777, 0444, 0777, 0444); test_write_object_permission(0777, 0444, 0777, 0444);
} }
......
...@@ -361,7 +361,7 @@ void test_online_clone__cred_callback_called_again_on_auth_failure(void) ...@@ -361,7 +361,7 @@ void test_online_clone__cred_callback_called_again_on_auth_failure(void)
cl_assert_equal_i(3, counter); cl_assert_equal_i(3, counter);
} }
int cred_default( static int cred_default(
git_credential **cred, git_credential **cred,
const char *url, const char *url,
const char *user_from_url, const char *user_from_url,
...@@ -618,7 +618,7 @@ void test_online_clone__ssh_cannot_change_username(void) ...@@ -618,7 +618,7 @@ void test_online_clone__ssh_cannot_change_username(void)
cl_git_fail(git_clone(&g_repo, "ssh://git@github.com/libgit2/TestGitRepository", "./foo", &g_options)); cl_git_fail(git_clone(&g_repo, "ssh://git@github.com/libgit2/TestGitRepository", "./foo", &g_options));
} }
int ssh_certificate_check(git_cert *cert, int valid, const char *host, void *payload) static int ssh_certificate_check(git_cert *cert, int valid, const char *host, void *payload)
{ {
git_cert_hostkey *key; git_cert_hostkey *key;
git_oid expected = {{0}}, actual = {{0}}; git_oid expected = {{0}}, actual = {{0}};
......
...@@ -10,7 +10,7 @@ void updated_tip_free(updated_tip *t) ...@@ -10,7 +10,7 @@ void updated_tip_free(updated_tip *t)
git__free(t); git__free(t);
} }
void push_status_free(push_status *s) static void push_status_free(push_status *s)
{ {
git__free(s->ref); git__free(s->ref);
git__free(s->msg); git__free(s->msg);
......
...@@ -47,7 +47,7 @@ void test_pack_filelimit__cleanup(void) ...@@ -47,7 +47,7 @@ void test_pack_filelimit__cleanup(void)
* (README.md) has the same content in all commits, but the second one * (README.md) has the same content in all commits, but the second one
* (file.txt) has a different content in each commit. * (file.txt) has a different content in each commit.
*/ */
void create_packfile_commit( static void create_packfile_commit(
git_repository *repo, git_repository *repo,
git_oid *out_commit_id, git_oid *out_commit_id,
git_oid *parent_id, git_oid *parent_id,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* and then print a variety of patch files. * and then print a variety of patch files.
*/ */
void patch_print_from_patchfile(const char *data, size_t len) static void patch_print_from_patchfile(const char *data, size_t len)
{ {
git_patch *patch; git_patch *patch;
git_buf buf = GIT_BUF_INIT; git_buf buf = GIT_BUF_INIT;
......
...@@ -120,7 +120,7 @@ void test_path_dotgit__dotgit_modules_symlink(void) ...@@ -120,7 +120,7 @@ void test_path_dotgit__dotgit_modules_symlink(void)
cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS)); cl_assert_equal_b(false, git_path_is_valid(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
} }
void test_core_path__git_fs_path_is_file(void) void test_path_dotgit__git_fs_path_is_file(void)
{ {
cl_git_fail(git_path_is_gitfile("blob", 4, -1, GIT_PATH_FS_HFS)); cl_git_fail(git_path_is_gitfile("blob", 4, -1, GIT_PATH_FS_HFS));
cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITIGNORE, GIT_PATH_FS_HFS)); cl_git_pass(git_path_is_gitfile("blob", 4, GIT_PATH_GITFILE_GITIGNORE, GIT_PATH_FS_HFS));
......
...@@ -6,35 +6,27 @@ ...@@ -6,35 +6,27 @@
#include "win32/path_w32.h" #include "win32/path_w32.h"
#endif #endif
void test_utf8_to_utf16(const char *utf8_in, const wchar_t *utf16_expected)
{
#ifdef GIT_WIN32 #ifdef GIT_WIN32
static void test_utf8_to_utf16(const char *utf8_in, const wchar_t *utf16_expected)
{
git_win32_path path_utf16; git_win32_path path_utf16;
int path_utf16len; int path_utf16len;
cl_assert((path_utf16len = git_win32_path_from_utf8(path_utf16, utf8_in)) >= 0); cl_assert((path_utf16len = git_win32_path_from_utf8(path_utf16, utf8_in)) >= 0);
cl_assert_equal_wcs(utf16_expected, path_utf16); cl_assert_equal_wcs(utf16_expected, path_utf16);
cl_assert_equal_i(wcslen(utf16_expected), path_utf16len); cl_assert_equal_i(wcslen(utf16_expected), path_utf16len);
#else
GIT_UNUSED(utf8_in);
GIT_UNUSED(utf16_expected);
#endif
} }
void test_utf8_to_utf16_relative(const char* utf8_in, const wchar_t* utf16_expected) static void test_utf8_to_utf16_relative(const char* utf8_in, const wchar_t* utf16_expected)
{ {
#ifdef GIT_WIN32
git_win32_path path_utf16; git_win32_path path_utf16;
int path_utf16len; int path_utf16len;
cl_assert((path_utf16len = git_win32_path_relative_from_utf8(path_utf16, utf8_in)) >= 0); cl_assert((path_utf16len = git_win32_path_relative_from_utf8(path_utf16, utf8_in)) >= 0);
cl_assert_equal_wcs(utf16_expected, path_utf16); cl_assert_equal_wcs(utf16_expected, path_utf16);
cl_assert_equal_i(wcslen(utf16_expected), path_utf16len); cl_assert_equal_i(wcslen(utf16_expected), path_utf16len);
#else
GIT_UNUSED(utf8_in);
GIT_UNUSED(utf16_expected);
#endif
} }
#endif
void test_path_win32__utf8_to_utf16(void) void test_path_win32__utf8_to_utf16(void)
{ {
......
...@@ -47,7 +47,7 @@ static void test_operations(git_rebase *rebase, size_t expected_current) ...@@ -47,7 +47,7 @@ static void test_operations(git_rebase *rebase, size_t expected_current)
} }
} }
void test_iterator(bool inmemory) static void test_iterator(bool inmemory)
{ {
git_rebase *rebase; git_rebase *rebase;
git_rebase_options opts = GIT_REBASE_OPTIONS_INIT; git_rebase_options opts = GIT_REBASE_OPTIONS_INIT;
......
...@@ -729,7 +729,7 @@ void test_rebase_merge__copy_notes_disabled_in_config(void) ...@@ -729,7 +729,7 @@ void test_rebase_merge__copy_notes_disabled_in_config(void)
test_copy_note(NULL, 0); test_copy_note(NULL, 0);
} }
void rebase_checkout_progress_cb( static void rebase_checkout_progress_cb(
const char *path, const char *path,
size_t completed_steps, size_t completed_steps,
size_t total_steps, size_t total_steps,
......
...@@ -86,7 +86,7 @@ committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n"; ...@@ -86,7 +86,7 @@ committer Rebaser <rebaser@rebaser.rb> 1405694510 +0000\n";
git_rebase_free(rebase); git_rebase_free(rebase);
} }
int create_cb_signed_gpg( static int create_cb_signed_gpg(
git_oid *out, git_oid *out,
const git_signature *author, const git_signature *author,
const git_signature *committer, const git_signature *committer,
......
...@@ -51,7 +51,7 @@ static int name_is_valid(const char *name) ...@@ -51,7 +51,7 @@ static int name_is_valid(const char *name)
return valid; return valid;
} }
void test_refs_branches_is_name_valid(void) void test_refs_branches_name__is_name_valid(void)
{ {
cl_assert_equal_i(true, name_is_valid("master")); cl_assert_equal_i(true, name_is_valid("master"));
cl_assert_equal_i(true, name_is_valid("test/master")); cl_assert_equal_i(true, name_is_valid("test/master"));
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "common.h" #include "common.h"
#include "util.h" #include "util.h"
#include "path.h" #include "path.h"
#include "ref_helpers.h"
int reference_is_packed(git_reference *ref) int reference_is_packed(git_reference *ref)
{ {
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
#include "repository.h" #include "repository.h"
#include "reflog.h" #include "reflog.h"
#include "reflog_helpers.h"
static int reflog_entry_tostr(git_str *out, const git_reflog_entry *entry) int reflog_entry_tostr(git_str *out, const git_reflog_entry *entry)
{ {
char old_oid[GIT_OID_HEXSZ], new_oid[GIT_OID_HEXSZ]; char old_oid[GIT_OID_HEXSZ], new_oid[GIT_OID_HEXSZ];
......
size_t reflog_entrycount(git_repository *repo, const char *name); size_t reflog_entrycount(git_repository *repo, const char *name);
#define cl_reflog_check_entry(repo, reflog, idx, old_spec, new_spec, email, message) \ #define cl_reflog_check_entry(repo, reflog, idx, old_spec, new_spec, email, message) \
cl_reflog_check_entry_(repo, reflog, idx, old_spec, new_spec, email, message, __FILE__, __LINE__) cl_reflog_check_entry_(repo, reflog, idx, old_spec, new_spec, email, message, __FILE__, __FUNCTION__, __LINE__)
void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx, void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx,
const char *old_spec, const char *new_spec, const char *old_spec, const char *new_spec,
const char *email, const char *message, const char *file, int line); const char *email, const char *message,
const char *file, const char *func, int line);
void reflog_print(git_repository *repo, const char *reflog_name); void reflog_print(git_repository *repo, const char *reflog_name);
int reflog_entry_tostr(git_str *out, const git_reflog_entry *entry);
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "repository.h" #include "repository.h"
void assert_shorthand(git_repository *repo, const char *refname, const char *shorthand) static void assert_shorthand(git_repository *repo, const char *refname, const char *shorthand)
{ {
git_reference *ref; git_reference *ref;
......
...@@ -7,7 +7,7 @@ static int name_is_valid(const char *name) ...@@ -7,7 +7,7 @@ static int name_is_valid(const char *name)
return valid; return valid;
} }
void test_refs_tags_is_name_valid(void) void test_refs_tags_name__is_name_valid(void)
{ {
cl_assert_equal_i(true, name_is_valid("sometag")); cl_assert_equal_i(true, name_is_valid("sometag"));
cl_assert_equal_i(true, name_is_valid("test/sometag")); cl_assert_equal_i(true, name_is_valid("test/sometag"));
......
...@@ -62,7 +62,7 @@ void test_remote_fetch__cleanup(void) { ...@@ -62,7 +62,7 @@ void test_remote_fetch__cleanup(void) {
* @param force Whether to use a spec with '+' prefixed to force the refs * @param force Whether to use a spec with '+' prefixed to force the refs
* to update * to update
*/ */
void do_time_travelling_fetch(git_oid *commit1id, git_oid *commit2id, static void do_time_travelling_fetch(git_oid *commit1id, git_oid *commit2id,
bool force) { bool force) {
char *refspec_strs = { char *refspec_strs = {
force ? FORCE_FETCHSPEC : NON_FORCE_FETCHSPEC, force ? FORCE_FETCHSPEC : NON_FORCE_FETCHSPEC,
......
...@@ -40,7 +40,7 @@ void test_remote_httpproxy__cleanup(void) ...@@ -40,7 +40,7 @@ void test_remote_httpproxy__cleanup(void)
cl_git_sandbox_cleanup(); cl_git_sandbox_cleanup();
} }
void assert_proxy_is(const char *expected) static void assert_proxy_is(const char *expected)
{ {
git_remote *remote; git_remote *remote;
char *proxy; char *proxy;
...@@ -57,7 +57,7 @@ void assert_proxy_is(const char *expected) ...@@ -57,7 +57,7 @@ void assert_proxy_is(const char *expected)
git__free(proxy); git__free(proxy);
} }
void assert_config_match(const char *config, const char *expected) static void assert_config_match(const char *config, const char *expected)
{ {
git_remote *remote; git_remote *remote;
char *proxy; char *proxy;
...@@ -106,7 +106,7 @@ void test_remote_httpproxy__config_empty_overrides(void) ...@@ -106,7 +106,7 @@ void test_remote_httpproxy__config_empty_overrides(void)
assert_config_match("remote.lg2.proxy", ""); assert_config_match("remote.lg2.proxy", "");
} }
void assert_global_config_match(const char *config, const char *expected) static void assert_global_config_match(const char *config, const char *expected)
{ {
git_remote *remote; git_remote *remote;
char *proxy; char *proxy;
......
...@@ -316,7 +316,7 @@ struct seen_paths { ...@@ -316,7 +316,7 @@ struct seen_paths {
bool when; bool when;
}; };
int checkout_notify( static int checkout_notify(
git_checkout_notify_t why, git_checkout_notify_t why,
const char *path, const char *path,
const git_diff_file *baseline, const git_diff_file *baseline,
...@@ -368,7 +368,7 @@ void test_stash_apply__executes_notify_cb(void) ...@@ -368,7 +368,7 @@ void test_stash_apply__executes_notify_cb(void)
cl_assert_equal_b(true, seen_paths.when); cl_assert_equal_b(true, seen_paths.when);
} }
int progress_cb( static int progress_cb(
git_stash_apply_progress_t progress, git_stash_apply_progress_t progress,
void *payload) void *payload)
{ {
...@@ -393,7 +393,7 @@ void test_stash_apply__calls_progress_cb(void) ...@@ -393,7 +393,7 @@ void test_stash_apply__calls_progress_cb(void)
cl_assert_equal_i(progress, GIT_STASH_APPLY_PROGRESS_DONE); cl_assert_equal_i(progress, GIT_STASH_APPLY_PROGRESS_DONE);
} }
int aborting_progress_cb( static int aborting_progress_cb(
git_stash_apply_progress_t progress, git_stash_apply_progress_t progress,
void *payload) void *payload)
{ {
......
...@@ -140,7 +140,7 @@ void test_stash_drop__dropping_the_last_entry_removes_the_stash(void) ...@@ -140,7 +140,7 @@ void test_stash_drop__dropping_the_last_entry_removes_the_stash(void)
git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE), GIT_ENOTFOUND); git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE), GIT_ENOTFOUND);
} }
void retrieve_top_stash_id(git_oid *out) static void retrieve_top_stash_id(git_oid *out)
{ {
git_object *top_stash; git_object *top_stash;
......
...@@ -43,7 +43,7 @@ void test_status_worktree__whole_repository(void) ...@@ -43,7 +43,7 @@ void test_status_worktree__whole_repository(void)
cl_assert_equal_i(0, counts.wrong_sorted_path); cl_assert_equal_i(0, counts.wrong_sorted_path);
} }
void assert_show( static void assert_show(
const int entry_counts, const int entry_counts,
const char *entry_paths[], const char *entry_paths[],
const unsigned int entry_statuses[], const unsigned int entry_statuses[],
......
...@@ -128,7 +128,7 @@ void test_submodule_modify__sync(void) ...@@ -128,7 +128,7 @@ void test_submodule_modify__sync(void)
git_submodule_free(sm3); git_submodule_free(sm3);
} }
void assert_ignore_change(git_submodule_ignore_t ignore) static void assert_ignore_change(git_submodule_ignore_t ignore)
{ {
git_submodule *sm; git_submodule *sm;
...@@ -146,7 +146,7 @@ void test_submodule_modify__set_ignore(void) ...@@ -146,7 +146,7 @@ void test_submodule_modify__set_ignore(void)
assert_ignore_change(GIT_SUBMODULE_IGNORE_ALL); assert_ignore_change(GIT_SUBMODULE_IGNORE_ALL);
} }
void assert_update_change(git_submodule_update_t update) static void assert_update_change(git_submodule_update_t update)
{ {
git_submodule *sm; git_submodule *sm;
...@@ -164,7 +164,7 @@ void test_submodule_modify__set_update(void) ...@@ -164,7 +164,7 @@ void test_submodule_modify__set_update(void)
assert_update_change(GIT_SUBMODULE_UPDATE_CHECKOUT); assert_update_change(GIT_SUBMODULE_UPDATE_CHECKOUT);
} }
void assert_recurse_change(git_submodule_recurse_t recurse) static void assert_recurse_change(git_submodule_recurse_t recurse)
{ {
git_submodule *sm; git_submodule *sm;
......
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