2017-04-06 12 views
10

これは私のシステムでのみ起こるようです。誰もそれを再現することはできません。エラーメッセージが大きすぎる場合(私の場合約65kバイト)、何も画面に表示されません。私はデフォルトのphp.ini(メモリ制限は8GBに設定されています)とデフォルトのPHPUnit 6.0.13の設定で、Windows 7でPHP 7.1.3を使用しています。プロンプトとpowershellの両方にエラーは表示されません。セバスチャン・バーグマンとコントリビュータによるPHPUnitが非常に大きなエラーメッセージを表示しない原因は何ですか?

のPHPUnit 6.0.13:

<?php 

use PHPUnit\Framework\Constraint\Constraint; 
use PHPUnit\Framework\TestCase; 

class MyConstraint extends Constraint 
{ 
    protected $expected; 

    function __construct($expected){ 
     parent::__construct(); 
     $this->expected = $expected; 
    } 

    protected function matches($actual){ 
     return false; 
    } 

    function failureDescription($other): string{ 
     return "desc"; 
    } 

    function toString(){ 
     return "description"; 
    } 

    function additionalFailureDescription($other): string{ 
     return str_repeat("x", 100000); 
     // If set to a smaller dump, error will appear 
     // some people I asked to try could dump one million 
     // bytes without problems, while I can't print more 
     // than about 50k 
    } 
} 

class SomeTest extends TestCase 
{ 
    function testBigDump(){ 
     TestCase::assertThat("irrelevant", new MyConstraint("irrelevant")); 
    } 
} 

?> 

は、そして、これは私が画面上に得るものです。

ランタイム:PHPDBG 7.1.3設定:..............

、F 1/1(100%)

時間:361ミリ秒、メモリ:6.00

1)SomeTest :: testBigDump

       <------- Notice no error description here 

FAILURES:MB

1つの失敗がありました!テスト:1、アサーション:1、失敗:1.

何が原因で起こりうるのでしょうか?前もって感謝します。ご使用の構成で

+0

PHPメモリは大丈夫のようです。別のエラーが発生します。テストの出力をファイルにリダイレクトしようとしましたか?あなたのコマンドラインに、そのような長い文字列を表示するのに十分なメモリがない可能性があります。擬似コードの代わりに完全な実際の例を投稿すれば、他の人が擬似コードを複製しようとする場合に役立ちます。 –

+0

これは疑似コードではありません。それだけでエラーを引き起こすのに十分です – Wes

答えて

9

何かが、私はWindows 7のVMを使用して可能な限りの環境を再現しようとすると、この問題を再現しましたphpdbg

経由PHPUnitのテストを実行しています。

ヒントはダンプのRuntime: PHPDBG行でした。どうやらphpdbgランタイムに関する何かが、大きなバッファが正しく動作するのを防ぎます。 (当然、切り捨て)以下の私の出力、php.exeに経由して実行すると、その後phpdbg.exe(欠落しているテストの説明)を介して実行し、初期出力の両方を参照してください:

C:\project>phpdbg -r phpunit-6.1.0.phar -v test.php 
[Welcome to phpdbg, the interactive PHP debugger, v0.5.0] 
To get help using phpdbg type "help" and press enter 
[Please report bugs to <http://bugs.php.net/report.php>] 
PHPUnit 6.1.0 by Sebastian Bergmann and contributors. 

Runtime:  PHPDBG 7.1.4 

F                 1/1 (100%) 


Time: 99 ms, Memory: 22.00MB 

There was 1 failure: 

1) SomeTest::testBigDump 

FAILURES! 
Tests: 1, Assertions: 1, Failures: 1. 
[Script ended normally] 

C:\project>php phpunit-6.1.0.phar test.php 
PHPUnit 6.1.0 by Sebastian Bergmann and contributors. 

F                 1/1 (100%) 


Time: 109 ms, Memory: 8.00MB 

There was 1 failure: 

1) SomeTest::testBigDump 
Failed asserting that desc. 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
----- Snip ----- 
関連する問題