forked from tvondra/distinct_estimators
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
68 lines (57 loc) · 2.09 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
EXTENSION = hyperloglog_counter
MODULE_big = $(EXTENSION)
OBJS = $(patsubst %.c,%.o,$(wildcard src/*.c))
DATA = sql/greenplum.sql sql/postgres.sql
MODULES = $(EXTENSION)
TEST_VERSION := $(shell psql -tAc "select case when lower(version()) like '%greenplum%' then 'gp' else 'pg' end")
OUT_DIR = test/expected
SQL_DIR = test/sql
PSQL = psql
PSQLOPTS = -X --echo-all -P null=NULL
PGOPTIONS = --client-min-messages=warning
GLOBAL_BASE_TEST = set_ops operators
ifeq ($(TEST_VERSION),gp)
BASE_TEST = gp_base $(GLOBAL_BASE_TEST) gp_persistence gp_update gp_aggs gp_compression
else
BASE_TEST = base $(GLOBAL_BASE_TEST) update aggs compression
endif
TEST = $(foreach test,$(BASE_TEST),$(SQL_DIR)/$(test).out)
TESTS = $(foreach test,$(BASE_TEST),$(SQL_DIR)/$(test).sql)
REGRESS = $(patsubst $(SQL_DIR)%,%,$(TESTS))
REGRESS_OPTS = -X --echo-all -P null=NULL
PG_CONFIG ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
ifeq ($(with_llvm), yes)
COMPILE.c.bc = $(CLANG) -Wno-ignored-attributes $(BITCODE_CFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c
%.bc : src/%.c
$(COMPILE.c.bc) -o $@ $<
endif
tests: clean_test $(TEST)
@find $(SQL_DIR) -maxdepth 1 -name '*.diff' -print >> failures
@find $(SQL_DIR) -maxdepth 1 -name '*.out' -print >> test_cases
@if test -s failures; then \
echo ERROR: `cat failures | wc -l` / `cat test_cases | wc -l` tests failed; \
echo; \
rm -f failures test_cases; \
exit 1; \
else \
echo `cat test_cases | wc -l` / `cat test_cases | wc -l` tests passed; \
rm -f failures test_cases; \
fi
%.out:
@echo $*
@if test -f ../testdata/$*.csv; then \
PGOPTIONS=$(PGOPTIONS) $(PSQL) $(PSQLOPTS) -f $*.sql < ../testdata/$*.csv > $*.out 2>&1; \
else \
PGOPTIONS=$(PGOPTIONS) $(PSQL) $(PSQLOPTS) -f $*.sql >> $*.out 2>&1; \
fi
@diff -u $*.ref $*.out >> $*.diff || status=1
@if test -s $*.diff; then \
echo " .. FAIL"; \
else \
echo " .. PASS"; \
rm -f $*.diff; \
fi
clean_test:
rm -f $(SQL_DIR)/*.out $(SQL_DIR)/*.diff failures test_cases