-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a script `contrib/compile-tests.sh` the checks that all crates in `tests/compiletests/` do compile if in `pass/` and fail to compile if in `fail/` Add a CI step to run the script
- Loading branch information
1 parent
3dee66b
commit c7eb39e
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Checks intended compile failures. | ||
|
||
set -euo pipefail | ||
|
||
REPO_DIR=$(git rev-parse --show-toplevel) | ||
|
||
compile_check() { | ||
local dir_path=$1 | ||
local expected_status=$2 | ||
result=0 | ||
# All crates in the specified subdirectory must compile or fail based on expected_status | ||
for dir in "$dir_path"/*; do | ||
if [ -d "$dir" ]; then | ||
pushd "$dir" > /dev/null | ||
echo "Compiling $dir" | ||
output=$(cargo build 2>&1) | ||
if [ "$?" -ne "$expected_status" ]; then | ||
if [ "$expected_status" -eq 0 ]; then | ||
echo "$output" | ||
echo "error: compile-tests/$dir/ failed to compile" | ||
else | ||
echo "error: compile-tests/$dir/ compiled when it should not have" | ||
fi | ||
result=1 | ||
fi | ||
popd > /dev/null | ||
fi | ||
done | ||
return "$result" | ||
} | ||
|
||
# Check that all files in compiletests pass or fail as expected | ||
cd "$REPO_DIR"/tests/compile-tests | ||
if compile_check "pass" 0 && compile_check "fail" 101; then | ||
echo "Compile tests passed" | ||
exit 0 | ||
else | ||
echo "Compile tests failed" | ||
exit 1 | ||
fi |