Files
gpr/bindings/python/tests/tests_gpr2/source_test.py
2025-10-16 14:38:53 +00:00

65 lines
2.1 KiB
Python

from gpr2.tree import ProjectTree, Options
from e3.fs import rm
import os
import pytest
@pytest.mark.data_dir("simple_project_with_ali")
def test_source_dependencies():
with ProjectTree(Options("p.gpr")) as tree:
tree.update_sources()
view = tree.root_project
sources = view.sources
assert len(sources) == 5
main = next(
source for source in sources if os.path.basename(source.path_name) == "main.adb"
)
# # We have some .ali files so we expect to get information from them
# assert len(main.dependencies) == 4
# assert {os.path.basename(s.path) for s in main.dependencies} == {
# "ada_pkg1.ads",
# "ada_pkg2.ads",
# "ada_pkg3.ads",
# "main.adb",
# }
# # Remove the .ali files
# rm("*.ali")
# # Update the dependencies
# main.update_dependencies(allow_source_parsing=False)
# # Why do we still have them with previous value ?
# assert len(main.dependencies) == 4
# assert {os.path.basename(s.path) for s in main.dependencies} == {
# "ada_pkg1.ads",
# "ada_pkg2.ads",
# "ada_pkg3.ads",
# "main.adb",
# }
# # Force full source invalidation
# tree.invalidate_source_list()
# tree.update_source_list()
# # Recompute the deps for main.adb
# sources = view.sources()
# main = next(
# source for source in sources if os.path.basename(source.path) == "main.adb"
# )
# # Seems that source parsing is enabled even when not selected. Result is very
# # distinct.
# # If there is no ALI file we should not have any dep information
# assert len(main.dependencies) == 0
# # Update source_infos using source parsing
# main.update_dependencies(allow_source_parsing=True)
# assert {os.path.basename(s.path) for s in main.dependencies} == {
# "ada_pkg1.ads",
# "ada_pkg2.ads",
# "main.adb",
# }