Skip to contentSkip to conversation

build-sys: generate tests/.gitignore

PATCH Superseded Marc-André Lureau 2 participants 2 messages Sep 22, 2016 – Oct 27, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 build-sys: generate tests/.gitignore

It's too easy to forget about updating the .gitignore, so this is an attempt at generating it instead.

This approach assumes that the files to clean are the one to put in the .gitignore.

---
v2:
- fix make check-clean
- improve adding $(QEMU_IOTESTS_HELPERS-y) in cleanfiles (it needs a patsubst because tests/ is present 2 times)
- use quiet-command
- fix cleanfiles +=

 tests/Makefile.include | 26 +++++++++++++---
 tests/.gitignore       | 82 --------------------------------------------------
 2 files changed, 22 insertions(+), 86 deletions(-)
 delete mode 100644 tests/.gitignore
tests/Makefile.include +22 -4
index 6052a38..cf81fd7 100644
@@ -782,8 +782,21 @@ $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
 	@perl -p -e 's|\Q$(SRC_PATH)\E/||g' $*.test.err | diff -q $(SRC_PATH)/$*.err -
 	@diff -q $(SRC_PATH)/$*.exit $*.test.exit
 
-# Consolidated targets
+tests-cleanfiles = *.o
+tests-cleanfiles += .gitignore
+tests-cleanfiles += qht-bench$(EXESUF)
+tests-cleanfiles += qapi-schema/*.test.*
+tests-cleanfiles += test-qapi-event.[ch]
+tests-cleanfiles += test-qapi-types.[ch]
+tests-cleanfiles += test-qapi-visit.[ch]
+tests-cleanfiles += test-qmp-introspect.[ch]
+tests-cleanfiles += test-qmp-commands.h
+tests-cleanfiles += test-qmp-marshal.c
+tests-cleanfiles += $(subst tests/,,$(check-unit-y))
+tests-cleanfiles += $(subst tests/,,$(check-qtest-y))
+tests-cleanfiles += $(patsubst tests/%,%,$(QEMU_IOTESTS_HELPERS-y))
 
+# Consolidated targets
 .PHONY: check-qapi-schema check-qtest check-unit check check-clean
 check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y))
 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
@@ -792,14 +805,19 @@ check-block: $(patsubst %,check-%, $(check-block-y))
 check: check-qapi-schema check-unit check-qtest
 check-clean:
 	$(MAKE) -C tests/tcg clean
-	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
-	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
-
+	(cd tests && rm -rf $(tests-cleanfiles))
 clean: check-clean
 
 # Build the help program automatically
 
 all: $(QEMU_IOTESTS_HELPERS-y)
 
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+$(SRC_PATH)/tests/.gitignore:
+	$(call quiet-command, echo "$(tests-cleanfiles)" | xargs -n1 | sort > $@, \
+	  " GEN $(@F)")
+Makefile: $(SRC_PATH)/tests/.gitignore
+endif
+
 -include $(wildcard tests/*.d)
 -include $(wildcard tests/libqos/*.d)
tests/.gitignore deleted +0 -82

82 lines not on this page · raw message

Signature · 1 line
2.10.0
#1 lore raw
Quoted 47 lines · Marc-André Lureau

It's too easy to forget about updating the .gitignore, so this is an attempt at generating it instead.

This approach assumes that the files to clean are the one to put in the .gitignore.

---
v2:
- fix make check-clean
- improve adding $(QEMU_IOTESTS_HELPERS-y) in cleanfiles (it needs a patsubst because tests/ is present 2 times)
- use quiet-command
- fix cleanfiles +=

 tests/Makefile.include | 26 +++++++++++++---
 tests/.gitignore       | 82 --------------------------------------------------
 2 files changed, 22 insertions(+), 86 deletions(-)
 delete mode 100644 tests/.gitignore
tests/Makefile.include +14 -1
index 6052a38..cf81fd7 100644
@@ -782,8 +782,21 @@ $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
 	@perl -p -e 's|\Q$(SRC_PATH)\E/||g' $*.test.err | diff -q $(SRC_PATH)/$*.err -
 	@diff -q $(SRC_PATH)/$*.exit $*.test.exit
 
-# Consolidated targets
+tests-cleanfiles = *.o
+tests-cleanfiles += .gitignore
+tests-cleanfiles += qht-bench$(EXESUF)
+tests-cleanfiles += qapi-schema/*.test.*
+tests-cleanfiles += test-qapi-event.[ch]
+tests-cleanfiles += test-qapi-types.[ch]
+tests-cleanfiles += test-qapi-visit.[ch]
+tests-cleanfiles += test-qmp-introspect.[ch]
+tests-cleanfiles += test-qmp-commands.h
+tests-cleanfiles += test-qmp-marshal.c
+tests-cleanfiles += $(subst tests/,,$(check-unit-y))
+tests-cleanfiles += $(subst tests/,,$(check-qtest-y))
+tests-cleanfiles += $(patsubst tests/%,%,$(QEMU_IOTESTS_HELPERS-y))
 
+# Consolidated targets
 .PHONY: check-qapi-schema check-qtest check-unit check check-clean
 check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y))
 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y)) · line 808

Quoted 7 lines
tests/Makefile.include +1 -3
@@ -792,14 +805,19 @@ check-block: $(patsubst %,check-%, $(check-block-y))
 check: check-qapi-schema check-unit check-qtest
 check-clean:
 	$(MAKE) -C tests/tcg clean
-	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
-	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
-
+	(cd tests && rm -rf $(tests-cleanfiles))

Why the subshell?

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y)) · line 818

Quoted 10 lines
tests/Makefile.include +4 -0
 clean: check-clean
 
 # Build the help program automatically
 
 all: $(QEMU_IOTESTS_HELPERS-y)
 
+ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
+$(SRC_PATH)/tests/.gitignore:
+	$(call quiet-command, echo "$(tests-cleanfiles)" | xargs -n1 | sort > $@, \
+	  " GEN $(@F)")

Incorrect usage of $(call quiet-command), now that 0bdb12c7 has landed.

tests/Makefile.include check-block: $(patsubst %,check-%, $(check-block-y)) · line 823

Quoted 5 lines
tests/Makefile.include +3 -0
+Makefile: $(SRC_PATH)/tests/.gitignore
+endif
+
 -include $(wildcard tests/*.d)
 -include $(wildcard tests/libqos/*.d)

Otherwise it appears to work, and looks like you've addressed many of my v1 findings. I still think that Paolo may be a better GNU make expert to give a review on this, so I've cc'd him.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org