|
22 | 22 | from pants.source.source_root import rules as source_root_rules |
23 | 23 | from pants.testutil.option_util import create_subsystem |
24 | 24 | from pants.testutil.rule_runner import RuleRunner, run_rule_with_mocks |
| 25 | +from pants.util.frozendict import FrozenDict |
25 | 26 |
|
26 | 27 |
|
27 | 28 | def _find_root( |
@@ -287,3 +288,26 @@ def test_source_roots_request() -> None: |
287 | 288 | PurePath("src/python/foo"): SourceRoot("src/python"), |
288 | 289 | PurePath("src/python/baz/qux"): SourceRoot("src/python"), |
289 | 290 | } == dict(res.path_to_root) |
| 291 | + |
| 292 | + |
| 293 | +def test_root_to_paths() -> None: |
| 294 | + res = SourceRootsResult( |
| 295 | + FrozenDict( |
| 296 | + { |
| 297 | + PurePath("src/python/foo/bar.py"): SourceRoot("src/python"), |
| 298 | + PurePath("tests/python/foo/bar_test.py"): SourceRoot("tests/python"), |
| 299 | + PurePath("src/python/foo"): SourceRoot("src/python"), |
| 300 | + PurePath("src/python/baz/qux"): SourceRoot("src/python"), |
| 301 | + } |
| 302 | + ) |
| 303 | + ) |
| 304 | + assert res.root_to_paths() == FrozenDict( |
| 305 | + { |
| 306 | + SourceRoot("src/python"): ( |
| 307 | + PurePath("src/python/baz/qux"), |
| 308 | + PurePath("src/python/foo"), |
| 309 | + PurePath("src/python/foo/bar.py"), |
| 310 | + ), |
| 311 | + SourceRoot("tests/python"): (PurePath("tests/python/foo/bar_test.py"),), |
| 312 | + } |
| 313 | + ) |
0 commit comments