]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/.github/driver.sh
Rollup merge of #73800 - nikic:hash_i, r=kennytm
[rust.git] / src / tools / clippy / .github / driver.sh
1 #!/bin/bash
2
3 set -ex
4
5 # Check sysroot handling
6 sysroot=$(./target/debug/clippy-driver --print sysroot)
7 test "$sysroot" = "$(rustc --print sysroot)"
8
9 if [[ ${OS} == "Windows" ]]; then
10   desired_sysroot=C:/tmp
11 else
12   desired_sysroot=/tmp
13 fi
14 sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
15 test "$sysroot" = $desired_sysroot
16
17 sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
18 test "$sysroot" = $desired_sysroot
19
20 # Make sure this isn't set - clippy-driver should cope without it
21 unset CARGO_MANIFEST_DIR
22
23 # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
24 # FIXME: How to match the clippy invocation in compile-test.rs?
25 ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
26 sed -e "s,tests/ui,\$DIR," -e "/= help/d" cstring.stderr > normalized.stderr
27 diff normalized.stderr tests/ui/cstring.stderr
28
29
30 # make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same
31 SYSROOT=`rustc --print sysroot`
32 diff <(LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver --rustc --version --verbose) <(rustc --version --verbose)
33
34
35 echo "fn main() {}" > target/driver_test.rs
36 # we can't run 2 rustcs on the same file at the same time
37 CLIPPY=`LD_LIBRARY_PATH=${SYSROOT}/lib ./target/debug/clippy-driver ./target/driver_test.rs --rustc`
38 RUSTC=`rustc ./target/driver_test.rs`
39 diff <($CLIPPY) <($RUSTC)
40
41 # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR