diff --git a/tests/data/packages/pep517_wrapper_buildsys/mybuildsys.py b/tests/data/packages/pep517_wrapper_buildsys/mybuildsys.py index df391e96a2f..e2f920ba3f5 100644 --- a/tests/data/packages/pep517_wrapper_buildsys/mybuildsys.py +++ b/tests/data/packages/pep517_wrapper_buildsys/mybuildsys.py @@ -8,6 +8,9 @@ def build_wheel(*a, **kw): + if os.environ.get("PIP_TEST_FAIL_BUILD_WHEEL"): + raise RuntimeError("Failing build_wheel, as requested.") + # Create the marker file to record that the hook was called with open(os.environ['PIP_TEST_MARKER_FILE'], 'wb'): pass diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 8ae64319d1e..5548d792cd7 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -1256,6 +1256,7 @@ def test_cleanup_after_failed_wheel(script, with_wheel): shebang = open(script_py, 'r').readline().strip() assert shebang != '#!python', shebang # OK, assert that we *said* we were cleaning up: + # /!\ if in need to change this, also change test_pep517_no_legacy_cleanup assert "Running setup.py clean for wheelbrokenafter" in str(res), str(res) diff --git a/tests/functional/test_install_cleanup.py b/tests/functional/test_install_cleanup.py index dc87bc3f76a..c6464e3ee0b 100644 --- a/tests/functional/test_install_cleanup.py +++ b/tests/functional/test_install_cleanup.py @@ -136,3 +136,19 @@ def test_cleanup_prevented_upon_build_dir_exception(script, data): assert result.returncode == PREVIOUS_BUILD_DIR_ERROR, str(result) assert "pip can't proceed" in result.stderr, str(result) assert exists(build_simple), str(result) + + +@pytest.mark.network +def test_pep517_no_legacy_cleanup(script, data, with_wheel): + """Test a PEP 517 failed build does not attempt a legacy cleanup""" + to_install = data.packages.joinpath('pep517_wrapper_buildsys') + script.environ["PIP_TEST_FAIL_BUILD_WHEEL"] = "1" + res = script.pip( + 'install', '-f', data.find_links, to_install, + expect_error=True + ) + # Must not have built the package + expected = "Failed building wheel for pep517-wrapper-buildsys" + assert expected in str(res) + # Must not have attempted legacy cleanup + assert "setup.py clean" not in str(res)