Skip to content

Commit

Permalink
Re-enable tests that were flaky in the past. (pantsbuild#19845)
Browse files Browse the repository at this point in the history
We want to see if they still are, and fix if so.

For context see pantsbuild#6787, pantsbuild#8520
  • Loading branch information
benjyw authored Sep 16, 2023
1 parent cdf8023 commit ee5003c
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions tests/python/pants_test/integration/graph_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

import os
import unittest
from contextlib import contextmanager
from pathlib import Path
from textwrap import dedent
from typing import Iterator

import pytest

from pants.option.scope import GLOBAL_SCOPE_CONFIG_SECTION
from pants.testutil.pants_integration_test import run_pants
from pants.util.contextutil import overwrite_file_content
Expand All @@ -18,16 +15,8 @@
_SOURCES_TARGET_BASE = "testprojects/src/python/sources"

_ERR_TARGETS = {
"testprojects/src/python/sources:some-missing-some-not": [
"['*.txt', '*.rs']",
"Snapshot(PathGlobs(globs=('testprojects/src/python/sources/*.txt', 'testprojects/src/python/sources/*.rs'), glob_match_error_behavior<Exactly(GlobMatchErrorBehavior)>=GlobMatchErrorBehavior(value=error), conjunction<Exactly(GlobExpansionConjunction)>=GlobExpansionConjunction(value=all_match)))",
'Unmatched glob from testprojects/src/python/sources:some-missing-some-not\'s `sources` field: "testprojects/src/python/sources/*.rs"',
],
"testprojects/src/python/sources:missing-sources": [
"*.scala",
"Snapshot(PathGlobs(globs=('testprojects/src/python/sources/*.scala', '!testprojects/src/python/sources/*Test.scala', '!testprojects/src/python/sources/*Spec.scala'), glob_match_error_behavior<Exactly(GlobMatchErrorBehavior)>=GlobMatchErrorBehavior(value=error), conjunction<Exactly(GlobExpansionConjunction)>=GlobExpansionConjunction(value=any_match)))",
'Unmatched glob from testprojects/src/python/sources:missing-sources\'s `sources` field:: "testprojects/src/python/sources/*.scala", excludes: ["testprojects/src/python/sources/*Test.scala", "testprojects/src/python/sources/*Spec.scala"]',
],
"testprojects/src/python/sources:some-missing-some-not": 'Unmatched glob from testprojects/src/python/sources:some-missing-some-not\'s `sources` field: "testprojects/src/python/sources/*.rs"',
"testprojects/src/python/sources:missing-sources": 'Unmatched glob from testprojects/src/python/sources:missing-sources\'s `sources` field: "testprojects/src/python/sources/*.scala", excludes: ["testprojects/src/python/sources/*Spec.scala", "testprojects/src/python/sources/*Suite.scala", "testprojects/src/python/sources/*Test.scala"]',
}


Expand All @@ -37,7 +26,7 @@ def setup_sources_targets() -> Iterator[None]:
original_content = build_path.read_text()
new_content = dedent(
"""\
scala_library(
scala_sources(
name='missing-sources',
)
Expand Down Expand Up @@ -74,8 +63,16 @@ def setup_sources_targets() -> Iterator[None]:
yield


@unittest.skip("flaky: https://github.com/pantsbuild/pants/issues/8520")
@pytest.mark.no_error_if_skipped
def _config(warn_on_unmatched_globs: bool) -> dict:
return {
GLOBAL_SCOPE_CONFIG_SECTION: {
"backend_packages": ["pants.backend.python", "pants.backend.experimental.scala"],
"unmatched_build_file_globs": "warn" if warn_on_unmatched_globs else "error",
}
}


# See https://github.com/pantsbuild/pants/issues/8520 for past flakiness of this test.
def test_missing_sources_warnings():
target_to_unmatched_globs = {
"missing-globs": ["*.a"],
Expand All @@ -87,7 +84,7 @@ def test_missing_sources_warnings():
target_full = f"{_SOURCES_TARGET_BASE}:{target}"
pants_run = run_pants(
["filedeps", target_full],
config={GLOBAL_SCOPE_CONFIG_SECTION: {"unmatched_build_file_globs": "warn"}},
config=_config(warn_on_unmatched_globs=True),
)
pants_run.assert_success()
unmatched_globs = target_to_unmatched_globs[target]
Expand All @@ -106,28 +103,25 @@ def test_missing_sources_warnings():
)


@unittest.skip("flaky: https://github.com/pantsbuild/pants/issues/8520")
@pytest.mark.no_error_if_skipped
# See https://github.com/pantsbuild/pants/issues/8520 for past flakiness of this test.
def test_existing_sources():
target_full = f"{_SOURCES_TARGET_BASE}:text"
pants_run = run_pants(
["filedeps", target_full],
config={GLOBAL_SCOPE_CONFIG_SECTION: {"unmatched_build_file_globs": "warn"}},
config=_config(warn_on_unmatched_globs=True),
)
pants_run.assert_success()
assert "[WARN] Unmatched glob" not in pants_run.stderr


@unittest.skip("flaky: https://github.com/pantsbuild/pants/issues/6787")
@pytest.mark.no_error_if_skipped
# See https://github.com/pantsbuild/pants/issues/6787 for past flakiness of this test.
def test_error_message():
with setup_sources_targets():
for target in _ERR_TARGETS:
expected_excerpts = _ERR_TARGETS[target]
expected_excerpt = _ERR_TARGETS[target]
pants_run = run_pants(
["filedeps", target],
config={GLOBAL_SCOPE_CONFIG_SECTION: {"unmatched_build_file_globs": "error"}},
config=_config(warn_on_unmatched_globs=False),
)
pants_run.assert_failure()
for excerpt in expected_excerpts:
assert excerpt in pants_run.stderr
assert expected_excerpt in pants_run.stderr

0 comments on commit ee5003c

Please sign in to comment.