Skip to content

Commit c3b1f82

Browse files
committed
Extract driver test
1 parent 0e3077e commit c3b1f82

File tree

3 files changed

+35
-54
lines changed

3 files changed

+35
-54
lines changed

.github/driver.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR

.github/workflows/clippy.yml

+3-25
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,9 @@ jobs:
6868
run: ../target/debug/cargo-clippy
6969
working-directory: clippy_workspace_tests
7070
- name: Test clippy-driver
71-
run: |
72-
(
73-
set -ex
74-
# Check sysroot handling
75-
sysroot=$(./target/debug/clippy-driver --print sysroot)
76-
test "$sysroot" = "$(rustc --print sysroot)"
77-
78-
desired_sysroot=/tmp
79-
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
80-
test "$sysroot" = $desired_sysroot
81-
82-
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
83-
test "$sysroot" = $desired_sysroot
84-
85-
# Make sure this isn't set - clippy-driver should cope without it
86-
unset CARGO_MANIFEST_DIR
87-
88-
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
89-
# FIXME: How to match the clippy invocation in compile-test.rs?
90-
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
91-
sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr
92-
diff normalized.stderr tests/ui/cstring.stderr
93-
94-
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
95-
)
71+
run: bash .github/driver.sh
72+
env:
73+
OS: ${{ runner.os }}
9674

9775
- name: Run cargo-cache --autoclean
9876
run: |

.github/workflows/clippy_bors.yml

+3-29
Original file line numberDiff line numberDiff line change
@@ -136,36 +136,10 @@ jobs:
136136
shell: bash
137137
working-directory: clippy_workspace_tests
138138
- name: Test clippy-driver
139-
run: |
140-
(
141-
set -ex
142-
# Check sysroot handling
143-
sysroot=$(./target/debug/clippy-driver --print sysroot)
144-
test "$sysroot" = "$(rustc --print sysroot)"
145-
146-
if [[ ${{ runner.os }} == "Windows" ]]; then
147-
desired_sysroot=C:/tmp
148-
else
149-
desired_sysroot=/tmp
150-
fi
151-
sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot)
152-
test "$sysroot" = $desired_sysroot
153-
154-
sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot)
155-
test "$sysroot" = $desired_sysroot
156-
157-
# Make sure this isn't set - clippy-driver should cope without it
158-
unset CARGO_MANIFEST_DIR
159-
160-
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
161-
# FIXME: How to match the clippy invocation in compile-test.rs?
162-
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1
163-
sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr
164-
diff normalized.stderr tests/ui/cstring.stderr
165-
166-
# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR
167-
)
139+
run: bash .github/driver.sh
168140
shell: bash
141+
env:
142+
OS: ${{ runner.os }}
169143

170144
- name: Run cargo-cache --autoclean
171145
run: |

0 commit comments

Comments
 (0)