Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for copy annotations #77

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading