mirror of
https://github.com/warpdotdev/warp.git
synced 2026-06-03 17:00:21 +08:00
## Description
Move inline Rust `mod tests { ... }` modules into sibling `_tests.rs`
files so test code follows the repository style guide consistently. The
original source files now include those modules with `#[cfg(test)]`,
`#[path = "..._tests.rs"]`, and `mod tests;` stubs.
This also adds a lightweight presubmit/CI check to prevent new inline
test modules from being introduced.
> [!NOTE]
> note from dstern: agent mode wrote a python script to do this
migration, so i have pretty good confidence that the migration of code
is lossless.
## Testing
- `./script/check_no_inline_test_modules`
- `./script/format`
- `./script/format --check`
- `git --no-pager diff --check`
- `cargo check --manifest-path /Users/david/src/warp-2/Cargo.toml
--workspace --all-targets --exclude command-signatures-v2`
- `cargo clippy --manifest-path /Users/david/src/warp-2/Cargo.toml
--workspace --exclude warp_completer --all-targets --tests -- -D
warnings`
- Manually verified `./script/check_no_inline_test_modules` fails for a
temporary Rust file containing an inline `mod tests { ... }` module.
CHANGELOG-NONE
Co-Authored-By: Oz <oz-agent@warp.dev>
68 lines
2.5 KiB
Bash
Executable File
68 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script to run presubmit checks. Devs can run this script locally before sending out PRs for review to ensure
|
|
# CI is passing for their PR.
|
|
|
|
set -e
|
|
cd "$(dirname "$0")/.."
|
|
|
|
FMT_COMMAND="./script/format"
|
|
echo "Running $FMT_COMMAND..."
|
|
set -e
|
|
EXIT_CODE=0
|
|
$FMT_COMMAND --check || EXIT_CODE=$?
|
|
if [[ $EXIT_CODE -ne 0 ]]; then
|
|
echo 'Run `'"$FMT_COMMAND"'` to fix.'
|
|
exit $EXIT_CODE
|
|
fi
|
|
|
|
echo "Rust formatting succeeded..."
|
|
echo "Checking for inline Rust test modules..."
|
|
./script/check_no_inline_test_modules
|
|
echo "Inline Rust test module check succeeded..."
|
|
|
|
echo "Running clippy..."
|
|
# Exclude warp_completer because we run clippy on it with default features (rather than all features) below.
|
|
#
|
|
# TODO(vorporeal): Re-enable the `all-features` flag once we've fixed things.
|
|
cargo clippy --workspace --exclude warp_completer --all-targets --tests -- -D warnings
|
|
# Run clippy on warp_completer with default, rather than all features enabled, because there is
|
|
# feature-gated logic for the WIP completions-on-js implementation.
|
|
cargo clippy -p warp_completer --all-targets --tests -- -D warnings
|
|
echo "clippy succeeded..."
|
|
|
|
echo "Running clang-format..."
|
|
./script/run-clang-format.py -r --extensions 'c,h,cpp,m' ./crates/warpui/src/ ./app/src/
|
|
echo "clang-format succeeded..."
|
|
|
|
echo "Running wgslfmt..."
|
|
# Normally a recursive glob pattern will do the trick, e.g. **/*.wgsl
|
|
# However, the default bash version in MacOS is too old to support that, so we use `find` instead.
|
|
find . -name "*.wgsl" -exec wgslfmt --check {} +
|
|
echo "wgslfmt succeeded..."
|
|
|
|
# check to see if we can run powershell on the device
|
|
if command -v pwsh /dev/null 2>&1; then
|
|
echo "Running PSScriptAnalyzer..."
|
|
./script/lint_powershell -ci
|
|
echo "PsScriptAnalyzer succeeded..."
|
|
elif [ "${GITHUB_ACTIONS}" == "true" ]; then
|
|
# If we are in CI, and fail to find powershell, we should automatically fail
|
|
echo "No powershell installation detected! Aborting!"
|
|
exit 1
|
|
else
|
|
# Otherwise, post a notice that we are skipping powershell
|
|
echo "No Powershell detected! skipping PSScriptAnalyzer!"
|
|
fi
|
|
|
|
echo "Running tests via nextest..."
|
|
cargo nextest run --no-fail-fast --workspace --exclude command-signatures-v2
|
|
# Run warp_completer tests with the "v2" (completions-on-js) flag enabled. We do this to ensure that
|
|
# the v2 completions implementation doesn't regress/rot while it's development is paused.
|
|
cargo nextest run -p warp_completer --features v2
|
|
echo "Running doc tests..."
|
|
cargo test --doc
|
|
echo "Tests succeeded..."
|
|
|
|
echo "Congrats! All presubmits checks passed."
|