Skip to content

Commit

Permalink
[CI] Make *nix unit test fail if C++ extension is not available (#847)
Browse files Browse the repository at this point in the history
Currently our test suites automatically/silently skip tests on C++ extension
if it is not available. This is nice in local env, but in CI these tests should be
enforced and reported as failure if C++ extension is not available.

This PR adds switch for making tests fail if C++ extension is not available,
and make CI for *nix fail if that's the case.
  • Loading branch information
mthrok authored Jul 31, 2020
1 parent 7f99271 commit 3bab2b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .circleci/unittest/linux/scripts/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env

python -m torch.utils.collect_env
export TORCHAUDIO_TEST_FAIL_IF_NO_EXTENSION=1
export PATH="${PWD}/third_party/install/bin/:${PATH}"

if [ "${os}" == MacOSX ] ; then
Expand Down
10 changes: 9 additions & 1 deletion test/common_utils/case_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,12 @@ def skipIfNoModule(module, display_name=None):
skipIfNoSoxBackend = unittest.skipIf(
'sox' not in torchaudio.list_audio_backends(), 'Sox backend not available')
skipIfNoCuda = unittest.skipIf(not torch.cuda.is_available(), reason='CUDA not available')
skipIfNoExtension = skipIfNoModule('torchaudio._torchaudio', 'torchaudio C++ extension')


def skipIfNoExtension(test_item):
if (
not is_module_available('torchaudio._torchaudio')
and 'TORCHAUDIO_TEST_FAIL_IF_NO_EXTENSION' in os.environ
):
raise RuntimeError('torchaudio C++ extension is not available.')
return unittest.skip('torchaudio C++ extension is not available')(test_item)

0 comments on commit 3bab2b2

Please sign in to comment.