Skip to content

Commit

Permalink
Merge 43bb246 into 6aee379
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Arellano committed Aug 24, 2020
2 parents 6aee379 + 43bb246 commit 7fbb62e
Show file tree
Hide file tree
Showing 42 changed files with 335 additions and 351 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from pants.engine.rules import QueryRule
from pants.engine.target import WrappedTarget
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.testutil.engine_util import Params
from pants.testutil.external_tool_test_base import ExternalToolTestBase
from pants.testutil.option_util import create_options_bootstrapper

Expand All @@ -41,14 +40,12 @@ def create_python_awslambda(self, addr: str) -> Tuple[str, bytes]:
"--source-root-patterns=src/python",
]
)
target = self.request_product(
WrappedTarget, Params(Address.parse(addr), bootstrapper)
).target
target = self.request_product(WrappedTarget, [Address.parse(addr), bootstrapper]).target
created_awslambda = self.request_product(
CreatedAWSLambda, Params(PythonAwsLambdaFieldSet.create(target), bootstrapper)
CreatedAWSLambda, [PythonAwsLambdaFieldSet.create(target), bootstrapper]
)
created_awslambda_digest_contents = self.request_product(
DigestContents, created_awslambda.digest
DigestContents, [created_awslambda.digest]
)
assert len(created_awslambda_digest_contents) == 1
return created_awslambda.zip_file_relpath, created_awslambda_digest_contents[0].content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
)
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.source.source_root import NoSourceRootError
from pants.testutil.engine_util import Params
from pants.testutil.external_tool_test_base import ExternalToolTestBase
from pants.testutil.option_util import create_options_bootstrapper

