|
15 | 15 | $fixturesDir = __DIR__ . '/../tests/Fixtures'; |
16 | 16 | $errors = []; |
17 | 17 | $checked = 0; |
| 18 | +$dimensionErrors = []; |
| 19 | +$dimensionsChecked = 0; |
| 20 | + |
| 21 | +// Required fixture dimensions (must match CI environment) |
| 22 | +const REQUIRED_WIDTH = 180; |
| 23 | +const REQUIRED_HEIGHT = 32; |
| 24 | + |
| 25 | +echo "Checking fixture dimensions (" . REQUIRED_WIDTH . "x" . REQUIRED_HEIGHT . ")...\n\n"; |
| 26 | + |
| 27 | +// Check dimensions for all terminal fixtures |
| 28 | +$dimensionsChecked += checkFixtureDimensions($fixturesDir . '/iterm', $dimensionErrors); |
| 29 | +$dimensionsChecked += checkFixtureDimensions($fixturesDir . '/ghostty', $dimensionErrors); |
| 30 | + |
| 31 | +if (count($dimensionErrors) > 0) { |
| 32 | + echo "DIMENSION ERRORS FOUND:\n\n"; |
| 33 | + foreach ($dimensionErrors as $error) { |
| 34 | + echo " ✗ {$error}\n"; |
| 35 | + } |
| 36 | + echo "\n"; |
| 37 | + echo "Found " . count($dimensionErrors) . " fixture dimension error(s).\n"; |
| 38 | + echo "All fixtures must be generated at " . REQUIRED_WIDTH . "x" . REQUIRED_HEIGHT . ".\n"; |
| 39 | + echo "Resize your terminal and run: composer test:screenshots\n"; |
| 40 | + exit(1); |
| 41 | +} |
| 42 | + |
| 43 | +echo "✓ All {$dimensionsChecked} fixture(s) have correct dimensions.\n\n"; |
18 | 44 |
|
19 | 45 | echo "Checking terminal fixture synchronization...\n\n"; |
20 | 46 |
|
@@ -134,3 +160,35 @@ function filesMatch(string $file1, string $file2): bool |
134 | 160 | { |
135 | 161 | return file_get_contents($file1) === file_get_contents($file2); |
136 | 162 | } |
| 163 | + |
| 164 | +/** |
| 165 | + * Check that all fixtures in a directory have the required dimensions. |
| 166 | + * |
| 167 | + * @return int Number of fixtures checked |
| 168 | + */ |
| 169 | +function checkFixtureDimensions(string $dir, array &$errors): int |
| 170 | +{ |
| 171 | + $checked = 0; |
| 172 | + |
| 173 | + if (!is_dir($dir)) { |
| 174 | + return $checked; |
| 175 | + } |
| 176 | + |
| 177 | + $files = findJsonFiles($dir); |
| 178 | + foreach ($files as $file) { |
| 179 | + $data = json_decode(file_get_contents($file), true); |
| 180 | + |
| 181 | + if (!isset($data['width']) || !isset($data['height'])) { |
| 182 | + continue; |
| 183 | + } |
| 184 | + |
| 185 | + $checked++; |
| 186 | + |
| 187 | + if ($data['width'] !== REQUIRED_WIDTH || $data['height'] !== REQUIRED_HEIGHT) { |
| 188 | + $relPath = basename(dirname($dir)) . '/' . basename($dir) . '/' . substr($file, strlen($dir) + 1); |
| 189 | + $errors[] = "{$relPath}: {$data['width']}x{$data['height']} (expected " . REQUIRED_WIDTH . "x" . REQUIRED_HEIGHT . ")"; |
| 190 | + } |
| 191 | + } |
| 192 | + |
| 193 | + return $checked; |
| 194 | +} |
0 commit comments