Skip to content

Commit d156389

Browse files
committed
Disable tests for Int64 type that can not work on a 32-bit platform
1 parent ca78df2 commit d156389

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

scripts/convert-bson-corpus-tests.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
'Top-level document validity: Bad $date (number, not string or hash)' => 'Legacy extended JSON $date syntax uses numbers (CDRIVER-2223)',
1515
];
1616

17+
$for64bitOnly = [
18+
'Int64 type: MinValue' => "Can't represent 64-bit ints on a 32-bit platform",
19+
'Int64 type: MaxValue' => "Can't represent 64-bit ints on a 32-bit platform",
20+
];
21+
1722
$outputPath = realpath(__DIR__ . '/../tests') . '/bson-corpus/';
1823

1924
if ( ! is_dir($outputPath) && ! mkdir($outputPath, 0755, true)) {
@@ -42,7 +47,7 @@
4247
foreach ($test['valid'] as $i => $case) {
4348
$outputFile = sprintf('%s-valid-%03d.phpt', pathinfo($inputFile, PATHINFO_FILENAME), $i + 1);
4449
try {
45-
$output = renderPhpt(getParamsForValid($test, $case), $expectedFailures);
50+
$output = renderPhpt(getParamsForValid($test, $case), $expectedFailures, $for64bitOnly);
4651
} catch (Exception $e) {
4752
printf("Error processing valid[%d] in %s: %s\n", $i, $inputFile, $e->getMessage());
4853
continue;
@@ -59,7 +64,7 @@
5964
foreach ($test['decodeErrors'] as $i => $case) {
6065
$outputFile = sprintf('%s-decodeError-%03d.phpt', pathinfo($inputFile, PATHINFO_FILENAME), $i + 1);
6166
try {
62-
$output = renderPhpt(getParamsForDecodeError($test, $case), $expectedFailures);
67+
$output = renderPhpt(getParamsForDecodeError($test, $case), $expectedFailures, $for64bitOnly);
6368
} catch (Exception $e) {
6469
printf("Error processing decodeErrors[%d] in %s: %s\n", $i, $inputFile, $e->getMessage());
6570
continue;
@@ -76,7 +81,7 @@
7681
foreach ($test['parseErrors'] as $i => $case) {
7782
$outputFile = sprintf('%s-parseError-%03d.phpt', pathinfo($inputFile, PATHINFO_FILENAME), $i + 1);
7883
try {
79-
$output = renderPhpt(getParamsForParseError($test, $case), $expectedFailures);
84+
$output = renderPhpt(getParamsForParseError($test, $case), $expectedFailures, $for64bitOnly);
8085
} catch (Exception $e) {
8186
printf("Error processing parseErrors[%d] in %s: %s\n", $i, $inputFile, $e->getMessage());
8287
continue;
@@ -263,16 +268,19 @@ function getParamsForParseError(array $test, array $case)
263268
];
264269
}
265270

266-
function renderPhpt(array $params, array $expectedFailures)
271+
function renderPhpt(array $params, array $expectedFailures, array $for64bitOnly)
267272
{
268273
$params['%XFAIL%'] = isset($expectedFailures[$params['%NAME%']])
269274
? "--XFAIL--\n" . $expectedFailures[$params['%NAME%']] . "\n"
270275
: '';
276+
$params['%SKIPIF%'] = isset($for64bitOnly[$params['%NAME%']])
277+
? "--SKIPIF--\n" . "<?php if (PHP_INT_SIZE !== 8) { die(\"skip {$for64bitOnly[$params['%NAME%']]}\"); } ?>" . "\n"
278+
: '';
271279

272280
$template = <<< 'TEMPLATE'
273281
--TEST--
274282
%NAME%
275-
%XFAIL%--DESCRIPTION--
283+
%XFAIL%%SKIPIF%--DESCRIPTION--
276284
Generated by scripts/convert-bson-corpus-tests.php
277285
278286
DO NOT EDIT THIS FILE

tests/bson-corpus/int64-valid-001.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Int64 type: MinValue
3+
--SKIPIF--
4+
<?php if (PHP_INT_SIZE !== 8) { die("skip Can't represent 64-bit ints on a 32-bit platform"); } ?>
35
--DESCRIPTION--
46
Generated by scripts/convert-bson-corpus-tests.php
57

tests/bson-corpus/int64-valid-002.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Int64 type: MaxValue
3+
--SKIPIF--
4+
<?php if (PHP_INT_SIZE !== 8) { die("skip Can't represent 64-bit ints on a 32-bit platform"); } ?>
35
--DESCRIPTION--
46
Generated by scripts/convert-bson-corpus-tests.php
57

0 commit comments

Comments
 (0)