github.com/pachyderm/pachyderm@v1.13.4/etc/testing/passing_test_regex.sh (about)

     1  #!/bin/bash
     2  #
     3  # This script prints a regex (which should be passed to 'go test -run=<regex>')
     4  # that matches all tests in the pachyderm test suite that aren't in
     5  # etc/testing/blacklist.txt. Tests in blacklist.txt are flaky or otherwise
     6  # cause our test suite to consitently flake or fail when run in a cloud
     7  # provider's cluster and would render our nightly tests useless.
     8  
     9  basedir="$(realpath "$(dirname "${0}")/../..")"
    10  tmpfile="$(mktemp --dry-run --tmpdir=.)"
    11  
    12  # Put blacklisted tests in ${tmpfile}
    13  grep -v '^$' "${basedir}/etc/testing/blacklist.txt" >"${tmpfile}"
    14  
    15  # List all tests in src/server, and put them in ${tmpfile} as well
    16  ls "${basedir}/src/server" \
    17    | grep '_test\.go$' \
    18    | while read -r f; do
    19        grep --no-filename '^func Test[A-Za-z_]\+(.* \*testing\.T)' "${basedir}/src/server/${f}" \
    20          | sed 's/^func \(Test[A-Za-z_]\+\)(.*$/\1/' >>"${tmpfile}"
    21      done
    22  
    23  # List tests that haven't been blacklisted. These tests only appear once
    24  # in ${tmpfile}, which includes both the list of all tests and the blacklist,
    25  # so that blacklisted tests appear twice. Format the result as a regex with awk
    26  sort "${tmpfile}" | uniq -u | awk '
    27     BEGIN { first = 1 }
    28     first == 0 { pattern = pattern "|" $0 }
    29     first == 1 { pattern = $0; first = 0 }
    30     END { print pattern; }'
    31  rm "${tmpfile}"