Просмотр исходного кода

:octocat: mute debug output on CI

smiley 3 лет назад
Родитель
Сommit
1fd3109339
5 измененных файлов с 18 добавлено и 3 удалено
  1. 1 1
      .github/workflows/tests.yml
  2. 1 0
      .gitignore
  3. 4 0
      phpunit.xml.dist
  4. 6 0
      tests/Data/QRMatrixTest.php
  5. 6 2
      tests/QRCodeReaderTestAbstract.php

+ 1 - 1
.github/workflows/tests.yml

@@ -109,7 +109,7 @@ jobs:
         run: composer update --no-ansi --no-interaction --no-progress --no-suggest
 
       - name: "Run tests with phpunit"
-        run: php vendor/bin/phpunit --configuration=phpunit.xml
+        run: php vendor/bin/phpunit --configuration=phpunit.xml.dist
 
       - name: "Send code coverage report to Codecov.io"
         uses: codecov/codecov-action@v3

+ 1 - 0
.gitignore

@@ -15,3 +15,4 @@
 docs/*
 vendor/*
 composer.lock
+phpunit.xml

+ 4 - 0
phpunit.xml → phpunit.xml.dist

@@ -23,4 +23,8 @@
 	<logging>
 		<junit outputFile=".build/logs/junit.xml"/>
 	</logging>
+	<php>
+		<!-- whether the test runs on CI or not - set to false to allow debug output -->
+		<const name="TEST_IS_CI" value="true"/>
+	</php>
 </phpunit>

+ 6 - 0
tests/Data/QRMatrixTest.php

@@ -17,6 +17,7 @@ use chillerlan\QRCode\Output\{QROutputInterface, QRString};
 use PHPUnit\Framework\TestCase;
 use PHPUnit\Util\Color;
 use Generator;
+use function defined;
 
 /**
  * Tests the QRMatix class
@@ -41,6 +42,11 @@ final class QRMatrixTest extends TestCase{
 	 * Matrix debugging console output
 	 */
 	public static function debugMatrix(QRMatrix $matrix):void{
+
+		if(defined('TEST_IS_CI') && TEST_IS_CI === true){
+			return;
+		}
+
 		$opt = new QROptions;
 		$opt->outputType  = QROutputInterface::STRING_TEXT;
 		$opt->eol         = Color::colorize('reset', "\x00\n");

+ 6 - 2
tests/QRCodeReaderTestAbstract.php

@@ -12,6 +12,7 @@
 
 namespace chillerlan\QRCodeTest;
 
+use chillerlan\QRCodeTest\Data\QRMatrixTest;
 use chillerlan\QRCode\{QRCode, QROptions};
 use chillerlan\QRCode\Common\{EccLevel, Mode, Version};
 use chillerlan\QRCode\Output\QROutputInterface;
@@ -79,8 +80,11 @@ abstract class QRCodeReaderTestAbstract extends TestCase{
 		}
 
 		/** @noinspection PhpUndefinedMethodInspection */
-		$this::assertSame($expected, (string)(new QRCode)
-			->readFromSource($this->FQN::fromFile(__DIR__.'/samples/'.$img, $this->options)));
+		$result = (new QRCode)->readFromSource($this->FQN::fromFile(__DIR__.'/samples/'.$img, $this->options));
+
+		QRMatrixTest::debugMatrix($result->getMatrix());
+
+		$this::assertSame($expected, (string)$result);
 	}
 
 	public function testReaderMultiSegment():void{