Merge pull request #418 from joerick/add-troubleshoot-test
Add troubleshoot test
This commit is contained in:
@@ -233,8 +233,8 @@ def build(options: BuildOptions) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def troubleshoot(package_dir: Path, error: Exception) -> None:
|
def troubleshoot(package_dir: Path, error: Exception) -> None:
|
||||||
if (isinstance(error, subprocess.CalledProcessError) and 'exec' in error.cmd):
|
if (isinstance(error, subprocess.CalledProcessError) and error.cmd[0:2] == ['pip', 'wheel']):
|
||||||
# the bash script failed
|
# the 'pip wheel' step failed.
|
||||||
print('Checking for common errors...')
|
print('Checking for common errors...')
|
||||||
so_files = list(package_dir.glob('**/*.so'))
|
so_files = list(package_dir.glob('**/*.so'))
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ def troubleshoot(package_dir: Path, error: Exception) -> None:
|
|||||||
|
|
||||||
If you're using Cython and have previously done an in-place build,
|
If you're using Cython and have previously done an in-place build,
|
||||||
remove those build files (*.so and *.c) before starting cibuildwheel.
|
remove those build files (*.so and *.c) before starting cibuildwheel.
|
||||||
'''))
|
'''), file=sys.stderr)
|
||||||
|
|
||||||
print(' Files detected:')
|
print(' Files detected:')
|
||||||
print('\n'.join([f' {f}' for f in so_files]))
|
print('\n'.join([f' {f}' for f in so_files]))
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import subprocess
|
||||||
|
import pytest
|
||||||
|
from .test_projects import TestProject
|
||||||
|
from . import utils
|
||||||
|
|
||||||
|
so_file_project = TestProject()
|
||||||
|
|
||||||
|
so_file_project.files['libnothing.so'] = ''
|
||||||
|
|
||||||
|
so_file_project.files['setup.py'] = '''
|
||||||
|
raise Exception('this build will fail')
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
def test_failed_project_with_so_files(tmp_path, capfd):
|
||||||
|
if utils.platform != 'linux':
|
||||||
|
pytest.skip('this test is only relevant to the linux build')
|
||||||
|
|
||||||
|
project_dir = tmp_path / 'project'
|
||||||
|
so_file_project.generate(project_dir)
|
||||||
|
|
||||||
|
with pytest.raises(subprocess.CalledProcessError):
|
||||||
|
utils.cibuildwheel_run(project_dir)
|
||||||
|
|
||||||
|
captured = capfd.readouterr()
|
||||||
|
print('out', captured.out)
|
||||||
|
print('err', captured.err)
|
||||||
|
assert "NOTE: Shared object (.so) files found in this project." in captured.err
|
||||||
Reference in New Issue
Block a user