From 945c66a764e635c0d3f2bb02412919d696b0e54f Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 6 Jul 2017 10:03:08 -0700 Subject: Disallow system header file includes in our test suite There is no guarantee that the system running the tests has the header file, let alone the same version of it that you have. Any test with such an include directive won't reliably produce the consistent bindings across systems. --- ci/no-includes.sh | 23 +++++++++++++++++++++++ ci/test.sh | 3 +++ 2 files changed, 26 insertions(+) create mode 100755 ci/no-includes.sh diff --git a/ci/no-includes.sh b/ci/no-includes.sh new file mode 100755 index 00000000..6aa0fc12 --- /dev/null +++ b/ci/no-includes.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Don't allow any system include directives in tests. + +set -eu +cd "$(dirname "$0")/.." + +echo "Checking for #include directives of system headers..." + +grep -rn '#include\s*<.*>' tests/headers || { + echo "Found none; OK!" + exit 0 +} + +echo " +Found a test with an #include directive of a system header file! + +There is no guarantee that the system running the tests has the header +file, let alone the same version of it that you have. Any test with such an +include directive won't reliably produce the consistent bindings across systems. +" + +exit 1 diff --git a/ci/test.sh b/ci/test.sh index 011ac737..c35dd20a 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -5,6 +5,9 @@ cd "$(dirname "$0")/.." export RUST_BACKTRACE=1 +# Disallow system header file includes in our test suite. +./ci/no-includes.sh + # Regenerate the test headers' bindings in debug and release modes, and assert # that we always get the expected generated bindings. -- cgit v1.2.3