remove cyclic subpackage dependencies

This commit is contained in:
John Kerl 2015-09-23 20:24:39 -04:00
parent b52935be04
commit 80910d0e69
19 changed files with 78 additions and 96 deletions

1
.gitignore vendored
View file

@ -12,6 +12,7 @@ test-parse-trie
test-lrec
test-multiple-containers
test-lrec-evaluators
test_lrec_evaluators
test-join-bucket-keeper
termcvt
a.out

View file

@ -1,10 +1,25 @@
SUBDIRS= lib cli stream input mapping output containers dsls experimental tools . test
SUBDIRS= lib cli stream input mapping output containers dsls experimental tools . test
AM_CPPFLAGS= -I${srcdir}
AM_CFLAGS= -Wall -Werror -std=gnu99 -O3
bin_PROGRAMS= mlr
noinst_PROGRAMS= mlrg mlrp
noinst_PROGRAMS= mlrg \
mlrp
TESTS= $(check_PROGRAMS)
check_PROGRAMS = test_mlrutil \
test_argparse \
test_byte_readers \
test_peek_file_reader \
test_parse_trie \
test_lrec \
test_multiple_containers \
test_string_builder \
test_lrec_evaluators \
test_join_bucket_keeper
mlr_SOURCES= mlrmain.c
mlr_LDADD= \
cli/libcli.la \
containers/libcontainers.la \
@ -32,6 +47,48 @@ mlrp_CFLAGS= -std=gnu99 -g -pg
mlrp_LDADD= ${mlr_LDADD}
mlrp_SOURCES= ${mlr_SOURCES}
# Unit-test mains
test_mlrutil_CFLAGS= -std=gnu99 -g
test_mlrutil_LDADD= ${mlr_LDADD}
test_mlrutil_SOURCES= utmains/test_mlrutil.c
test_argparse_CFLAGS= -std=gnu99 -g
test_argparse_LDADD= ${mlr_LDADD}
test_argparse_SOURCES= utmains/test_argparse.c
test_byte_readers_CFLAGS= -std=gnu99 -g
test_byte_readers_LDADD= ${mlr_LDADD}
test_byte_readers_SOURCES= utmains/test_byte_readers.c
test_peek_file_reader_CFLAGS= -std=gnu99 -g
test_peek_file_reader_LDADD= ${mlr_LDADD}
test_peek_file_reader_SOURCES= utmains/test_peek_file_reader.c
test_parse_trie_CFLAGS= -std=gnu99 -g
test_parse_trie_LDADD= ${mlr_LDADD}
test_parse_trie_SOURCES= utmains/test_parse_trie.c
test_lrec_CFLAGS= -std=gnu99 -g
test_lrec_LDADD= ${mlr_LDADD}
test_lrec_SOURCES= utmains/test_lrec.c
test_multiple_containers_CFLAGS= -std=gnu99 -g
test_multiple_containers_LDADD= ${mlr_LDADD}
test_multiple_containers_SOURCES= utmains/test_multiple_containers.c
test_string_builder_CFLAGS= -std=gnu99 -g
test_string_builder_LDADD= ${mlr_LDADD}
test_string_builder_SOURCES= utmains/test_string_builder.c
test_lrec_evaluators_CFLAGS= -std=gnu99 -g
test_lrec_evaluators_LDADD= ${mlr_LDADD}
test_lrec_evaluators_SOURCES= utmains/test_lrec_evaluators.c
test_join_bucket_keeper_CFLAGS= -std=gnu99 -g
test_join_bucket_keeper_LDADD= ${mlr_LDADD}
test_join_bucket_keeper_SOURCES= utmains/test_join_bucket_keeper.c
# ================================================================
# Run this after unit-test expected output has changed, and is verified to be
# OK. (Example: after adding new test cases in test/run.)
regtest-copy:

View file

