Skip to content

Commit

Permalink
[internal] Delete the python_integration_tests macro (pantsbuild#11830
Browse files Browse the repository at this point in the history
)

Now that we don't run tests via `pants.pex`, there is no need for the old `int-test` target we had. Removing the macro allows us to delete several unnecessary targets and to simplify our BUILD files.

We do lose the tag `integration_test`, but we never used that in CI anymore anyways.

[ci skip-rust]
[ci skip-build-wheels]
  • Loading branch information
Eric-Arellano authored Apr 2, 2021
1 parent 2c8d72c commit 403733b
Show file tree
Hide file tree
Showing 35 changed files with 98 additions and 245 deletions.
5 changes: 0 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

files(
name = '3rdparty_directory',
sources = ['3rdparty/**/*'],
)

# We use this to establish the build root, rather than `./pants`, because we cannot safely use the
# latter as the sentinel filename per https://github.com/pantsbuild/pants/pull/8105.
files(
Expand Down
6 changes: 0 additions & 6 deletions build-support/flake8/BUILD

This file was deleted.

6 changes: 0 additions & 6 deletions build-support/mypy/BUILD

This file was deleted.

6 changes: 0 additions & 6 deletions build-support/regexes/BUILD

This file was deleted.

12 changes: 0 additions & 12 deletions pants-plugins/python_integration_tests_macro.py

This file was deleted.

1 change: 0 additions & 1 deletion pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ plugins = [
# TODO: Remove the relevant `ignore_pants_warning` entry when this is bumped.
"toolchain.pants.plugin==0.7.0",
]
build_file_prelude_globs = ["pants-plugins/python_integration_tests_macro.py"]

ignore_pants_warnings = [
# TODO: Remove when `toolchain.pants.plugin` is bumped past `0.7.0`.
Expand Down
6 changes: 3 additions & 3 deletions src/python/pants/backend/python/goals/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ python_tests(
timeout=180,
)

python_integration_tests(
name='integration',
uses_pants_run=True,
python_tests(
name="integration",
sources=["*_integration_test.py"],
timeout=480,
)
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/lint/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library()
python_integration_tests(name='integration', uses_pants_run=False, timeout=180)
python_tests(name="tests", timeout=180)
7 changes: 1 addition & 6 deletions src/python/pants/backend/python/lint/bandit/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library()

python_integration_tests(
name='integration',
uses_pants_run=False,
timeout=240,
)
python_tests(name="tests", timeout=240)
7 changes: 1 addition & 6 deletions src/python/pants/backend/python/lint/black/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library()

python_integration_tests(
name='integration',
uses_pants_run=False,
timeout=240,
)
python_tests(name="tests", timeout=240)
7 changes: 1 addition & 6 deletions src/python/pants/backend/python/lint/docformatter/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library()

python_integration_tests(
name='integration',
uses_pants_run=False,
timeout=120,
)
python_tests(name="tests", timeout=120)
7 changes: 1 addition & 6 deletions src/python/pants/backend/python/lint/flake8/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library()

python_integration_tests(
name='integration',
uses_pants_run=False,
timeout=180,
)
python_tests(name="tests", timeout=180)
7 changes: 1 addition & 6 deletions src/python/pants/backend/python/lint/isort/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library()

python_integration_tests(
name='integration',
uses_pants_run=False,
timeout=120,
)
python_tests(name="tests", timeout=120)
7 changes: 1 addition & 6 deletions src/python/pants/backend/python/lint/pylint/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library()

python_integration_tests(
name='integration',
uses_pants_run=False,
timeout=330,
)
python_tests(name="tests", timeout=330)
7 changes: 1 addition & 6 deletions src/python/pants/backend/python/typecheck/mypy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library()

python_integration_tests(
name='integration',
uses_pants_run=False,
timeout=480,
)
python_tests(name="tests", timeout=480)
6 changes: 2 additions & 4 deletions src/python/pants/base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@ python_tests(
timeout=90,
)

python_integration_tests(
python_tests(
name='exception_sink_integration_test',
sources=['exception_sink_integration_test.py'],
dependencies=[
'testprojects/src/python:coordinated_runs_directory',
'testprojects/src/python:hello_directory',
'testprojects:pants_plugins_directory',
],
uses_pants_run=True,
tags=['platform_specific_behavior'],
# NB: This frequently times out, but due to hanging. So, we want to fail eagerly. See
# https://github.com/pantsbuild/pants/issues/8127.
timeout=400,
)

python_integration_tests(
python_tests(
name='exiter_integration_test',
sources=['exiter_integration_test.py'],
uses_pants_run=True,
timeout=180,
)
7 changes: 6 additions & 1 deletion src/python/pants/base/exception_sink_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ def test_logs_unhandled_exception() -> None:
directory = "testprojects/src/python/hello/main"
with temporary_dir() as tmpdir:
pants_run = run_pants_with_workdir(
["--no-pantsd", "list", f"{directory}:this-target-does-not-exist"],
[
"--no-pantsd",
"list",
f"{directory}:this-target-does-not-exist",
"--backend-packages=['pants.backend.python']",
],
workdir=tmpdir,
# The backtrace should be omitted when --print-stacktrace=False.
print_stacktrace=False,
Expand Down
28 changes: 1 addition & 27 deletions src/python/pants/bin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,4 @@ pex_binary(
emit_warnings=False,
)

# This binary is for internal use only. It adds deps on internal_plugins and build-support config
# files, both of which are not meant for publishing in the `pantsbuild.pants` sdist.
pex_binary(
name='pants_local_binary',
entry_point='pants.bin.pants_loader:main',
dependencies=[
':pants_loader',
'//:build_root',
'//:pants_toml',
'//:3rdparty_directory',
'//:pyproject',
'build-support/flake8',
'build-support/mypy',
'build-support/regexes',
'pants-plugins/internal_plugins/releases',
],
# We depend on twitter.common libraries that trigger pex warnings for not properly declaring their
# dependency on setuptools (for namespace package support).
emit_warnings=False,
# To allow for loading `native_engine.so` when built as a pex, we set zip_safe=False.
zip_safe=False,
)

python_integration_tests(
name='integration',
uses_pants_run=True,
)
python_tests(name="tests")
12 changes: 1 addition & 11 deletions src/python/pants/build_graph/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,4 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library()

python_tests(
name="tests",
sources=["*_test.py", "!*_integration_test.py"],
)

python_integration_tests(
name='integration',
uses_pants_run=True,
timeout=180,
)
python_tests(name="tests")
16 changes: 5 additions & 11 deletions src/python/pants/core/goals/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@

python_library()

python_tests(
name = "tests",
sources=['*_test.py', '!*_integration_test.py'],
)
python_tests(name="tests", sources=['*_test.py', '!*_integration_test.py'])

python_integration_tests(
name='integration',
uses_pants_run=True,
dependencies=[
'testprojects/src/python:hello_directory',
'//:pyproject',
],
python_tests(
name="integration",
sources=["*_integration_test.py"],
dependencies=['testprojects/src/python:hello_directory', '//:pyproject'],
timeout=240,
)
10 changes: 5 additions & 5 deletions src/python/pants/engine/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ python_library()
python_tests(
name='tests',
dependencies=['src/python/pants/engine/internals:fs_test_data'],
sources=["*_test.py", "!*_integration_test.py"],
sources=["*_test.py", "!streaming_workunit_handler_integration_test.py"],
timeout=90,
)

python_integration_tests(
name='integration_tests',
uses_pants_run=True,
python_tests(
name="streaming_workunit_handler_integration_test",
sources=["streaming_workunit_handler_integration_test.py"],
dependencies=[
# Loaded reflectively as a backend in `streaming_workunit_handler_integration_test.py`.
'testprojects/pants-plugins/src/python/workunit_logger',
"testprojects/pants-plugins/src/python/workunit_logger",
],
)
8 changes: 4 additions & 4 deletions src/python/pants/engine/internals/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ python_library(

python_tests(
name='tests',
sources=['*_test.py', '!*_integration_test.py'],
sources=['*_test.py', '!scheduler_integration_test.py'],
timeout=90,
)

python_integration_tests(
name='integration',
uses_pants_run=True,
python_tests(
name="scheduler_integration_test",
sources=["scheduler_integration_test.py"],
dependencies=[
'pants-plugins/internal_plugins/rules_for_testing',
'testprojects/src/python:hello_directory',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import os
import signal
from typing import List, Mapping, Tuple
from typing import Mapping

from workunit_logger.register import FINISHED_SUCCESSFULLY

Expand All @@ -28,10 +28,13 @@ def workunit_logger_config(log_dest: str) -> Mapping:
}


def run(args: List[str], success: bool = True) -> Tuple[PantsResult, str | None]:
with setup_tmpdir({}) as tmpdir:
def run(
args: list[str], success: bool = True, *, files: dict[str, str] | None = None
) -> tuple[PantsResult, str | None]:
with setup_tmpdir(files or {}) as tmpdir:
dest = os.path.join(tmpdir, "dest.log")
pants_run = run_pants(args, config=workunit_logger_config(dest))
normalized_args = [arg.format(tmpdir=tmpdir) for arg in args]
pants_run = run_pants(normalized_args, config=workunit_logger_config(dest))
log_content = maybe_read_file(dest)
if success:
pants_run.assert_success()
Expand All @@ -43,7 +46,7 @@ def run(args: List[str], success: bool = True) -> Tuple[PantsResult, str | None]


def test_list() -> None:
run(["list", "3rdparty::"])
run(["list", "{tmpdir}/foo::"], files={"foo/BUILD": "files(sources=[])"})


def test_help() -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/goal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

python_library()
python_tests(name='tests', sources=["*_test.py", "!*_integration_test.py"])
python_integration_tests(name="integration", uses_pants_run=True, timeout=120)
python_tests(name="integration", sources=["*_integration_test.py"], timeout=120)
6 changes: 1 addition & 5 deletions src/python/pants/help/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ python_tests(
dependencies=["//:build_root"],
)

python_integration_tests(
name='integration',
uses_pants_run=True,
timeout=360,
)
python_tests(name="integration", sources=["*_integration_test.py"], timeout=360)
12 changes: 2 additions & 10 deletions src/python/pants/init/BUILD
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies=[
':plugins',
],
)
python_library(dependencies=[":plugins"])

target(
name='plugins',
Expand All @@ -26,8 +22,4 @@ target(
],
)

python_integration_tests(
name="integration",
uses_pants_run=True,
timeout=200,
)
python_tests(name="tests", timeout=200)
6 changes: 0 additions & 6 deletions src/python/pants/option/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ python_library()

python_tests(
name="tests",
sources=['*_test.py', '!*_integration_test.py'],
dependencies=[
# Used by `options_bootstrapper_test` and `config_test`.
'//:build_root',
'//:pants_toml',
],
timeout=300,
)

python_integration_tests(
name='integration',
uses_pants_run=True,
)
Loading

0 comments on commit 403733b

Please sign in to comment.