]> git.lizzy.rs Git - rust.git/blob - ci/base-tests.sh
Rustup to https://github.com/rust-lang/rust/pull/60965
[rust.git] / ci / base-tests.sh
1 set -ex
2
3 echo "Running clippy base tests"
4
5 PATH=$PATH:./node_modules/.bin
6 if [ "$TRAVIS_OS_NAME" == "linux" ]; then
7   remark -f *.md -f doc/*.md > /dev/null
8 fi
9 # build clippy in debug mode and run tests
10 cargo build --features debugging
11 cargo test --features debugging
12 # for faster build, share target dir between subcrates
13 export CARGO_TARGET_DIR=`pwd`/target/
14 (cd clippy_lints && cargo test)
15 (cd rustc_tools_util && cargo test)
16 (cd clippy_dev && cargo test)
17
18 # make sure clippy can be called via ./path/to/cargo-clippy
19 (
20   cd clippy_workspace_tests
21   ../target/debug/cargo-clippy
22 )
23
24 # Perform various checks for lint registration
25 ./util/dev update_lints --check
26 ./util/dev --limit-stderr-length
27 cargo +nightly fmt --all -- --check
28
29 # Check running clippy-driver without cargo
30 (
31   export LD_LIBRARY_PATH=$(rustc --print sysroot)/lib
32
33   # Check sysroot handling
34   sysroot=$(./target/debug/clippy-driver --print sysroot)
35   test $sysroot = $(rustc --print sysroot)
36
37   sysroot=$(./target/debug/clippy-driver --sysroot /tmp --print sysroot)
38   test $sysroot = /tmp
39
40   sysroot=$(SYSROOT=/tmp ./target/debug/clippy-driver --print sysroot)
41   test $sysroot = /tmp
42
43   # Make sure this isn't set - clippy-driver should cope without it
44   unset CARGO_MANIFEST_DIR
45
46   # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
47   # XXX How to match the clippy invocation in compile-test.rs?
48   ! ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr
49   diff <(sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr) tests/ui/cstring.stderr
50
51   # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
52 )
53
54 # make sure tests are formatted
55
56 # some lints are sensitive to formatting, exclude some files
57 tests_need_reformatting="false"
58 # switch to nightly
59 rustup override set nightly
60 # avoid loop spam and allow cmds with exit status != 0
61 set +ex
62
63 # Excluding `ice-3891.rs` because the code triggers a rustc parse error which
64 # makes rustfmt fail.
65 for file in `find tests -not -path "tests/ui/crashes/ice-3891.rs" | grep "\.rs$"` ; do
66   rustfmt ${file} --check
67   if [ $? -ne 0 ]; then
68     echo "${file} needs reformatting!"
69     tests_need_reformatting="true"
70   fi
71 done
72
73 set -ex # reset
74
75 if [ "${tests_need_reformatting}" == "true" ] ; then
76     echo "Tests need reformatting!"
77     exit 2
78 fi
79
80 # switch back to master
81 rustup override set master