Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/tools/cultural_gauntlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ def _run_cell(args: tuple[Any, ...]) -> dict[str, Any]:
dbs = layers[1] if len(layers) > 1 else None # part 3 (D): --db's {target: spec}
os.environ.setdefault("GITGALAXY_LICENSE_KEY", "COMMUNITY_FREE_TIER") # a pool process of its own
os.environ["GITGALAXY_DISABLE_GIT_HISTORY"] = "1"
os.environ.setdefault("GALAXYSCOPE_MAX_WORKERS", "1") # one scan per pool process: no pool inside (#4896)
cell_dir = Path(work) / f"{dialect}__{column}"
observe = _observe_collation if dialect in COLLATION_TARGETS else _observe_input if dialect in INPUT_FORMATS \
else _observe # fmt: skip
Expand Down
1 change: 1 addition & 0 deletions tests/tools/import_graph_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@ def scan_group(group_dir: Path, out_dir: Path) -> tuple[dict[str, str], set[tupl
for one group, scanned in a subprocess pinned to THIS checkout (the console-script trap)."""
env = {k: v for k, v in os.environ.items() if k != "PYTHONPATH"}
env.update(PYTHONPATH=str(REPO_ROOT), GITGALAXY_DISABLE_GIT_HISTORY="1")
env.setdefault("GALAXYSCOPE_MAX_WORKERS", "1") # scan_group runs --jobs at a time: no pool inside (#4896)
out_dir.mkdir(parents=True, exist_ok=True)
proc = subprocess.run(
[sys.executable, "-c", _SCAN, str(REPO_ROOT), str(group_dir), str(out_dir / "g.json")],
Expand Down
45 changes: 45 additions & 0 deletions tests/tools/test_unicode_gauntlet_scan_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""The gauntlet runs --jobs scans at once, so each scan must stay single-worker (#4896, #3913)."""

import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent))

import unicode_gauntlet as ug # noqa: E402


def _scan_env(monkeypatch, tmp_path, preset=None):
import gitgalaxy.tools.cobol_to_cobol.galaxy_ir as ir

seen = {}

def fake(estate, out, extra_args=()):
import os

seen["workers"] = os.environ.get("GALAXYSCOPE_MAX_WORKERS")
return out

monkeypatch.setattr(ir, "scan_to_db", fake)
monkeypatch.delenv("GALAXYSCOPE_MAX_WORKERS", raising=False)
if preset:
monkeypatch.setenv("GALAXYSCOPE_MAX_WORKERS", preset)
ug.scan(tmp_path / "e__utf-8", tmp_path / "out")
return seen["workers"]


def test_scan_env_pins_one_worker(monkeypatch, tmp_path):
assert _scan_env(monkeypatch, tmp_path) == "1"


def test_scan_env_respects_explicit_value_and_restores(monkeypatch, tmp_path):
import os

assert _scan_env(monkeypatch, tmp_path, preset="3") == "3"
assert os.environ["GALAXYSCOPE_MAX_WORKERS"] == "3"


def test_scan_env_does_not_leak(monkeypatch, tmp_path):
import os

_scan_env(monkeypatch, tmp_path)
assert "GALAXYSCOPE_MAX_WORKERS" not in os.environ
5 changes: 4 additions & 1 deletion tests/tools/unicode_gauntlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@ def scan(estate: Path, out: Path) -> Path:

# set for the scan only: a process-wide GITGALAXY_DISABLE_GIT_HISTORY outlives it and silently
# turns git off for every later test in a pytest session (it once broke test_chronometer)
keys = ("GITGALAXY_LICENSE_KEY", "GITGALAXY_DISABLE_GIT_HISTORY")
keys = ("GITGALAXY_LICENSE_KEY", "GITGALAXY_DISABLE_GIT_HISTORY", "GALAXYSCOPE_MAX_WORKERS")
saved = {k: os.environ.get(k) for k in keys}
os.environ.setdefault("GITGALAXY_LICENSE_KEY", "COMMUNITY_FREE_TIER")
# --jobs scans already fill the box: a worker pool inside each one is N x N processes (#4896,
# #3913). An explicit value from the caller wins.
os.environ.setdefault("GALAXYSCOPE_MAX_WORKERS", "1")
os.environ["GITGALAXY_DISABLE_GIT_HISTORY"] = "1"
codec = estate.name.rpartition("__")[2]
try:
Expand Down
Loading