feat(compat): sweep of components against the real core with strict diagnostics
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
use Toolbox\Catalog;
|
||||
|
||||
Harness::suite('group11-compat');
|
||||
|
||||
$GLOBALS['g11_repo'] = dirname(__DIR__);
|
||||
|
||||
/**
|
||||
* Contratos:
|
||||
* - levels.json debe cubrir exactamente los componentes del catalogo.
|
||||
* - si tests/compat/report.json existe, todo 'tested' declarado debe estar
|
||||
* respaldado por un 'ok' del reporte, y los niveles 'none' no deben
|
||||
* declarar tested.
|
||||
* Sin reporte (entorno offline sin haber corrido el barrido) solo se exige el
|
||||
* primer contrato.
|
||||
*/
|
||||
Harness::it('levels.json cubre exactamente los componentes del catalogo', function () {
|
||||
$repo = $GLOBALS['g11_repo'];
|
||||
$levels = json_decode((string) file_get_contents($repo . '/tests/compat/levels.json'), true);
|
||||
ok(is_array($levels), 'levels.json debe ser un objeto por paquete');
|
||||
|
||||
$catalog = Catalog::fromRoot($repo);
|
||||
$declared = [];
|
||||
foreach ($catalog->packages() as $manifest) {
|
||||
foreach (array_keys($manifest->components()) as $component) {
|
||||
$declared[] = $manifest->name . ':' . $component;
|
||||
}
|
||||
}
|
||||
|
||||
$planned = [];
|
||||
foreach ($levels as $package => $components) {
|
||||
foreach (array_keys($components) as $component) {
|
||||
$planned[] = $package . ':' . $component;
|
||||
}
|
||||
}
|
||||
|
||||
sort($declared);
|
||||
sort($planned);
|
||||
eq($declared, $planned, 'cada componente del catalogo tiene su nivel de evidencia planeado');
|
||||
});
|
||||
|
||||
Harness::it('los stamps tested estan respaldados por el reporte del barrido', function () {
|
||||
$repo = $GLOBALS['g11_repo'];
|
||||
$reportPath = $repo . '/tests/compat/report.json';
|
||||
|
||||
if (!is_file($reportPath)) {
|
||||
return; // offline sin barrido previo: no se inventa evidencia ni se exige.
|
||||
}
|
||||
|
||||
$report = json_decode((string) file_get_contents($reportPath), true);
|
||||
ok(is_array($report) && isset($report['components']), 'report.json valido');
|
||||
|
||||
$levels = json_decode((string) file_get_contents($repo . '/tests/compat/levels.json'), true);
|
||||
$catalog = Catalog::fromRoot($repo);
|
||||
|
||||
foreach ($catalog->packages() as $manifest) {
|
||||
foreach (array_keys($manifest->components()) as $component) {
|
||||
$id = $manifest->name . ':' . $component;
|
||||
$level = $levels[$manifest->name][$component] ?? null;
|
||||
$level = is_array($level) ? $level['level'] : $level;
|
||||
$status = $report['components'][$id]['status'] ?? 'missing';
|
||||
$tested = $manifest->testedCore($component);
|
||||
|
||||
if ($level === 'none') {
|
||||
eq(null, $tested, "$id esta deliberadamente sin datos y no debe declarar tested");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($tested !== null) {
|
||||
eq('ok', $status, "$id declara tested='$tested' pero su evidencia en el reporte es '$status'");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user