Skip to content

Commit f23309a

Browse files
committed
improve script
1 parent d2661af commit f23309a

8 files changed

+58
-61
lines changed

.github/deploy.sh

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,16 @@ if [ -n "$TRAVIS_TAG" ]; then
3131
fi
3232

3333
# Generate version index that is shown as root index page
34-
(
35-
cp util/gh-pages/versions.html out/index.html
36-
37-
cd out
38-
python -c '\
39-
import os, json;\
40-
print json.dumps([\
41-
dir for dir in os.listdir(".")\
42-
if not dir.startswith(".") and os.path.isdir(dir)\
43-
])' > versions.json
44-
)
34+
cp util/gh-pages/versions.html out/index.html
35+
pushd out
36+
37+
cat <<-EOF | python - > versions.json
38+
import os, json
39+
print json.dumps([
40+
dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
41+
])
42+
EOF
43+
popd
4544

4645
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
4746
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
@@ -60,7 +59,7 @@ ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
6059
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
6160
openssl aes-256-cbc -K "$ENCRYPTED_KEY" -iv "$ENCRYPTED_IV" -in .github/deploy_key.enc -out .github/deploy_key -d
6261
chmod 600 .github/deploy_key
63-
eval $(ssh-agent -s)
62+
eval "$(ssh-agent -s)"
6463
ssh-add .github/deploy_key
6564

6665
# Now let's go have some fun with the cloned repo

ci/base-tests.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
#!/usr/bin/env bash
12
set -ex
23

34
echo "Running clippy base tests"
45

