github.com/alloyci/alloy-runner@v1.0.1-0.20180222164613-925503ccafd6/scripts/check_race_conditions (about)

     1  #!/bin/sh
     2  
     3  # This is the number of race conditions detected on master.
     4  # This number is not allowed to increase, and it has to be lowered when we
     5  # fix existing race conditions
     6  max=33
     7  
     8  tmpfile=$(mktemp)
     9  CGO_ENABLED=1 TESTFLAGS="-race" make test 2>&1 | tee -a "$tmpfile"
    10  
    11  cnt=$(grep -c -e "^WARNING: DATA RACE$" "$tmpfile")
    12  echo "Found ${cnt} race conditions. Maximum allowed value is ${max}"
    13  
    14  rm "$tmpfile" 2>/dev/null || true
    15  
    16  if [ "$cnt" -gt "$max" ]; then
    17    echo "Race conditions count increased"
    18    exit 1
    19  fi