-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
153 lines (119 loc) · 4.2 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# This is a GNU-make file made for
# automatic testing to validate the
# pdb_file_statistics script.
MAKEFLAGS = -r
.PHONY: all display
SCRIPT_DIR = \.
all:
display:
@echo ${${VAR}}
# Declaring variables.
TEST_DIR = tests
TEST_CASE_DIR = ${TEST_DIR}/cases
TEST_DIFF_DIR = ${TEST_DIR}/outputs
TEST_OUTP_DIR = ${TEST_DIR}/outputs
TEST_CASE_PDB_INPUTS = $(wildcard ${TEST_CASE_DIR}/*.pdb)
TEST_CASE_CIF_INPUTS = $(wildcard ${TEST_CASE_DIR}/*.cif)
TEST_CASE_DIR_INPUTS = $(wildcard ${TEST_CASE_DIR}/*.dir)
TEST_CIF_OUTPS =\
$(sort $(TEST_CASE_CIF_INPUTS:${TEST_CASE_DIR}/%.cif=\
$(TEST_OUTP_DIR)/%.cifout))
TEST_PDB_OUTPS =\
$(sort $(TEST_CASE_PDB_INPUTS:${TEST_CASE_DIR}/%.pdb=\
$(TEST_OUTP_DIR)/%.pdbout))
TEST_DIR_OUTPS =\
$(sort $(TEST_CASE_DIR_INPUTS:${TEST_CASE_DIR}/%.dir=\
$(TEST_OUTP_DIR)/%.dirout))
TEST_CIF_DIFFS =\
$(sort $(TEST_CASE_CIF_INPUTS:${TEST_CASE_DIR}/%.cif=\
$(TEST_DIFF_DIR)/%.cifdiff))
TEST_PDB_DIFFS =\
$(sort $(TEST_CASE_PDB_INPUTS:${TEST_CASE_DIR}/%.pdb=\
$(TEST_DIFF_DIR)/%.pdbdiff))
TEST_DIR_DIFFS =\
$(sort $(TEST_CASE_DIR_INPUTS:${TEST_CASE_DIR}/%.dir=\
$(TEST_DIFF_DIR)/%.dirdiff))
# Section for test dependencies.
TEST_DEPENDENCIES = .test_depend
include ${TEST_DEPENDENCIES}
${TEST_DEPENDENCIES}: .pdb_depend .cif_depend .dir_depend
@cat $^ > $@
.pdb_depend: ${TEST_CASE_PDB_INPUTS}
@find tests/cases/ -name "*.pdb" \
| sed 's|/cases/|outputs/|; s|\.pdb$$|\.pdbdiff|' \
| awk '{ \
pgm = $$1; \
sub("${TEST_OUTP_DIR}/","",pgm); \
sub("_[0-9]*[a-z]\..*$$","",pgm); \
print $$1 ": " "${SCRIPT_DIR}/"pgm".pl" \
}' \
| sort\
> $@
.cif_depend: ${TEST_CASE_CIF_INPUTS}
@find tests/cases/ -name "*.cif" \
| sed 's|/cases/|outputs/|; s|\.cif$$|\.cifdiff|' \
| awk '{ \
pgm = $$1; \
sub("${TEST_OUTP_DIR}/","",pgm); \
sub("_[0-9]*[a-z]\..*$$","",pgm); \
print $$1 ": " "${SCRIPT_DIR}/"pgm".pl" \
}' \
| sort \
> $@
.dir_depend: ${TEST_CASE_DIR_INPUTS}
@find tests/cases/ -name "*.dir" \
| sed 's|/cases/|outputs/|; s|\.dir$$|\.dirdiff|' \
| awk '{ \
pgm = $$1; \
sub("${TEST_OUTP_DIR}/","",pgm); \
sub("_[0-9]*[a-z]\..*$$","",pgm); \
print $$1 ": " "${SCRIPT_DIR}/"pgm".pl" \
}' \
| sort \
> $@
# Make targets with dependencies and recipes.
# Because there are 3 possible ways of parsing
# files into this program, there will be three
# kinds of tests for each type of given
# file format: directory, PDB and CIF files.
.PHONY: test test_cif test_pdb test_dir
test: test_cif test_pdb test_dir
test_cif: ${TEST_CIF_OUTPS} ${TEST_CIF_DIFFS}
test_pdb: ${TEST_PDB_OUTPS} ${TEST_PDB_DIFFS}
test_dir: ${TEST_DIR_OUTPS} ${TEST_DIR_DIFFS}
# Generating output files with the .cifout,
# .pdbout and .dirout extensions.
${TEST_OUTP_DIR}/%.cifout:
@${SCRIPT_DIR}/$(shell echo $* | sed 's/\(.*\)_[0-9]*[a-z]/\1\.pl/') \
$(shell echo -cif) ${TEST_CASE_DIR}/$*.cif > $@
${TEST_OUTP_DIR}/%.pdbout:
@${SCRIPT_DIR}/$(shell echo $* | sed 's/\(.*\)_[0-9]*[a-z]/\1\.pl/') \
$(shell echo -pdb) ${TEST_CASE_DIR}/$*.pdb > $@
${TEST_OUTP_DIR}/%.dirout:
@${SCRIPT_DIR}/$(shell echo $* | sed 's/\(.*\)_[0-9]*[a-z]/\1\.pl/') \
$(shell echo -d -pdb) ${TEST_CASE_DIR}/$*.dir > $@
# Generating diff files.
${TEST_DIFF_DIR}/%.cifdiff: ${TEST_CASE_DIR}/%.cif ${TEST_OUTP_DIR}/%.cifout
@echo -n $*": "
@${SCRIPT_DIR}/$(shell echo $* | sed 's/\(.*\)_[0-9]*[a-z]/\1\.pl/') \
$(shell echo -cif) $< 2>&1 | diff - $(word 2, $^) > $@; \
if [ $$? -eq 0 ]; then echo "OK"; else echo "FAILED"; cat $@; fi
${TEST_DIFF_DIR}/%.pdbdiff: ${TEST_CASE_DIR}/%.pdb ${TEST_OUTP_DIR}/%.pdbout
@echo -n $*": "
@${SCRIPT_DIR}/$(shell echo $* | sed 's/\(.*\)_[0-9]*[a-z]/\1\.pl/') \
$(shell echo -pdb) $< 2>&1 | diff - $(word 2, $^) > $@; \
if [ $$? -eq 0 ]; then echo "OK"; else echo "FAILED"; cat $@; fi
${TEST_DIFF_DIR}/%.dirdiff: ${TEST_CASE_DIR}/%.dir ${TEST_OUTP_DIR}/%.dirout
@echo -n $*": "
@${SCRIPT_DIR}/$(shell echo $* | sed 's/\(.*\)_[0-9]*[a-z]/\1\.pl/') \
$(shell echo -d -pdb) $(shell FILE=`readlink -f $<`; echo $$FILE) 2>&1 \
| diff - $(word 2, $^) > $@; \
if [ $$? -eq 0 ]; then echo "OK"; else echo "FAILED"; cat $@; fi
.PHONY: clean-tests
clean-tests:
rm -f ${TEST_CIF_DIFFS}
rm -f ${TEST_PDB_DIFFS}
rm -f ${TEST_DIR_DIFFS}
rm -f ${TEST_CIF_OUTPS}
rm -f ${TEST_PDB_OUTPS}
rm -f ${TEST_DIR_OUTPS}