56
PATH=$PATH:./node_modules/.bin
67
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
7-
remark -f *.md -f doc/*.md > /dev/null
8+
remark -f ./*.md -f doc/*.md > /dev/null
89
fi
910
# build clippy in debug mode and run tests
1011
cargo build --features "debugging deny-warnings"
1112
cargo test --features "debugging deny-warnings"
1213
# for faster build, share target dir between subcrates
13-
export CARGO_TARGET_DIR=`pwd`/target/
14+
CARGO_TARGET_DIR=$(pwd)/target/
15+
export CARGO_TARGET_DIR
1416
(cd clippy_lints && cargo test)
1517
(cd rustc_tools_util && cargo test)
1618
(cd clippy_dev && cargo test)
@@ -29,25 +31,25 @@ export CARGO_TARGET_DIR=`pwd`/target/
2931
(
3032
# Check sysroot handling
3133
sysroot=$(./target/debug/clippy-driver --print sysroot)
32-
test $sysroot = $(rustc --print sysroot)
34+
test "$sysroot" = "$(rustc --print sysroot)"
3335

34-
if [ -z $OS_WINDOWS ]; then
36+
if [ -z "$OS_WINDOWS" ]; then
3537
desired_sysroot=/tmp
3638
else
3739
desired_sysroot=C:/tmp
3840
fi
3941
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
40-
test $sysroot = $desired_sysroot
42+
test "$sysroot" = $desired_sysroot
4143

4244
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
43-
test $sysroot = $desired_sysroot
45+
test "$sysroot" = $desired_sysroot
4446

4547
# Make sure this isn't set - clippy-driver should cope without it
4648
unset CARGO_MANIFEST_DIR
4749

4850
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
4951
# XXX How to match the clippy invocation in compile-test.rs?
50-
! ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr
52+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
5153
diff <(sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr) tests/ui/cstring.stderr
5254

5355
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR

ci/integration-tests.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
#!/usr/bin/env bash
12
set -x
23
rm ~/.cargo/bin/cargo-clippy
34
cargo install --force --path .
45

56
echo "Running integration test for crate ${INTEGRATION}"
67

7-
git clone --depth=1 https://github.com/${INTEGRATION}.git checkout
8-
cd checkout
8+
git clone --depth=1 https://github.com/"${INTEGRATION}".git checkout
9+
cd checkout || exit
910

1011
function check() {
1112
# run clippy on a project, try to be verbose and trigger as many warnings as possible for greater coverage
1213
RUST_BACKTRACE=full cargo clippy --all-targets --all-features -- --cap-lints warn -W clippy::pedantic -W clippy::nursery &> clippy_output
1314
cat clippy_output
14-
! cat clippy_output | grep -q "internal compiler error\|query stack during panic\|E0463"
15-
if [[ $? != 0 ]]; then
15+
if ! grep -q "internal compiler error\|query stack during panic\|E0463" clippy_output; then
1616
return 1
1717
fi
1818
}

tests/ui-toml/update-all-references.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ if [[ "$1" == "--help" || "$1" == "-h" ]]; then
1313
fi
1414

1515
BUILD_DIR=$PWD/target/debug/test_build_base
16-
MY_DIR=$(dirname $0)
17-
cd $MY_DIR
18-
find . -name '*.rs' | xargs ./update-references.sh $BUILD_DIR
16+
MY_DIR=$(dirname "$0")
17+
cd "$MY_DIR" || exit
18+
find . -name '*.rs' -exec ./update-references.sh "$BUILD_DIR" {} +

tests/ui-toml/update-references.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
1616
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
1717
fi
1818

19-
MYDIR=$(dirname $0)
19+
MYDIR=$(dirname "$0")
2020

2121
BUILD_DIR="$1"
2222
shift
@@ -25,16 +25,14 @@ while [[ "$1" != "" ]]; do
2525
STDERR_NAME="${1/%.rs/.stderr}"
2626
STDOUT_NAME="${1/%.rs/.stdout}"
2727
shift
28-
if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
29-
! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then
30-
echo updating $MYDIR/$STDOUT_NAME
31-
cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME
28+
if [ -f "$BUILD_DIR"/"$STDOUT_NAME" ] && \
29+
! (diff "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME" >& /dev/null); then
30+
echo updating "$MYDIR"/"$STDOUT_NAME"
31+
cp "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"
3232
fi
33-
if [ -f $BUILD_DIR/$STDERR_NAME ] && \
34-
! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then
35-
echo updating $MYDIR/$STDERR_NAME
36-
cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME
33+
if [ -f "$BUILD_DIR"/"$STDERR_NAME" ] && \
34+
! (diff "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME" >& /dev/null); then
35+
echo updating "$MYDIR"/"$STDERR_NAME"
36+
cp "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"
3737
fi
3838
done
39-
40-

tests/ui/update-all-references.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ if [[ "$1" == "--help" || "$1" == "-h" ]]; then
1313
fi
1414

1515
BUILD_DIR=$PWD/target/debug/test_build_base
16-
MY_DIR=$(dirname $0)
17-
cd $MY_DIR
18-
find . -name '*.rs' | xargs ./update-references.sh $BUILD_DIR
16+
MY_DIR=$(dirname "$0")
17+
cd "$MY_DIR" || exit
18+
find . -name '*.rs' -exec ./update-references.sh "$BUILD_DIR" {} +

tests/ui/update-references.sh

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
1616
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
1717
fi
1818

19-
MYDIR=$(dirname $0)
19+
MYDIR=$(dirname "$0")
2020

2121
BUILD_DIR="$1"
2222
shift
@@ -26,21 +26,19 @@ while [[ "$1" != "" ]]; do
2626
STDOUT_NAME="${1/%.rs/.stdout}"
2727
FIXED_NAME="${1/%.rs/.fixed}"
2828
shift
29-
if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
30-
! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then
31-
echo updating $MYDIR/$STDOUT_NAME
32-
cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME
29+
if [ -f "$BUILD_DIR"/"$STDOUT_NAME" ] && \
30+
! (diff "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME" >& /dev/null); then
31+
echo updating "$MYDIR"/"$STDOUT_NAME"
32+
cp "$BUILD_DIR"/"$STDOUT_NAME" "$MYDIR"/"$STDOUT_NAME"
3333
fi
34-
if [ -f $BUILD_DIR/$STDERR_NAME ] && \
35-
! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then
36-
echo updating $MYDIR/$STDERR_NAME
37-
cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME
34+
if [ -f "$BUILD_DIR"/"$STDERR_NAME" ] && \
35+
! (diff "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME" >& /dev/null); then
36+
echo updating "$MYDIR"/"$STDERR_NAME"
37+
cp "$BUILD_DIR"/"$STDERR_NAME" "$MYDIR"/"$STDERR_NAME"
3838
fi
39-
if [ -f $BUILD_DIR/$FIXED_NAME ] && \
40-
! (diff $BUILD_DIR/$FIXED_NAME $MYDIR/$FIXED_NAME >& /dev/null); then
41-
echo updating $MYDIR/$FIXED_NAME
42-
cp $BUILD_DIR/$FIXED_NAME $MYDIR/$FIXED_NAME
39+
if [ -f "$BUILD_DIR"/"$FIXED_NAME" ] && \
40+
! (diff "$BUILD_DIR"/"$FIXED_NAME" "$MYDIR"/"$FIXED_NAME" >& /dev/null); then
41+
echo updating "$MYDIR"/"$FIXED_NAME"
42+
cp "$BUILD_DIR"/"$FIXED_NAME" "$MYDIR"/"$FIXED_NAME"
4343
fi
4444
done
45-
46-

util/fetch_prs_between.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Fetches the merge commits between two git commits and prints the PR URL
44
# together with the full commit message
@@ -12,14 +12,14 @@ last=$2
1212
IFS='
1313
'
1414
for pr in $(git log --oneline --grep "Merge #" --grep "Merge pull request" --grep "Auto merge of" --grep "Rollup merge of" "$first...$last" | sort -rn | uniq); do
15-
id=$(echo $pr | rg -o '#[0-9]{3,5}' | cut -c 2-)
16-
commit=$(echo $pr | cut -d' ' -f 1)
17-
message=$(git --no-pager show --pretty=medium $commit)
18-
if [ ! -z $(echo "$message" | rg "^[\s]{4}changelog: [nN]one\.*$") ]; then
15+
id=$(echo "$pr" | rg -o '#[0-9]{3,5}' | cut -c 2-)
16+
commit=$(echo "$pr" | cut -d' ' -f 1)
17+
message=$(git --no-pager show --pretty=medium "$commit")
18+
if [[ -n $(echo "$message" | rg "^[\s]{4}changelog: [nN]one\.*$") ]]; then
1919
continue
2020
fi
2121

2222
echo "URL: https://github.com/rust-lang/rust-clippy/pull/$id"
2323
echo "$message"
24-
echo "---------------------------------------------------------\n"
24+
printf "---------------------------------------------------------\n\n"
2525
done

0 commit comments

Comments
 (0)