Skip to content

Commit

Permalink
Integration test to reproduce
Browse files Browse the repository at this point in the history
  • Loading branch information
twm committed Jul 26, 2024
1 parent 348523c commit ba0fd83
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/incremental/tests/test_pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,24 @@ def test_fileNotFound(self):
path = os.path.join(cast(str, self.mktemp()), "pyproject.toml")
self.assertIsNone(_load_pyproject_toml(path))

def test_nameMissing(self):
def test_configMissing(self):
"""
`ValueError` is raised when ``[tool.incremental]`` is present but
he project name isn't available.
A ``pyproject.toml`` that exists but provides no relevant configuration
is ignored.
"""
for toml in [
"\n",
"[tool.notincremental]\n",
"[project]\n",
]:
self.assertIsNone(self._loadToml(toml))

def test_nameMissing(self):
"""
`ValueError` is raised when ``[tool.incremental]`` is present but
the project name isn't available.
"""
for toml in [
"[tool.incremental]\n",
"[project]\n[tool.incremental]\n",
]:
Expand Down
3 changes: 3 additions & 0 deletions tests/example_noop/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file exists, but doesn't contain any [project] or
# [tool.incremental] configuration so Incremental ignores it.
[tool.something]
13 changes: 13 additions & 0 deletions tests/example_noop/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from setuptools import setup

setup(
name="example_noop",
version="100",
packages=["example_noop"],
zip_safe=False,
setup_requires=[
# Ensure Incremental is installed for test purposes
# (but it won't do anything).
"incremental",
],
)
11 changes: 11 additions & 0 deletions tests/example_noop/src/example_noop/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
An example setuptools project that doesn't use Incremental at all.
This is used to verify that Incremental correctly deactivates itself
when there is no opt-in, even though setuptools always invokes its
hook.
"""

__version__ = "100"

__all__ = ["__version__"]
12 changes: 12 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,15 @@ def test_hatch_version_set(self):
# Hatch may wrap the output, so we are flexible about the specifics of whitespace.
suggestion.replace(b".", rb"\.").replace(b" ", b"\\s+"),
)

def test_noop(self):
"""
The Incremental setuptools hook is a silent no-op when there is no Incremental
configuration to be found.
"""
build_and_install(TEST_DIR.child("example_noop"))

import example_noop

self.assertEqual(example_noop.__version__, "100")
self.assertEqual(metadata.version("example_noop"), "100")

0 comments on commit ba0fd83

Please sign in to comment.