-
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.
- Loading branch information
Showing
28 changed files
with
762 additions
and
262 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
**/target | ||
**/*.rs.bk | ||
Cargo*.lock | ||
.vscode | ||
**/target | ||
**/Cargo.lock | ||
/.vscode/ | ||
/test_dirs/ | ||
/wip/ |
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
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,34 +1,137 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
######## | ||
# functions | ||
######## | ||
|
||
TMP_FILE="/tmp/sscanf_test_out.txt" | ||
function handle_output { | ||
rm -f "${TMP_FILE}" | ||
while IFS='' read -r line | ||
do | ||
echo "${line}" >> "${TMP_FILE}" | ||
|
||
echo -en "\033[2K\r" | ||
echo -n "$(cut -c "1-$(tput cols)" <<< "> ${line}")" | ||
done | ||
echo -en "\033[2K\r"; | ||
tput init # Reset any coloring | ||
} | ||
|
||
function try_silent { | ||
echo "Running $@" | ||
unbuffer "$@" > /tmp/sscanf_test_out.txt || (cat /tmp/sscanf_test_out.txt && return 1) | ||
echo "Running $*" | ||
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}" | ||
MIN_VERSIONS_DIR="${OUT_DIRS}/min_versions" | ||
|
||
for dir in "${MSRV_DIR}" "${MIN_VERSIONS_DIR}"; do | ||
[[ -d "${dir}" ]] && continue | ||
mkdir -p "${dir}" | ||
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 | ||
pushd ~/projects/sscanf | ||
try_silent cargo update || exit 1 | ||
try_silent cargo +stable test || exit 1 | ||
try_silent cargo +nightly test || exit 1 | ||
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 | ||
popd | ||
|
||
pushd ~/projects/sscanf/sscanf_macro | ||
try_silent cargo +nightly clippy -- -D warnings || exit 1 | ||
try_silent cargo +stable fmt --check || exit 1 | ||
popd | ||
|
||
# old rustc version | ||
pushd ~/projects/sscanf_old_rustc | ||
try_silent cargo +1.56.0 test -- --skip failing_tests || exit 1 | ||
popd | ||
|
||
# minimum version | ||
pushd ~/projects/sscanf_min_version | ||
try_silent cargo +nightly -Z minimal-versions update || exit 1 | ||
|
||
try_silent cargo +stable test -- --skip failing_tests || exit 1 | ||
try_silent cargo +nightly test -- --skip failing_tests || exit 1 | ||
popd | ||
######## | ||
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}" | ||
try_silent rustup install "${MSRV}" | ||
ORIGINAL_RUSTFLAGS="${RUSTFLAGS}" | ||
RUSTFLAGS="${RUSTFLAGS} --cfg msrv_build" | ||
try_silent cargo "+${MSRV}" test --tests # only run --tests, which excludes the doctests from Readme.md | ||
RUSTFLAGS="${ORIGINAL_RUSTFLAGS}" | ||
|
||
######## | ||
# minimum versions | ||
######## | ||
cd "${MIN_VERSIONS_DIR}" | ||
try_silent cargo +nightly -Z minimal-versions update | ||
|
||
try_silent cargo +stable test | ||
try_silent cargo +nightly test | ||
|
||
######## | ||
echo "All tests passed!" |
File renamed without changes.
Oops, something went wrong.