Skip to content

Commit 3bab2b2

Browse files
authored
[CI] Make *nix unit test fail if C++ extension is not available (#847)
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.
1 parent 7f99271 commit 3bab2b2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.circleci/unittest/linux/scripts/run_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ eval "$(./conda/bin/conda shell.bash hook)"
1212
conda activate ./env
1313

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

1718
if [ "${os}" == MacOSX ] ; then

test/common_utils/case_utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,12 @@ def skipIfNoModule(module, display_name=None):
6767
skipIfNoSoxBackend = unittest.skipIf(
6868
'sox' not in torchaudio.list_audio_backends(), 'Sox backend not available')
6969
skipIfNoCuda = unittest.skipIf(not torch.cuda.is_available(), reason='CUDA not available')
70-
skipIfNoExtension = skipIfNoModule('torchaudio._torchaudio', 'torchaudio C++ extension')
70+
71+
72+
def skipIfNoExtension(test_item):
73+
if (
74+
not is_module_available('torchaudio._torchaudio')
75+
and 'TORCHAUDIO_TEST_FAIL_IF_NO_EXTENSION' in os.environ
76+
):
77+
raise RuntimeError('torchaudio C++ extension is not available.')
78+
return unittest.skip('torchaudio C++ extension is not available')(test_item)

0 commit comments

Comments
 (0)