diff options
author | EuAndreh <eu@euandre.org> | 2021-02-19 17:04:10 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-02-19 17:04:10 -0300 |
commit | be60ec35865a5a2352c8e96de58a86519f348189 (patch) | |
tree | bc55f94294fd8f30f98dbc6e9527b76c664c4c4e | |
parent | report.sh: Remove set -x option (diff) | |
download | remembering-be60ec35865a5a2352c8e96de58a86519f348189.tar.gz remembering-be60ec35865a5a2352c8e96de58a86519f348189.tar.xz |
Makefile.in: Simplify build/tests of C code
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Makefile.in | 54 | ||||
-rw-r--r-- | src/remembering.c | 20 |
3 files changed, 41 insertions, 39 deletions
@@ -2,6 +2,6 @@ /tests/test-profiles/ /Makefile /remembering -*.t -*.t-fallible -fallible-* +/remembering-c +/run-tests +/fallible* diff --git a/Makefile.in b/Makefile.in index 04c5110..7e0379e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ .POSIX: CC = c99 -CFLAGS = -std=c99 -Wall -Wextra -Wpedantic +CFLAGS = -std=c99 -Wall -Wextra -Wpedantic -DVERSION='"$(VERSION)"' -DDATE='"$(DATE)"' LDFLAGS = LDLIBS = PREFIX = @PREFIX@ @@ -8,40 +8,30 @@ MANPREFIX = $(PREFIX)/share/man VERSION = @VERSION@ DATE = @DATE@ -headers = \ - src/vendor/sharedc/testing.h - -sources = \ - src/remembering.c +sources = src/remembering.c manpages = \ doc/remembering.1 \ doc/remembering.5 -.SUFFIXES: .c .o .t .t-fallible - -.c.o: - $(CC) -c $(CFLAGS) $(LDFLAGS) - -.c.t: - $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -o $@ $< $(LDLIBS) - -.c.t-fallible: - $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -DFALLIBLE -o $@ $< $(LDLIBS) -lfallible - -objects = $(sources:.c=.o) -tests = $(sources:.c=.t) -fallible-tests = $(sources:.c=.t-fallible) - -all: $(tests) remembering +all: remembering remembering-c run-tests remembering: src/remembering.in $(do_subst) < $? > $@-t chmod +x $@-t mv $@-t $@ +remembering-c: $(sources) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(sources) $(LDLIBS) + +run-tests: $(sources) + $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -o $@ $(sources) $(LDLIBS) + +fallible-tests: $(sources) + $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -DFALLIBLE -o $@ $(sources) $(LDLIBS) + check: all - for t in $(tests); do echo $$t && ./$$t; done + ./run-tests sh tests/cli-opts.sh sh tests/ranking.sh sh tests/signals.sh @@ -50,8 +40,16 @@ check: all $(MAKE) dev-check; \ fi -dev-check: $(fallible-tests) - for t in $(fallible-tests); do fallible-check ./$$t; done +VALGRIND_FLAGS= \ + --show-error-list=yes \ + --show-leak-kinds=all \ + --leak-check=full \ + --track-origins=yes \ + --error-exitcode=1 + +dev-check: run-tests fallible-tests + valgrind $(VALGRIND_FLAGS) ./run-tests + fallible-check ./fallible-tests sh aux/assert-clang-format.sh sh aux/assert-shellcheck.sh sh aux/workflow/assert-todos.sh @@ -70,7 +68,7 @@ dist: git tag v$(VERSION) clean: - rm -rf public/ tests/test-profiles/ remembering $(tests) $(fallible-tests) + rm -rf public/ tests/test-profiles/ remembering remembering-c run-tests fallible* vgcore* do_subst = sed \ -e 's:[@]VERSION[@]:$(VERSION):g' \ @@ -85,9 +83,7 @@ install: all done uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/remembering \ - $(DESTDIR)$(MANPREFIX)/man1/remembering.1 \ - $(DESTDIR)$(MANPREFIX)/man5/remembering.5 + rm -f $(DESTDIR)$(PREFIX)/bin/remembering for m in $(manpages); do rm -f $(DESTDIR)$(MANPREFIX)/man$${##*.}/`basename $$m`.gz; done NAME_UC = Remembering diff --git a/src/remembering.c b/src/remembering.c index 22784d9..6907021 100644 --- a/src/remembering.c +++ b/src/remembering.c @@ -2,17 +2,19 @@ #define _POSIX_C_SOURCE 200809L #endif +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +// #include <tuple.h> + /* -#include "vendor/tuple.h" #include "vendor/vector.h" #include <assert.h> #include <libgen.h> #include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #include <sys/stat.h> -#include <unistd.h> +*/ static void print_usage(FILE *stream, char *given_name) { char *name = "remembering"; @@ -39,6 +41,7 @@ static void print_missing(FILE *stream, char *text) { fprintf(stream, "Missing option: %s\n", text); } +/* static struct Tuple *get_options(int argc, char *argv[]) { for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], "--help")) { @@ -64,7 +67,7 @@ static struct Tuple *get_options(int argc, char *argv[]) { print_help(stdout); exit(0); case 'V': - fprintf(stdout, "remembering-%s\n", VERSION); + fprintf(stdout, "remembering-%s %s\n", VERSION, DATE); exit(0); } } @@ -97,6 +100,9 @@ static struct Tuple *get_options(int argc, char *argv[]) { return options; } +*/ + +/* static char *expand_profile_name(char *profile_name) { char *prefix = NULL; @@ -286,7 +292,7 @@ static void test_rankings() { } #endif -/* +/ * struct GetlineParams { char *line; |