2019-12-15 20:28:38 +01:00
|
|
|
import sys
|
|
|
|
|
|
2020-01-07 02:42:38 +00:00
|
|
|
import pytest
|
|
|
|
|
|
2019-12-15 20:28:38 +01:00
|
|
|
from cibuildwheel.__main__ import main
|
|
|
|
|
|
2020-03-28 16:25:57 +01:00
|
|
|
from conftest import MOCK_PACKAGE_DIR # noqa: I100
|
2019-12-15 20:28:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_unknown_platform_non_ci(monkeypatch, capsys):
|
|
|
|
|
monkeypatch.delenv('CI', raising=False)
|
|
|
|
|
monkeypatch.delenv('BITRISE_BUILD_NUMBER', raising=False)
|
|
|
|
|
monkeypatch.delenv('AZURE_HTTP_USER_AGENT', raising=False)
|
2020-11-23 21:17:28 +00:00
|
|
|
monkeypatch.delenv('TRAVIS', raising=False)
|
|
|
|
|
monkeypatch.delenv('APPVEYOR', raising=False)
|
|
|
|
|
monkeypatch.delenv('GITHUB_ACTIONS', raising=False)
|
|
|
|
|
monkeypatch.delenv('GITLAB_CI', raising=False)
|
|
|
|
|
monkeypatch.delenv('CIRCLECI', raising=False)
|
2020-04-10 12:18:21 +01:00
|
|
|
monkeypatch.delenv('CIBW_PLATFORM', raising=False)
|
2019-12-15 20:28:38 +01:00
|
|
|
|
|
|
|
|
with pytest.raises(SystemExit) as exit:
|
|
|
|
|
main()
|
|
|
|
|
assert exit.value.code == 2
|
|
|
|
|
_, err = capsys.readouterr()
|
|
|
|
|
|
|
|
|
|
assert 'cibuildwheel: Unable to detect platform.' in err
|
|
|
|
|
assert 'cibuildwheel should run on your CI server' in err
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_unknown_platform_on_ci(monkeypatch, capsys):
|
|
|
|
|
monkeypatch.setenv('CI', 'true')
|
|
|
|
|
monkeypatch.setattr(sys, 'platform', 'nonexistent')
|
2020-04-10 12:18:21 +01:00
|
|
|
monkeypatch.delenv('CIBW_PLATFORM', raising=False)
|
2019-12-15 20:28:38 +01:00
|
|
|
|
|
|
|
|
with pytest.raises(SystemExit) as exit:
|
|
|
|
|
main()
|
|
|
|
|
assert exit.value.code == 2
|
|
|
|
|
_, err = capsys.readouterr()
|
|
|
|
|
|
|
|
|
|
assert 'cibuildwheel: Unable to detect platform from "sys.platform"' in err
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_unknown_platform(monkeypatch, capsys):
|
|
|
|
|
monkeypatch.setenv('CIBW_PLATFORM', 'nonexistent')
|
|
|
|
|
|
|
|
|
|
with pytest.raises(SystemExit) as exit:
|
|
|
|
|
main()
|
|
|
|
|
_, err = capsys.readouterr()
|
|
|
|
|
|
|
|
|
|
assert exit.value.code == 2
|
|
|
|
|
assert 'cibuildwheel: Unsupported platform: nonexistent' in err
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_platform_argument(platform, intercepted_build_args, monkeypatch):
|
2019-12-16 11:32:09 +01:00
|
|
|
monkeypatch.setenv('CIBW_PLATFORM', 'nonexistent')
|
2019-12-15 20:28:38 +01:00
|
|
|
monkeypatch.setattr(sys, 'argv', sys.argv + ['--platform', platform])
|
|
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|
2020-04-09 14:05:09 +01:00
|
|
|
assert intercepted_build_args.args[0].package_dir == MOCK_PACKAGE_DIR
|
2019-12-15 20:28:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_platform_environment(platform, intercepted_build_args, monkeypatch):
|
|
|
|
|
main()
|
|
|
|
|
|
2020-04-09 14:05:09 +01:00
|
|
|
assert intercepted_build_args.args[0].package_dir == MOCK_PACKAGE_DIR
|