Skip to content

Commit 66875a3

Browse files
committed
Ignore whitespace when validating objdump output
If the output of `cargo objdump` changes only with regard to whitespace, it's probably OK to still pass CI. Most readers probably won't even notice whitespace differences in the first place. The [`diff` documentation](https://www.gnu.org/software/diffutils/manual/html_node/White-Space.html#White-Space) says of whitespace-suppressing options: > The --ignore-space-change (-b) option is stronger than -E and -Z > combined. It ignores white space at line end, and considers all other > sequences of one or more white space characters within a line to be > equivalent. This ignores only changes _within_ a line -- changes which span multiple lines (i.e. the addition or removal of whitespace-only lines) will still compare as different. This is a good thing, because there are places the book includes a subset of a file based on line numbers.
1 parent 8d4ae10 commit 66875a3

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

ci/script.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
set -euxo pipefail
22

3+
# All objdumps are compared to their expected output using the `-b` flag, which
4+
# ignores whitespace changes within lines. This is good to avoid the necessity
5+
# of regenerating blessed outputs each time `cargo objdump` makes minor
6+
# formatting changes.
7+
#
8+
# Note that `diff -b` does _not_ allow whitespace changes to span multiple
9+
# lines (i.e. the addition or removal of whitespace-only lines). This is a good
10+
# thing, since some files are included in the book based on line number.
11+
312
main() {
413
# build the book and check that it has no dead links
514
mdbook build
@@ -41,11 +50,11 @@ main() {
4150
pushd memory-layout
4251

4352
# check that the Reset symbol is there
44-
diff app.text.objdump \
53+
diff -b app.text.objdump \
4554
<(cargo objdump --bin app -- -d -no-show-raw-insn -no-leading-addr)
4655

4756
# check that the reset vector is there and has the right address
48-
diff app.vector_table.objdump \
57+
diff -b app.vector_table.objdump \
4958
<(cargo objdump --bin app -- -s -section .vector_table)
5059

5160
qemu_check target/thumbv7m-none-eabi/debug/app
@@ -59,7 +68,7 @@ main() {
5968

6069
# check that the disassembly matches
6170
pushd app
62-
diff app.objdump \
71+
diff -b app.objdump \
6372
<(cargo objdump --bin app -- -d -no-show-raw-insn -no-leading-addr)
6473
# disabled because of rust-lang/rust#53964
6574
# edition_check
@@ -94,9 +103,9 @@ main() {
94103

95104
# check that the disassembly matches
96105
pushd app
97-
diff app.objdump \
106+
diff -b app.objdump \
98107
<(cargo objdump --bin app --release -- -d -no-show-raw-insn -print-imm-hex -no-leading-addr)
99-
diff app.vector_table.objdump \
108+
diff -b app.vector_table.objdump \
100109
<(cargo objdump --bin app --release -- -s -j .vector_table)
101110
edition_check
102111
popd
@@ -115,7 +124,7 @@ main() {
115124

116125
# check that the disassembly matches
117126
pushd app
118-
diff release.objdump \
127+
diff -b release.objdump \
119128
<(cargo objdump --bin app --release -- -d -no-show-raw-insn -print-imm-hex -no-leading-addr)
120129
diff release.vector_table \
121130
<(cargo objdump --bin app --release -- -s -j .vector_table)
@@ -126,13 +135,13 @@ main() {
126135
pushd rt2
127136
arm-none-eabi-as -march=armv7-m asm.s -o asm.o
128137
ar crs librt.a asm.o
129-
diff librt.objdump \
138+
diff -b librt.objdump \
130139
<(arm-none-eabi-objdump -Cd librt.a)
131140
popd
132141

133142
# check that the disassembly matches
134143
pushd app2
135-
diff release.objdump \
144+
diff -b release.objdump \
136145
<(cargo objdump --bin app --release -- -d -no-show-raw-insn -print-imm-hex -no-leading-addr)
137146
diff release.vector_table \
138147
<(cargo objdump --bin app --release -- -s -j .vector_table)
@@ -180,7 +189,7 @@ main() {
180189
pushd app2
181190
diff dev.out \
182191
<(cargo run | xxd -p)
183-
diff dev.objdump \
192+
diff -b dev.objdump \
184193
<(cargo objdump --bin app -- -t | grep '\.log')
185194
edition_check
186195
popd
@@ -189,7 +198,7 @@ main() {
189198
pushd app3
190199
diff dev.out \
191200
<(cargo run | xxd -p)
192-
diff dev.objdump \
201+
diff -b dev.objdump \
193202
<(cargo objdump --bin app -- -t | grep '\.log')
194203
edition_check
195204
popd
@@ -198,7 +207,7 @@ main() {
198207
pushd app4
199208
diff dev.out \
200209
<(cargo run | xxd -p)
201-
diff dev.objdump \
210+
diff -b dev.objdump \
202211
<(cargo objdump --bin app -- -t | grep '\.log')
203212
edition_check
204213
popd
@@ -211,9 +220,9 @@ main() {
211220
pushd app
212221
diff dev.out \
213222
<(cargo run | xxd -p)
214-
diff dev.objdump \
223+
diff -b dev.objdump \
215224
<(cargo objdump --bin app -- -t | grep '\.log')
216-
diff release.objdump \
225+
diff -b release.objdump \
217226
<(cargo objdump --bin app --release -- -t | grep LOGGER)
218227
edition_check
219228
popd

0 commit comments

Comments
 (0)