-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated test script, fixed resulting warning errors
- Loading branch information
1 parent
d0677b6
commit cd822ea
Showing
16 changed files
with
640 additions
and
357 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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(unused)] | ||
|
||
use crate::*; | ||
|
||
/// A workaround for Spans on stable Rust. | ||
|
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 |
---|---|---|
@@ -1,96 +1,134 @@ | ||
#!/bin/bash | ||
|
||
OVERWRITE=0 | ||
if [[ "$1" == "overwrite" ]]; then | ||
OVERWRITE=1 | ||
elif [[ -n "$1" ]]; then | ||
echo "Usage: $0 [overwrite]" | ||
exit 1 | ||
fi | ||
set -e | ||
|
||
TMP_FILE="/tmp/sscanf_test_out.txt" | ||
######## | ||
# functions | ||
######## | ||
|
||
TMP_FILE="/tmp/sscanf_test_out.txt" | ||
function handle_output { | ||
rm -f "${TMP_FILE}" | ||
while read -r line | ||
while IFS='' read -r line | ||
do | ||
echo "${line}" >> "${TMP_FILE}" | ||
|
||
# make sure line is not longer than the terminal width | ||
WIDTH=$(tput cols) # read this again in case the terminal was resized | ||
WIDTH=$((WIDTH - 3)) # leave space for the "..." | ||
TRIMMED_LINE=$(echo "> ${line}" | sed "s/\(.\{${WIDTH}\}\).*/\1.../") | ||
echo -en "\033[2K\r${TRIMMED_LINE}" | ||
tput init # trimmed line may have messed up coloring | ||
echo -en "\033[2K\r" | ||
echo -n "$(cut -c "1-$(tput cols)" <<< "> ${line}")" | ||
done | ||
echo -ne "\033[2K\r"; | ||
echo -en "\033[2K\r"; | ||
tput init # Reset any coloring | ||
} | ||
|
||
function try_silent { | ||
echo "Running $*" | ||
unbuffer "$@" | handle_output | ||
unbuffer "$@" 2>&1 | handle_output | ||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then | ||
cat "${TMP_FILE}" | ||
return 1 | ||
fi | ||
} | ||
|
||
function assert_no_change { | ||
DIR="$1" | ||
if ! git diff-files --quiet --ignore-cr-at-eol "${DIR}"; then | ||
>&2 echo "Changes in ${DIR} detected, aborting" | ||
exit 1 | ||
fi | ||
if [[ -n "$(git ls-files --exclude-standard --others "${DIR}")" ]]; then | ||
>&2 echo "Untracked files in ${DIR} detected, aborting" | ||
exit 1 | ||
fi | ||
} | ||
|
||
######## | ||
# setup | ||
######## | ||
BASE_DIR="$(realpath "$(dirname "$0")")" | ||
|
||
OVERWRITE=0 | ||
if [[ "$1" == "overwrite" ]]; then | ||
OVERWRITE=1 | ||
elif [[ -n "$1" ]]; then | ||
echo "Usage: $0 [overwrite]" | ||
exit 1 | ||
fi | ||
|
||
MSRV=$(grep '^rust-version = ".*"$' "${BASE_DIR}/Cargo.toml" | sed -E 's/^rust-version = "(.*)"$/\1/') | ||
[[ -n "${MSRV}" ]] | ||
echo "Minimum supported Rust version: ${MSRV}" | ||
|
||
OUT_DIRS="${BASE_DIR}/test_dirs" | ||
MSRV_DIR="${OUT_DIRS}/msrv" | ||
MSRV_DIR="${OUT_DIRS}/msrv_${MSRV}" | ||
MIN_VERSIONS_DIR="${OUT_DIRS}/min_versions" | ||
|
||
for dir in "${MSRV_DIR}" "${MIN_VERSIONS_DIR}"; do | ||
[[ -d "${dir}" ]] && continue | ||
mkdir -p "${dir}" | ||
ln -s "${BASE_DIR}/Cargo.toml" "${dir}/Cargo.toml" | ||
ln -s "${BASE_DIR}/src" "${dir}/src" | ||
ln -s "${BASE_DIR}/tests" "${dir}/tests" | ||
ln -s "${BASE_DIR}/sscanf_macro" "${dir}/sscanf_macro" | ||
ln -s "../../Cargo.toml" "${dir}/Cargo.toml" | ||
ln -s "../../src" "${dir}/src" | ||
ln -s "../../tests" "${dir}/tests" | ||
ln -s "../../sscanf_macro" "${dir}/sscanf_macro" | ||
done | ||
|
||
export RUSTFLAGS="-D warnings" | ||
export RUSTDOCFLAGS="-D warnings" | ||
|
||
######## | ||
# main tests | ||
( | ||
cd "${BASE_DIR}" || (echo "Failed to cd to ${BASE_DIR}"; exit 1) | ||
try_silent cargo update || exit 1 | ||
try_silent cargo +stable test || exit 1 | ||
try_silent cargo +nightly test || exit 1 | ||
|
||
if [[ OVERWRITE -eq 1 ]]; then | ||
echo "Trybuild overwrite mode enabled" | ||
export TRYBUILD=overwrite | ||
try_silent cargo +stable test error_message_tests -- --ignored || exit 1 | ||
git add tests/fail # stage overwrite changes first, in case `nightly` would undo them | ||
try_silent cargo +nightly test error_message_tests -- --ignored || exit 1 | ||
else | ||
try_silent cargo +stable test error_message_tests -- --ignored || exit 1 | ||
try_silent cargo +nightly test error_message_tests -- --ignored || exit 1 | ||
fi | ||
export RUSTDOCFLAGS="-D warnings" | ||
try_silent cargo +nightly doc --no-deps || exit 1 | ||
try_silent cargo +nightly clippy -- -D warnings || exit 1 | ||
try_silent cargo +stable fmt --check || exit 1 | ||
) || exit 1 | ||
|
||
( | ||
cd "${BASE_DIR}/sscanf_macro" || (echo "Failed to cd to ${BASE_DIR}/sscanf_macro"; exit 1) | ||
try_silent cargo +nightly clippy -- -D warnings || exit 1 | ||
try_silent cargo +stable fmt --check || exit 1 | ||
) || exit 1 | ||
######## | ||
cd "${BASE_DIR}" | ||
try_silent rustup update | ||
try_silent cargo update | ||
try_silent cargo +stable test | ||
try_silent cargo +nightly test | ||
|
||
if [[ OVERWRITE -eq 1 ]]; then | ||
echo "Trybuild overwrite mode enabled" | ||
export TRYBUILD=overwrite | ||
|
||
# "overwrite" will (as the name implies) overwrite any incorrect output files in the error_message_tests. | ||
# There is however the problem that the stable and nightly versions might have different outputs. If they | ||
# are simply run one after the other, then the second one will overwrite the first one. To avoid this, we | ||
# use git to check if the files have changed after every step. | ||
assert_no_change "tests/fail/**/*.stderr" # Check for initial changes that would skew the later checks | ||
|
||
try_silent cargo +stable test error_message_tests -- --ignored | ||
assert_no_change "tests/fail/**/*.stderr" | ||
|
||
try_silent cargo +nightly test error_message_tests -- --ignored | ||
assert_no_change "tests/fail/**/*.stderr" | ||
else | ||
try_silent cargo +stable test error_message_tests -- --ignored | ||
try_silent cargo +nightly test error_message_tests -- --ignored | ||
fi | ||
try_silent cargo +nightly doc --no-deps | ||
try_silent cargo +nightly clippy -- -D warnings | ||
try_silent cargo +stable fmt --check | ||
|
||
|
||
######## | ||
# sscanf_macro subdirectory | ||
######## | ||
cd "${BASE_DIR}/sscanf_macro" | ||
try_silent cargo +nightly clippy -- -D warnings | ||
try_silent cargo +stable fmt --check | ||
|
||
######## | ||
# minimum supported rust version | ||
( | ||
cd "${MSRV_DIR}" || (echo "Failed to cd to ${MSRV_DIR}"; exit 1) | ||
try_silent cargo +1.56.0 test || exit 1 | ||
) || exit 1 | ||
######## | ||
cd "${MSRV_DIR}" | ||
try_silent rustup install "${MSRV}" | ||
try_silent cargo "+${MSRV}" test --tests # only run --tests, which excludes the doctests from Readme.md | ||
|
||
######## | ||
# minimum versions | ||
( | ||
cd "${MIN_VERSIONS_DIR}" || (echo "Failed to cd to ${MIN_VERSIONS_DIR}"; exit 1) | ||
try_silent cargo +nightly -Z minimal-versions update || exit 1 | ||
######## | ||
cd "${MIN_VERSIONS_DIR}" | ||
try_silent cargo +nightly -Z minimal-versions update | ||
|
||
try_silent cargo +stable test || exit 1 | ||
try_silent cargo +nightly test || exit 1 | ||
) || exit 1 | ||
try_silent cargo +stable test | ||
try_silent cargo +nightly test | ||
|
||
######## | ||
echo "All tests passed!" |
File renamed without changes.
Oops, something went wrong.