@ -33,10 +33,10 @@ FDSL_OBJS = ./dsls/filter_dsl_parse.o ./dsls/filter_dsl_lexer.o ./dsls/filter_ds
TEST_ARGPARSE_SRCS = \
lib/mlrutil.c \
lib/mlr_globals.c \
cli/argparse.c \
containers/slls.c \
containers/sllv.c \
cli/argparse.c \
cli/test_argparse.c
utmains/test_argparse.c
TEST_BYTE_READERS_SRCS = \
lib/mlrutil.c \
@ -45,7 +45,7 @@ lib/mlr_globals.c \
input/string_byte_reader.c \
input/stdio_byte_reader.c \
input/mmap_byte_reader.c \
input/test_byte_readers.c
utmains/test_byte_readers.c
TEST_PEEK_FILE_READER_SRCS = \
lib/mlrutil.c \
@ -53,7 +53,7 @@ lib/mlr_test_util.c \
lib/mlr_globals.c \
input/string_byte_reader.c \
input/peek_file_reader.c \
input/test_peek_file_reader.c
utmains/test_peek_file_reader.c
TEST_LREC_SRCS = lib/mlrutil.c lib/mlr_globals.c lib/string_builder.c \
containers/lrec.c containers/header_keeper.c containers/sllv.c \
@ -64,7 +64,7 @@ input/lrec_reader_mmap_csvlite.c input/lrec_reader_stdio_csvlite.c \
input/lrec_reader_mmap_dkvp.c input/lrec_reader_stdio_dkvp.c \
input/lrec_reader_mmap_nidx.c input/lrec_reader_stdio_nidx.c \
input/lrec_reader_mmap_xtab.c input/lrec_reader_stdio_xtab.c \
containers/test_lrec.c
utmains/test_lrec.c
TEST_MULTIPLE_CONTAINERS_SRCS = lib/mlrutil.c lib/mlr_globals.c lib/string_builder.c \
containers/lrec.c containers/header_keeper.c containers/sllv.c \
@ -84,7 +84,7 @@ input/lrec_reader_mmap_csvlite.c input/lrec_reader_stdio_csvlite.c \
input/lrec_reader_mmap_dkvp.c input/lrec_reader_stdio_dkvp.c \
input/lrec_reader_mmap_nidx.c input/lrec_reader_stdio_nidx.c \
input/lrec_reader_mmap_xtab.c input/lrec_reader_stdio_xtab.c \
containers/test_multiple_containers.c
utmains/test_multiple_containers.c
TEST_LREC_EVALUATORS_SRCS = \
lib/mlr_globals.c \
@ -116,7 +116,7 @@ input/lrec_reader_mmap_nidx.c input/lrec_reader_stdio_nidx.c \
input/lrec_reader_mmap_xtab.c input/lrec_reader_stdio_xtab.c \
input/file_reader_mmap.c input/file_reader_stdio.c \
input/peek_file_reader.c \
containers/test_join_bucket_keeper.c
utmains/test_join_bucket_keeper.c
EXPERIMENTAL_READER_SRCS = \
lib/mlrutil.c \
@ -216,13 +216,13 @@ test-multiple-containers: .always
$(CCDEBUG) -D__TEST_MULTIPLE_CONTAINERS_MAIN__ $(TEST_MULTIPLE_CONTAINERS_SRCS) -o test-multiple-containers
test-mlrutil: .always
$(CCDEBUG) -D__TEST_MLRUTIL_MAIN__ lib/mlrutil.c lib/test_mlrutil.c -o test-mlrutil
$(CCDEBUG) -D__TEST_MLRUTIL_MAIN__ lib/mlrutil.c utmains/test_mlrutil.c -o test-mlrutil
test-string-builder: .always
$(CCDEBUG) -D__TEST_STRING_BUILDER_MAIN__ lib/mlrutil.c lib/mlr_globals.c lib/string_builder.c lib/test_string_builder.c -o test-string-builder
$(CCDEBUG) -D__TEST_STRING_BUILDER_MAIN__ lib/mlrutil.c lib/mlr_globals.c lib/string_builder.c utmains/test_string_builder.c -o test-string-builder
test-parse-trie: .always
$(CCDEBUG) -D__TEST_PARSE_TRIE_MAIN__ lib/mlrutil.c lib/mlr_globals.c containers/parse_trie.c containers/test_parse_trie.c -o test-parse-trie
$(CCDEBUG) -D__TEST_PARSE_TRIE_MAIN__ lib/mlrutil.c lib/mlr_globals.c containers/parse_trie.c utmains/test_parse_trie.c -o test-parse-trie
test-lrec-evaluators: .always
$(CCDEBUG) -D__TEST_LREC_EVALUATORS_MAIN__ $(TEST_LREC_EVALUATORS_SRCS) -o test-lrec-evaluators -lm

View file

