Skip to content

Commit

Permalink
Disallow system header file includes in our test suite
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fitzgen committed Jul 6, 2017
1 parent 78e7546 commit 945c66a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ci/no-includes.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 945c66a

Please sign in to comment.