Skip to content

Commit

Permalink
Add tests for copy annotations (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrisco authored Jun 20, 2024
1 parent 2bae5e5 commit c092f69
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion private/tests/annotations/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ py_reqs_solution_test(
py_test(
name = "annotations",
srcs = ["annotations.py"],
deps = requirements([
deps = [
"@rules_python//python/runfiles",
] + requirements([
"numpy",
"sphinx",
]),
Expand Down
26 changes: 26 additions & 0 deletions private/tests/annotations/annotations.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""The sdist integration test"""

import platform
import unittest
from pathlib import Path

from numpy import __version__ as numpy_version # pylint: disable=import-error
from rules_python.python.runfiles import Runfiles # pylint: disable=import-error
from sphinx import __version__ as sphinx_version # pylint: disable=import-error


Expand All @@ -13,6 +16,29 @@ def test_numpy_version(self) -> None:
def test_sphinx_version(self) -> None:
assert sphinx_version == "7.2.6"

def test_copy_annotations(self) -> None:
runfiles = Runfiles.Create()
assert runfiles, "Failed to locate runfiles"

expected = [
"req_compile_test_annotations_{}__numpy/site-packages/numpy/conftest.copy.py",
"req_compile_test_annotations_{}__numpy/site-packages/numpy-1.26.4.dist-info/entry_points.copy.txt",
"req_compile_test_annotations_{}__numpy/site-packages/numpy/testing/setup.copy.py",
]

platforms = {
"Darwin": "macos",
"Windows": "windows",
"Linux": "linux",
}

for rlocationpath in expected:
runfile = runfiles.Rlocation(
rlocationpath.format(platforms[platform.system()])
)
assert runfile, f"Failed to find runfile: {rlocationpath}"
assert Path(runfile).exists(), f"Runfile does not exist: {rlocationpath}"


if __name__ == "__main__":
unittest.main()
9 changes: 9 additions & 0 deletions private/tests/annotations/annotations_test_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def req_compile_test_annotations_deps():
"numpy": package_annotation(
additive_build_file_content = _NUMPY_LIBRARY_TARGET,
data = [":pkg.headers"],
copy_srcs = {
"site-packages/numpy/conftest.py": "site-packages/numpy/conftest.copy.py",
},
copy_files = {
"site-packages/numpy-1.26.4.dist-info/entry_points.txt": "site-packages/numpy-1.26.4.dist-info/entry_points.copy.txt",
},
copy_executables = {
"site-packages/numpy/testing/setup.py": "site-packages/numpy/testing/setup.copy.py",
},
),
# Sphinx is known to have a circular dependency. The annotations here solve for that.
"sphinxcontrib-applehelp": package_annotation(
Expand Down

0 comments on commit c092f69

Please sign in to comment.