Fri 05 Dec 2014 01:20:14 AM UTC, original submission:
Background:
I have a Makefile in which tests are executed by running a "make tests" target.
The test rules work with files having several suffixes: .ok, .out, .expected and .txr
The foo.ok file is a timestamp, which is updated by a rule that only succeeds if "foo.out" matches "foo.expected".
%.ok depends on %.out, and %.out depends on %.txr: a foo.txr script is run with some arguments to produce foo.out.
Now some of the %.out targets have target specific assignments to set up some command line arguments and whatnot for the test.
STRANGE BEHAVIOR: it seems that those %.out targets which do not have target-specific assignments are not considered to be intermediate files. They are not deleted. Those %.out targets which have no target-specific assignments are deleted.
Example run:
# this .out file has a target-specific assignment
$ rm tests/009/json.out
$ make tests/009/json.ok
mkdir -p tests/009/
./txr --gc-debug tests/009/json.txr /home/kaz/txr/tests /009/webapp.json /home/kaz/txr/tests/009/pass1.json > tests/009/json.out
diff -u tests/009/json.expected tests/009/json.out
Notice there is no removal of the intermediate .out file here! If I remove the target-specific assignment then the behavior is different:
$ make tests/009/json.ok
mkdir -p tests/009/
./txr --gc-debug tests/009/json.txr > tests/009/json.out
diff -u tests/009/json.expected tests/009/json.out
rm tests/009/json.out
Note the rm command at the end, issued by GNU Make.
Now for the following different .out file, there is a target-specific assignment, but of a slightly different form.
$ make tests/011/txr-case.ok
mkdir -p tests/011/
./txr tests/011/txr-case.txr > tests/011/txr-case.out
diff -u tests/011/txr-case.expected tests/011/txr-case.out
rm tests/011/txr-case.out
Note the "rm" command here, eliminating the intermediate file.
In the non-removal case (tests/009/json.out) even interrupting make does not ensure that the .out file is gone.
The target specific assignments are:
tests/009/json.out: TXR_ARGS := $(addprefix $(top_srcdir)/tests/009/,webapp.json pass1.json)
tests/011/%: TXR_DBG_OPTS :=
One is a concrete, one is a pattern.
The relevant rules are just:
%.out: %.txr
mkdir -p $(dir $@)
$(if $(TXR_SCRIPT_ON_CMDLINE),\
$(TXR) $(TXR_DBG_OPTS) $(TXR_OPTS) -c "$$(cat $<)" \
$(TXR_ARGS) > $@,\
$(TXR) $(TXR_DBG_OPTS) $(TXR_OPTS) $< $(TXR_ARGS) > $@)
%.ok: %.out
diff -u $(<:.out=.expected) $<
@touch $@
%.expected: %.out
cp $< $@
Am I running into a documented behavior?
|