Skip to content

Commit 01c4572

Browse files
authored
Make check-proto-files fail when things need updatings. (apple#1902)
Since there are multiple commands happening, it wasn't actually making the `make` fail when there were changes found. Solve this by using a temp file to hold all the diffs, and check if it has anything at the end to do the reporting.
1 parent 4bd401a commit 01c4572

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Makefile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -622,19 +622,28 @@ update-proto-files: check-for-protobuf-checkout
622622
#
623623
# Usually want to also provide `GOOGLE_PROTOBUF_CHECKOUT=some_local_head_protobuf` so
624624
# you are checking against a state this project hasn't adopted yet.
625+
#
626+
# Since there are multiple things to check we direct the diffs all into a file and check
627+
# at the end.
625628
check-proto-files: check-for-protobuf-checkout
629+
@rm -f _check_protos.txt && touch _check_protos.txt
626630
@for p in `cd ${GOOGLE_PROTOBUF_CHECKOUT} && ls conformance/*.proto conformance/test_protos/*.proto`; do \
627-
diff -u "Protos/upstream/$$p" "${GOOGLE_PROTOBUF_CHECKOUT}/$$p" \
628-
|| (echo "ERROR: Time to do a 'make update-proto-files'" && exit 1); \
631+
diff -u "Protos/upstream/$$p" "${GOOGLE_PROTOBUF_CHECKOUT}/$$p" >> _check_protos.txt; \
629632
done
630633
@for p in `cd ${GOOGLE_PROTOBUF_CHECKOUT}/src && ls google/protobuf/*.proto | grep -v test`; do \
631-
diff -u "Protos/upstream/$$p" "${GOOGLE_PROTOBUF_CHECKOUT}/src/$$p" \
632-
|| (echo "ERROR: Time to do a 'make update-proto-files'" && exit 1); \
634+
diff -u "Protos/upstream/$$p" "${GOOGLE_PROTOBUF_CHECKOUT}/src/$$p" >> _check_protos.txt; \
633635
done
634636
@for p in `cd ${GOOGLE_PROTOBUF_CHECKOUT}/src && ls google/protobuf/compiler/*.proto`; do \
635-
diff -u "Protos/upstream/$$p" "${GOOGLE_PROTOBUF_CHECKOUT}/src/$$p" \
636-
|| (echo "ERROR: Time to do a 'make update-proto-files'" && exit 1); \
637+
diff -u "Protos/upstream/$$p" "${GOOGLE_PROTOBUF_CHECKOUT}/src/$$p" >> _check_protos.txt; \
637638
done
639+
@if [ -s _check_protos.txt ] ; then \
640+
cat _check_protos.txt; \
641+
rm -f _check_protos.txt; \
642+
echo "ERROR: Time to do a 'make update-proto-files'"; \
643+
exit 1; \
644+
else \
645+
rm -f _check_protos.txt; \
646+
fi
638647

639648
# Runs the conformance tests.
640649
test-conformance: build check-for-protobuf-checkout Sources/Conformance/failure_list_swift.txt Sources/Conformance/text_format_failure_list_swift.txt

0 commit comments

Comments
 (0)