forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for rule graph issues with each distinct backend (pantsbuild#10519)
We want to make sure that no matter what combination of backend packages you have loaded, Pants will not error due to issues with the rule graph. Closes pantsbuild#10430. [ci skip-rust] [ci skip-build-wheels]
- Loading branch information
1 parent
12b0217
commit 2b98738
Showing
4 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from pathlib import Path | ||
from typing import List | ||
|
||
from pants.testutil.pants_run_integration_test import PantsRunIntegrationTest | ||
|
||
|
||
class LoadBackendsIntegrationTest(PantsRunIntegrationTest): | ||
"""Ensure that the rule graph can be loaded properly for each backend.""" | ||
|
||
@staticmethod | ||
def discover_backends() -> List[str]: | ||
register_pys = Path().glob("src/python/**/register.py") | ||
backends = { | ||
str(register_py.parent).replace("src/python/", "").replace("/", ".") | ||
for register_py in register_pys | ||
} | ||
always_activated = {"pants.core", "pants.backend.project_info", "pants.backend.pants_info"} | ||
return sorted(backends - always_activated) | ||
|
||
def assert_backends_load(self, backends: List[str]) -> None: | ||
result = self.run_pants( | ||
["--no-verify-config", "--version"], config={"GLOBAL": {"backend_packages": backends}} | ||
) | ||
self.assert_success(result, msg=f"Failed to load: {backends}") | ||
|
||
def test_no_backends_loaded(self) -> None: | ||
self.assert_backends_load([]) | ||
|
||
def test_all_backends_loaded(self) -> None: | ||
"""This should catch all ambiguity issues.""" | ||
all_backends = self.discover_backends() | ||
self.assert_backends_load(all_backends) | ||
|
||
def test_each_distinct_backend_loads(self) -> None: | ||
"""This should catch graph incompleteness errors, i.e. when a required rule is not | ||
registered.""" | ||
for backend in self.discover_backends(): | ||
self.assert_backends_load([backend]) |