Skip to content

[maintainability] Python-interpreter discovery is duplicated (with drift) across 3 test files #63

Description

@corgab

Summary

The same foreach (['python3', 'python'] as $candidate) { $which = shell_exec("which {$candidate} 2>/dev/null"); ... } interpreter-discovery block, followed by a skip-or-fail decision, is duplicated across three test files with small, real divergences:

  • tests/Unit/Bridge/PythonBridgeTest.php:52-60 — discovers, then always markTestSkipped() if absent (no CI-fail branch)
  • tests/Feature/GateParityTest.php:21-33 — discovers, then test()->fail(...) if getenv('CI') !== false, else skip
  • tests/Feature/CustomProviderTest.php:22-49 (inside a named helper customProviderPythonPath()) — additionally checks getenv('AETHER_PYTHON_PATH') first, then the same discovery loop, then the same CI-fail-else-skip branch

Where

  • tests/Unit/Bridge/PythonBridgeTest.php:52-60
  • tests/Feature/GateParityTest.php:21-33
  • tests/Feature/CustomProviderTest.php:22-49

Refactor proposal

Add one shared helper to tests/Pest.php (e.g. resolveTestPythonPath(bool $requireInCi = true): ?string), honoring AETHER_PYTHON_PATH first, then falling back to the which python3/python search, with the CI-fail-vs-skip decision as a parameter — then have all three test files call it instead of carrying their own (subtly different) copies.

Severity: low

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions