From af0e7338dd24ed7e7e15cc7c47b5a6ba0e376bc0 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 25 May 2020 13:48:42 +1000 Subject: [PATCH] Call ob_start() before running tests The policy introduced for T206476 creates a subtle failure mode: any test writing to stdout will cause headers to be sent, causing later tests to fail when they try to call header(). Instead, call ob_start() to intercept test output. Any buffered output is still seen when PHPUnit exits. Bug: T206476 Change-Id: Id085efeab67d1e700ffcbf37868b5107e3a7e5d5 --- tests/phpunit/phpunit.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php index 650cfcfa3a..6036e3fb82 100755 --- a/tests/phpunit/phpunit.php +++ b/tests/phpunit/phpunit.php @@ -124,6 +124,10 @@ class PHPUnitMaintClass extends Maintenance { exit( 1 ); } + // Start an output buffer to avoid headers being sent by constructors, + // data providers, etc. (T206476) + ob_start(); + fwrite( STDERR, defined( 'HHVM_VERSION' ) ? 'Using HHVM ' . HHVM_VERSION . ' (' . PHP_VERSION . ")\n" : 'Using PHP ' . PHP_VERSION . "\n" ); -- 2.20.1