41 lines · 839 B · Text
RawDownload
#!/bin/bash set -ecd "$(dirname "$0")/.." matches=$(    find . \        \( -path './.git' -o -path './target' \) -prune -o \        -type f \        -name '*.rs' \        -exec grep -nE '^[[:space:]]*mod[[:space:]]+tests[[:space:]]*\{' {} + || true) if [[ -z "$matches" ]]; then    exit 0fi cat <<'EOF'Inline Rust test modules are not allowed. Move test code into a sibling `_tests.rs`file and include it from the original module like this: ```#[cfg(test)]#[path = "..._tests.rs"]mod tests;``` EOFwhile IFS= read -r match; do    file=${match%%:*}    rest=${match#*:}    line=${rest%%:*}     if [[ "${GITHUB_ACTIONS:-}" == "true" ]]; then        echo "::error file=${file#./},line=$line::Move this inline test module to a sibling _tests.rs file."    else        echo "$match"    fidone <<< "$matches" exit 1