diff --git a/.circleci/unittest/linux/scripts/run_test.sh b/.circleci/unittest/linux/scripts/run_test.sh index 2945b56194..63bd5aa52d 100755 --- a/.circleci/unittest/linux/scripts/run_test.sh +++ b/.circleci/unittest/linux/scripts/run_test.sh @@ -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 diff --git a/test/common_utils/case_utils.py b/test/common_utils/case_utils.py index 9c89ef6891..ad68eb4f52 100644 --- a/test/common_utils/case_utils.py +++ b/test/common_utils/case_utils.py @@ -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)