Expand Down Expand Up @@ -54,13 +53,13 @@ def assert_files_generated(
f"--source-root-patterns={repr(source_roots)}",
]
)
tgt = self.request_product(WrappedTarget, Params(Address.parse(spec), bootstrapper)).target
tgt = self.request_product(WrappedTarget, [Address.parse(spec), bootstrapper]).target
protocol_sources = self.request_product(
HydratedSources, Params(HydrateSourcesRequest(tgt[ProtobufSources]), bootstrapper),
HydratedSources, [HydrateSourcesRequest(tgt[ProtobufSources]), bootstrapper],
)
generated_sources = self.request_product(
GeneratedSources,
Params(GeneratePythonFromProtobufRequest(protocol_sources.snapshot, tgt), bootstrapper),
[GeneratePythonFromProtobufRequest(protocol_sources.snapshot, tgt), bootstrapper],
)
assert set(generated_sources.snapshot.files) == set(expected_files)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from pants.engine.addresses import Address
from pants.engine.rules import QueryRule
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.testutil.engine_util import Params
from pants.testutil.option_util import create_options_bootstrapper
from pants.testutil.test_base import TestBase
from pants.util.frozendict import FrozenDict
Expand Down Expand Up @@ -108,7 +107,7 @@ def test_map_first_party_modules_to_addresses(self) -> None:
# not generate subtargets.
self.create_file("tests/python/project_test/demo_test/__init__.py")
self.add_to_build_file("tests/python/project_test/demo_test", "python_library()")
result = self.request_product(FirstPartyModuleToAddressMapping, options_bootstrapper)
result = self.request_product(FirstPartyModuleToAddressMapping, [options_bootstrapper])
assert result.mapping == FrozenDict(
{
"project.util.dirutil": Address(
Expand Down Expand Up @@ -149,7 +148,7 @@ def test_map_third_party_modules_to_addresses(self) -> None:
),
)
result = self.request_product(
ThirdPartyModuleToAddressMapping, Params(create_options_bootstrapper())
ThirdPartyModuleToAddressMapping, [create_options_bootstrapper()]
)
assert result.mapping == FrozenDict(
{
Expand All @@ -166,7 +165,7 @@ def test_map_module_to_address(self) -> None:

def get_owner(module: str) -> Optional[Address]:
return self.request_product(
PythonModuleOwner, Params(PythonModule(module), options_bootstrapper)
PythonModuleOwner, [PythonModule(module), options_bootstrapper]
).address

# First check that we can map 3rd-party modules.
Expand Down
19 changes: 6 additions & 13 deletions src/python/pants/backend/python/dependency_inference/rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from pants.engine.target import InferredDependencies, WrappedTarget
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.source.source_root import all_roots
from pants.testutil.engine_util import Params
from pants.testutil.option_util import create_options_bootstrapper
from pants.testutil.test_base import TestBase

Expand Down Expand Up @@ -96,12 +95,10 @@ def run_dep_inference(
if enable_string_imports:
args.append("--python-infer-string-imports")
options_bootstrapper = create_options_bootstrapper(args=args)
target = self.request_product(
WrappedTarget, Params(address, options_bootstrapper)
).target
target = self.request_product(WrappedTarget, [address, options_bootstrapper]).target
return self.request_product(
InferredDependencies,
Params(InferPythonDependencies(target[PythonSources]), options_bootstrapper),
[InferPythonDependencies(target[PythonSources]), options_bootstrapper],
)

normal_address = Address("src/python")
Expand Down Expand Up @@ -146,12 +143,10 @@ def test_infer_python_inits(self) -> None:
self.add_to_build_file("src/python/root/mid/leaf", "python_library()")

def run_dep_inference(address: Address) -> InferredDependencies:
target = self.request_product(
WrappedTarget, Params(address, options_bootstrapper)
).target
target = self.request_product(WrappedTarget, [address, options_bootstrapper]).target
return self.request_product(
InferredDependencies,
Params(InferInitDependencies(target[PythonSources]), options_bootstrapper),
[InferInitDependencies(target[PythonSources]), options_bootstrapper],
)

assert run_dep_inference(Address.parse("src/python/root/mid/leaf")) == InferredDependencies(
Expand All @@ -178,12 +173,10 @@ def test_infer_python_conftests(self) -> None:
self.add_to_build_file("src/python/root/mid/leaf", "python_tests()")

def run_dep_inference(address: Address) -> InferredDependencies:
target = self.request_product(
WrappedTarget, Params(address, options_bootstrapper)
).target
target = self.request_product(WrappedTarget, [address, options_bootstrapper]).target
return self.request_product(
InferredDependencies,
Params(InferConftestDependencies(target[PythonSources]), options_bootstrapper),
[InferConftestDependencies(target[PythonSources]), options_bootstrapper],
)

assert run_dep_inference(Address.parse("src/python/root/mid/leaf")) == InferredDependencies(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pants.engine.rules import QueryRule
from pants.engine.target import Target
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.testutil.engine_util import Params
from pants.testutil.external_tool_test_base import ExternalToolTestBase
from pants.testutil.option_util import create_options_bootstrapper
from pants.testutil.python_interpreter_selection import skip_unless_python27_and_python3_present
Expand Down Expand Up @@ -64,10 +63,10 @@ def run_bandit(
args.extend(additional_args)
results = self.request_product(
LintResults,
Params(
[
BanditRequest(BanditFieldSet.create(tgt) for tgt in targets),
create_options_bootstrapper(args=args),
),
],
)
return results.results

Expand Down Expand Up @@ -185,7 +184,7 @@ def test_report_file(self) -> None:
assert result[0].exit_code == 1
assert result[0].stdout.strip() == ""
assert result[0].report is not None
report_files = self.request_product(DigestContents, result[0].report.digest)
report_files = self.request_product(DigestContents, [result[0].report.digest])
assert len(report_files) == 1
assert (
"Issue: [B303:blacklist] Use of insecure MD2, MD4, MD5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from pants.engine.rules import QueryRule
from pants.engine.target import Target
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.testutil.engine_util import Params
from pants.testutil.external_tool_test_base import ExternalToolTestBase
from pants.testutil.option_util import create_options_bootstrapper

Expand Down Expand Up @@ -62,26 +61,26 @@ def run_black(
options_bootstrapper = create_options_bootstrapper(args=args)
field_sets = [BlackFieldSet.create(tgt) for tgt in targets]
lint_results = self.request_product(
LintResults, Params(BlackRequest(field_sets), options_bootstrapper)
LintResults, [BlackRequest(field_sets), options_bootstrapper]
)
input_sources = self.request_product(
SourceFiles,
Params(
[
SourceFilesRequest(field_set.sources for field_set in field_sets),
options_bootstrapper,
),
],
)
fmt_result = self.request_product(
FmtResult,
Params(
[
BlackRequest(field_sets, prior_formatter_result=input_sources.snapshot),
options_bootstrapper,
),
],
)
return lint_results.results, fmt_result

def get_digest(self, source_files: List[FileContent]) -> Digest:
return self.request_product(Digest, CreateDigest(source_files))
return self.request_product(Digest, [CreateDigest(source_files)])

def test_passing_source(self) -> None:
target = self.make_target([self.good_source])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from pants.engine.rules import QueryRule
from pants.engine.target import Target
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.testutil.engine_util import Params
from pants.testutil.external_tool_test_base import ExternalToolTestBase
from pants.testutil.option_util import create_options_bootstrapper

Expand Down Expand Up @@ -51,26 +50,26 @@ def run_docformatter(
options_bootstrapper = create_options_bootstrapper(args=args)
field_sets = [DocformatterFieldSet.create(tgt) for tgt in targets]
lint_results = self.request_product(
LintResults, Params(DocformatterRequest(field_sets), options_bootstrapper)
LintResults, [DocformatterRequest(field_sets), options_bootstrapper]
)
input_sources = self.request_product(
SourceFiles,
Params(
[
SourceFilesRequest(field_set.sources for field_set in field_sets),
options_bootstrapper,
),
],
)
fmt_result = self.request_product(
FmtResult,
Params(
[
DocformatterRequest(field_sets, prior_formatter_result=input_sources.snapshot),
options_bootstrapper,
),
],
)
return lint_results.results, fmt_result

def get_digest(self, source_files: List[FileContent]) -> Digest:
return self.request_product(Digest, CreateDigest(source_files))
return self.request_product(Digest, [CreateDigest(source_files)])

def test_passing_source(self) -> None:
target = self.make_target([self.good_source])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pants.engine.rules import QueryRule
from pants.engine.target import Target
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.testutil.engine_util import Params
from pants.testutil.external_tool_test_base import ExternalToolTestBase
from pants.testutil.option_util import create_options_bootstrapper
from pants.testutil.python_interpreter_selection import skip_unless_python27_and_python3_present
Expand Down Expand Up @@ -63,10 +62,10 @@ def run_flake8(
args.extend(additional_args)
results = self.request_product(
LintResults,
Params(
[
Flake8Request(Flake8FieldSet.create(tgt) for tgt in targets),
create_options_bootstrapper(args=args),
),
],
)
return results.results

Expand Down Expand Up @@ -173,6 +172,6 @@ def test_report_file(self) -> None:
assert result[0].exit_code == 1
assert result[0].stdout.strip() == ""
assert result[0].report is not None
report_files = self.request_product(DigestContents, result[0].report.digest)
report_files = self.request_product(DigestContents, [result[0].report.digest])
assert len(report_files) == 1
assert "bad.py:1:1: F401" in report_files[0].content.decode()
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from pants.engine.rules import QueryRule
from pants.engine.target import Target
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.testutil.engine_util import Params
from pants.testutil.external_tool_test_base import ExternalToolTestBase
from pants.testutil.option_util import create_options_bootstrapper

Expand Down Expand Up @@ -69,26 +68,26 @@ def run_isort(
options_bootstrapper = create_options_bootstrapper(args=args)
field_sets = [IsortFieldSet.create(tgt) for tgt in targets]
lint_results = self.request_product(
LintResults, Params(IsortRequest(field_sets), options_bootstrapper)
LintResults, [IsortRequest(field_sets), options_bootstrapper]
)
input_sources = self.request_product(
SourceFiles,
Params(
[
SourceFilesRequest(field_set.sources for field_set in field_sets),
options_bootstrapper,
),
],
)
fmt_result = self.request_product(
FmtResult,
Params(
[
IsortRequest(field_sets, prior_formatter_result=input_sources.snapshot),
options_bootstrapper,
),
],
)
return lint_results.results, fmt_result

def get_digest(self, source_files: List[FileContent]) -> Digest:
return self.request_product(Digest, CreateDigest(source_files))
return self.request_product(Digest, [CreateDigest(source_files)])

def test_passing_source(self) -> None:
target = self.make_target_with_origin([self.good_source])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from pants.engine.rules import QueryRule
from pants.engine.target import Target, WrappedTarget
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.testutil.engine_util import Params
from pants.testutil.external_tool_test_base import ExternalToolTestBase
from pants.testutil.option_util import create_options_bootstrapper
from pants.testutil.python_interpreter_selection import skip_unless_python27_and_python3_present
Expand Down Expand Up @@ -76,10 +75,10 @@ def make_target(
)
return self.request_product(
WrappedTarget,
Params(
[
Address(package, target_name=name),
create_options_bootstrapper(args=self.global_args),
),
],
).target

def run_pylint(
Expand All @@ -103,10 +102,10 @@ def run_pylint(
args.extend(additional_args)
results = self.request_product(
LintResults,
Params(
[
PylintRequest(PylintFieldSet.create(tgt) for tgt in targets),
create_options_bootstrapper(args=args),
),
],
)
return results.results

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from pants.engine.rules import QueryRule
from pants.engine.target import Targets
from pants.option.options_bootstrapper import OptionsBootstrapper
from pants.testutil.engine_util import Params
from pants.testutil.external_tool_test_base import ExternalToolTestBase
from pants.testutil.option_util import create_options_bootstrapper

Expand Down Expand Up @@ -42,12 +41,12 @@ def run_black_and_isort(
*(extra_args or []),
]
results = self.request_product(
LanguageFmtResults, Params(targets, create_options_bootstrapper(args=args)),
LanguageFmtResults, [targets, create_options_bootstrapper(args=args)],
)
return results

def get_digest(self, source_files: List[FileContent]) -> Digest:
return self.request_product(Digest, CreateDigest(source_files))
return self.request_product(Digest, [CreateDigest(source_files)])

def test_multiple_formatters_changing_the_same_file(self) -> None:
original_source = FileContent(
Expand Down
5 changes: 2 additions & 3 deletions src/python/pants/backend/python/pants_requirement_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from pants.engine.addresses import Address
from pants.engine.internals.scheduler import ExecutionError
from pants.engine.target import WrappedTarget
from pants.testutil.engine_util import Params
from pants.testutil.option_util import create_options_bootstrapper
from pants.testutil.test_base import TestBase
from pants.util.frozendict import FrozenDict
Expand Down Expand Up @@ -43,10 +42,10 @@ def assert_pants_requirement(
self.add_to_build_file("3rdparty/python", f"{build_file_entry}\n")
target = self.request_product(
WrappedTarget,
Params(
[
Address("3rdparty/python", target_name=expected_target_name),
create_options_bootstrapper(),
),
],
).target
assert isinstance(target, PythonRequirementLibrary)
assert target[PythonRequirementsField].value == (
Expand Down

0 comments on commit 7fbb62e

Please sign in to comment.