test_script.sh 1.27 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
# This script is meant to be called by the "script" step defined in
# .travis.yml. See http://docs.travis-ci.com/ for more details.
# The behavior of the script is controlled by environment variabled defined
# in the .travis.yml in the top level folder of the project.
set -e

python --version

run_tests() {
  # find all the test files that match "test*.py"
Jason Lian's avatar
more  
Jason Lian committed
12
  TEST_FILES="$(find test -type f -name "test*.py" | sort)"
13
14
15
16
17
18
19
20
  echo "Test files are:"
  echo $TEST_FILES

  echo "Executing tests:"
  EXIT_STATUS=0
  for FILE in $TEST_FILES; do
    # run each file on a separate process. if one fails, just keep going and
    # return the final exit status.
21
    python -m pytest -v $FILE
22
23
24
25
26
27
28
29
30
31
32
33
34
    STATUS=$?
    EXIT_STATUS="$(($EXIT_STATUS+STATUS))"
  done

  echo "Done, exit status: $EXIT_STATUS"
  exit $EXIT_STATUS
}

if [[ "$RUN_FLAKE8" == "true" ]]; then
  flake8
fi

if [[ "$SKIP_TESTS" != "true" ]]; then
35
  echo "run_tests"
36
37
  run_tests
fi
38
39
40
41
42
43
44
45
46
47
48

if [[ "$RUN_EXAMPLE_TESTS" == "true" ]]; then
  echo "run_example_tests"
  pushd examples
  ASR_MODEL_PATH=$HOME/download/data/model.pt \
  ASR_INPUT_FILE=interactive_asr/data/sample.wav \
  ASR_DATA_PATH=$HOME/download/data \
  ASR_USER_DIR=$HOME/download/fairseq/examples/speech_recognition \
  python -m unittest test/test_interactive_asr.py
  popd
fi