Skip to content

Commit d82b9e1

Browse files
authored
Add thread sanitizer to test (#72)
1 parent f06b051 commit d82b9e1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

.github/workflows/test.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,36 @@ jobs:
213213
PROPTEST_CASES: "10"
214214
MIRIFLAGS: "-Zmiri-disable-isolation"
215215
run: cargo miri test --all-features
216+
217+
thread_sanitizer-MacOS:
218+
name: Thread Sanitizer checks MacOS
219+
runs-on: macos-latest
220+
221+
steps:
222+
- uses: actions/checkout@v2
223+
- uses: actions/cache@v2
224+
with:
225+
path: |
226+
~/.cargo/bin/
227+
~/.cargo/registry/index/
228+
~/.cargo/registry/cache/
229+
~/.cargo/git/db/
230+
target/
231+
key: ${{ github.event.repository.name }}-${{ runner.os }}-cargo-thread_sanitizer-v2
232+
- name: Install latest nightly
233+
uses: actions-rs/toolchain@v1
234+
with:
235+
toolchain: nightly
236+
override: true
237+
components: rust-src
238+
- name: Run thread sanitizer
239+
run: |
240+
# Thread sanitizer isn't guaranteed to catch all data races, it can only catch it
241+
# the data race if it happens when running the program.
242+
#
243+
# Running the tests multiple times increase the chances that data races are found
244+
# by the thread sanitizer.
245+
for _ in $(seq 1 10); do cargo +nightly test -Z build-std --target --target $(uname -m)-apple-darwin; done
246+
env:
247+
RUSTDOCFLAGS: "-Zsanitizer=thread"
248+
RUSTFLAGS: "-Zsanitizer=thread"

0 commit comments

Comments
 (0)