Skip to content

test: run engine tests in-process now the datasource stub is gone - #345

Merged
TheWitness merged 10 commits into
developfrom
refactor/engine-tests-in-process
Nov 11, 2026
Merged

TheWitness merged 10 commits into
developfrom
refactor/engine-tests-in-process

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member

Fixes #343

Stacked on #344, so merge #344 first. This PR targets #344's branch until then.

Engine tests that used a separate process only to avoid the WeatherMapDataSource and IN/OUT collision are back to plain in-process Pest tests:

  • DefaultLinkBandwidth
  • MapStyleConfigRoundTrip
  • the thumbnail sizing case
  • AlgorithmRegression
  • CodeScanningHardening

Their assertions are unchanged, and each one restores the working directory.

Tests that genuinely need isolation keep it, each with a one-line reason. They either declare functions unconditionally, replace built-in functions in the plugin's namespaces, or depend on the working directory and GD's per-process font cache.

Verified: the full Pest suite passes on PHP 8.4 with 360 tests and 2053 assertions, the same counts as the base branch.

Each define() is wrapped in defined() so loading the file after a caller
or test has already declared IN/OUT no longer warns. Values, order and
the point at which WeatherMap.class.php defines them are unchanged.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
WeatherMapDataSource, WeatherMapPreProcessor, WeatherMapPostProcessor,
WeatherMapBase, WeatherMapConfigItem and WeatherMapItem each move to
their own lib/*.class.php file with their bodies unchanged.
WeatherMap.class.php requires them before WeatherMapNode and
WeatherMapLink, which extend WeatherMapItem and previously relied on it
being hoisted from the same file. Existing callers keep including
WeatherMap.class.php only.

The source-scanning ReadData contract tests now read
WeatherMapDataSource.class.php, and the syntax smoke list covers the
new files.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The harness declared its own WeatherMapDataSource and IN/OUT, so any
later test in the same process that loaded WeatherMap.class.php hit a
class redeclaration fatal. It now requires the guarded constants file
and the real base class, which are require_once-safe, and the stub is
dropped. The real base adds only no-op Register() and Prefetch().

The patch-coverage allowlist note for lib/editor.actions.php no longer
cites the collision.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Class and method summaries for the files moved out of
WeatherMap.class.php, and a docblock per constant group. Comment-only;
kept separate from the move so that commit stays a verbatim copy.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
DefaultLinkBandwidthTest, MapStyleConfigRoundTripTest and the thumbnail
sizing case from BackgroundSizingEngineTest were PHPUnit classes only so
they could run in a separate process and avoid the WeatherMapDataSource
redeclaration. They become Pest tests with the same assertions and
restore the working directory afterwards. The thumbnail case moves to
ThumbnailDefaultTest; MapStyleConfigRoundTripTest drops its cacti_count()
fallback, which bootstrap-unit.php already provides.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Each one declares functions unconditionally, shadows builtins in a
plugin namespace, plain-requires setup.php, or depends on the working
directory and GD's per-process font cache.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
EngineFileLoadingTest loads each split file in a fresh PHP process:
the constants file twice and after a caller-defined IN, each base class
on its own, and the datasource base, harness and engine in that order.
EngineRenderEndToEndTest reads the published traffic-pulse example from
a temp dir, then runs ReadData, DrawMap and MakeHTML and checks the PNG
and the imagemap areas for both nodes and the link.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
AlgorithmRegressionTest and CodeScanningHardeningTest used separate
processes only to avoid the WeatherMapDataSource and IN/OUT collision
with the datasource harness. They return to Pest with the same
assertions; engine construction runs from the plugin directory, which
it scans for datasource, pre and post plugins, and the previous working
directory is restored.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The standalone-load checks run in child processes, so patch coverage
does not see the moved base-class defaults. Exercise them in-process.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@alcatron

alcatron commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Ran c9bf18b with #344 underneath it: all 364 PHP tests passed on PHP 8.3. The combined batch also passed after correcting the unrelated #348 fixtures.

Keeping isolation for the tests that still redefine functions makes sense. I didn't find a new failure caused by removing it from the other engine tests. This should follow #344 in the merge order.

@alcatron alcatron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked with #344 and the rest of the active batch. All 648 PHP tests pass without local test corrections. Good from my side; this should follow #344.

Base automatically changed from refactor/split-weathermap-engine to develop November 11, 2026 02:12
@TheWitness
TheWitness merged commit 628d553 into develop Nov 11, 2026
2 checks passed
@TheWitness
TheWitness deleted the refactor/engine-tests-in-process branch November 11, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run engine unit tests in-process where isolation is not needed

3 participants