@ -4,9 +4,6 @@ libcli_la_SOURCES= \
argparse.h \
mlrcli.c \
mlrcli.h
libcli_la_LIBADD= \
../lib/libmlr.la
../containers/libcontainers.la
# TODO: causes circular dependency
#noinst_PROGRAMS= ap
@ -14,13 +11,5 @@ libcli_la_LIBADD= \
#ap_LDADD= ../containers/libcontainers.la ../lib/libmlr.la
#ap_SOURCES= argparse.c
TESTS= $(check_PROGRAMS)
check_PROGRAMS= test_argparse
test_argparse_CPPFLAGS= -D__TEST_ARGPARSE_MAIN__ ${AM_CPPFLAGS}
test_argparse_LDADD= ../lib/libmlr.la \
../containers/libcontainers.la \
libcli.la
AM_CPPFLAGS= -I${srcdir}/../
AM_CFLAGS= -std=gnu99

View file

@ -38,27 +38,5 @@ libcontainers_la_LIBADD= \
../lib/libmlr.la \
../mapping/libmapping.la
TESTS= $(check_PROGRAMS)
check_PROGRAMS= test_join_bucket_keeper test_lrec test_multiple_containers test_parse_trie
test_join_bucket_keeper_CPPFLAGS= -D__TEST_JOIN_BUCKET_KEEPER_MAIN__ ${AM_CPPFLAGS}
test_join_bucket_keeper_LDADD= ../input/libinput.la \
../mapping/libmapping.la \
../lib/libmlr.la \
libcontainers.la
test_lrec_CPPFLAGS= -D__TEST_LREC_MAIN__ ${AM_CPPFLAGS}
test_lrec_LDADD= ../input/libinput.la \
../lib/libmlr.la \
libcontainers.la
test_multiple_containers_CPPFLAGS= -D__TEST_MULTIPLE_CONTAINERS_MAIN__ ${AM_CPPFLAGS}
test_multiple_containers_LDADD= ../input/libinput.la \
../lib/libmlr.la \
libcontainers.la
test_parse_trie_CPPFLAGS= -D__TEST_PARSE_TRIE_MAIN__ ${AM_CPPFLAGS}
test_parse_trie_LDADD= libcontainers.la
AM_CPPFLAGS= -I${srcdir}/../
AM_CFLAGS= -std=gnu99

View file

@ -29,23 +29,5 @@ libinput_la_SOURCES= \
libinput_la_LIBADD= ../lib/libmlr.la
libinput_la_CPPFLAGS= -I${srcdir}/../
TESTS= $(check_PROGRAMS)
check_PROGRAMS= test_byte_readers test_peek_file_reader
# TODO: replace the interesting content with unit tests; jettison the rest
# TODO: causes circular dependency
#noinst_PROGRAMS= lrim
#lrim_SOURCES= lrec_reader_in_memory.c
#lrim_CPPFLAGS= -D__LREC_READER_IN_MEMORY_MAIN__ ${AM_CPPFLAGS}
#lrim_LDADD= ../containers/libcontainers.la ../lib/libmlr.la # -lm
test_byte_readers_CPPFLAGS= -D__TEST_BYTE_READERS_MAIN__ ${AM_CPPFLAGS}
test_byte_readers_LDADD= libinput.la \
../lib/libmlr.la
test_peek_file_reader_CPPFLAGS= -D__TEST_PEEK_FILE_READER_MAIN__ ${AM_CPPFLAGS}
test_peek_file_reader_LDADD= libinput.la
AM_CPPFLAGS= -I${srcdir}/../
AM_CFLAGS= -std=gnu99

View file

@ -17,15 +17,5 @@ libmlr_la_SOURCES= minunit.h \
mlr_test_util.c \
mlr_test_util.h
TESTS= $(check_PROGRAMS)
check_PROGRAMS= test_mlrutil test_string_builder
test_mlrutil_LDADD= libmlr.la
test_mlrutil_CPPFLAGS= -D__TEST_MLRUTIL_MAIN__ ${AM_CPPFLAGS}
test_string_builder_LDADD= libmlr.la
test_string_builder_CPPFLAGS= -D__TEST_STRING_BUILDER_MAIN__ ${AM_CPPFLAGS}
AM_CPPFLAGS= -I${srcdir}/../
AM_CFLAGS= -std=gnu99

View file

@ -1138,8 +1138,6 @@ lrec_evaluator_t* lrec_evaluator_alloc_from_ast(mlr_dsl_ast_node_t* pnode) {
}
// ================================================================
#ifdef __TEST_LREC_EVALUATORS_MAIN__
#include "lib/minunit.h"
// ----------------------------------------------------------------
@ -1333,7 +1331,7 @@ static char * all_tests() {
return 0;
}
int main(int argc, char **argv) {
int test_lrec_evaluators_main(int argc, char **argv) {
mlr_global_init(argv[0], "%lf", NULL);
printf("TEST_LREC_EVALUATORS ENTER\n");
@ -1350,5 +1348,3 @@ int main(int argc, char **argv) {
return result != 0;
}
#endif // __TEST_LREC_EVALUATORS_MAIN__

View file

@ -9,4 +9,6 @@ void lrec_evaluator_list_functions(FILE* output_stream);
// Pass function_name == NULL to get usage for all functions:
void lrec_evaluator_function_usage(FILE* output_stream, char* function_name);
int test_lrec_evaluators_main(int argc, char **argv);
#endif // LREC_FEVALUATORS_H

View file

@ -4,7 +4,6 @@
#include "lib/mlrutil.h"
#include "cli/argparse.h"
#ifdef __TEST_ARGPARSE_MAIN__
int tests_run = 0;
int tests_failed = 0;
int assertions_run = 0;
@ -135,4 +134,3 @@ int main(int argc, char **argv) {
return result != 0;
}
#endif // __TEST_ARGPARSE_MAIN__

View file

@ -6,7 +6,6 @@
#include "lib/mlr_test_util.h"
#include "input/byte_readers.h"
#ifdef __TEST_BYTE_READERS_MAIN__
int tests_run = 0;
int tests_failed = 0;
int assertions_run = 0;
@ -211,4 +210,3 @@ int main(int argc, char **argv) {
return result != 0;
}
#endif // __TEST_BYTE_READERS_MAIN__

View file

@ -8,7 +8,6 @@
#include "containers/join_bucket_keeper.h"
#include "containers/mixutil.h"
#ifdef __TEST_JOIN_BUCKET_KEEPER_MAIN__
int tests_run = 0;
int tests_failed = 0;
int assertions_run = 0;
@ -444,4 +443,3 @@ int main(int argc, char **argv) {
return result != 0;
}
#endif // __TEST_JOIN_BUCKET_KEEPER_MAIN__

View file

@ -6,7 +6,6 @@
#include "containers/sllv.h"
#include "input/lrec_readers.h"
#ifdef __TEST_LREC_MAIN__
int tests_run = 0;
int tests_failed = 0;
int assertions_run = 0;
@ -273,4 +272,3 @@ int main(int argc, char **argv) {
return result != 0;
}
#endif // __TEST_LREC_MAIN__

View file

@ -0,0 +1,5 @@
#include "mapping/lrec_evaluators.h"
int main(int argc, char **argv) {
return test_lrec_evaluators_main(argc, argv);
}

View file

@ -3,7 +3,6 @@
#include "lib/minunit.h"
#include "lib/mlrutil.h"
#ifdef __TEST_MLRUTIL_MAIN__
int tests_run = 0;
int tests_failed = 0;
int assertions_run = 0;
@ -151,4 +150,3 @@ int main(int argc, char **argv) {
return result != 0;
}
#endif // __TEST_MLRUTIL_MAIN__

View file

@ -14,7 +14,6 @@
#include "containers/top_keeper.h"
#include "containers/dheap.h"
#ifdef __TEST_MULTIPLE_CONTAINERS_MAIN__
int tests_run = 0;
int tests_failed = 0;
int assertions_run = 0;
@ -656,4 +655,3 @@ int main(int argc, char **argv) {
return result != 0;
}
#endif // __TEST_MULTIPLE_CONTAINERS_MAIN__

View file

@ -5,7 +5,6 @@
#include "lib/mlrutil.h"
#include "containers/parse_trie.h"
#ifdef __TEST_PARSE_TRIE_MAIN__
int tests_run = 0;
int tests_failed = 0;
int assertions_run = 0;
@ -266,4 +265,3 @@ int main(int argc, char** argv) {
return result != 0;
}
#endif // __TEST_PARSE_TRIE_MAIN__

View file

@ -7,7 +7,6 @@
#include "input/byte_readers.h"
#include "input/peek_file_reader.h"
#ifdef __TEST_PEEK_FILE_READER_MAIN__
int tests_run = 0;
int tests_failed = 0;
int assertions_run = 0;
@ -88,4 +87,3 @@ int main(int argc, char **argv) {
return result != 0;
}
#endif // __TEST_PEEK_FILE_READER_MAIN__

View file

@ -4,7 +4,6 @@
#include "lib/mlrutil.h"
#include "lib/string_builder.h"
#ifdef __TEST_STRING_BUILDER_MAIN__
int tests_run = 0;
int tests_failed = 0;
int assertions_run = 0;
@ -92,4 +91,3 @@ int main(int argc, char **argv) {
return result != 0;
}
#endif // __TEST_STRING_BUILDER_MAIN__