From d2c2a71af1372486532f36254b7747a379d882f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Fri, 2 Aug 2024 16:17:57 +0200 Subject: [PATCH] Update test suite to ensure 100% code coverage --- .github/workflows/ci.yml | 10 +++++-- README.md | 27 ++++++++++++++++++- .../Redis/Protocol/Parser/ResponseParser.php | 1 - 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b521e6d..841c7e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,13 @@ jobs: php-version: ${{ matrix.php }} coverage: xdebug - run: composer install - - run: vendor/bin/phpunit --coverage-text + - run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml if: ${{ matrix.php >= 7.3 }} - - run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy + - run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml -c phpunit.xml.legacy if: ${{ matrix.php < 7.3 }} + - name: Check 100% code coverage + shell: php {0} + run: | + project->metrics; + exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1); diff --git a/README.md b/README.md index 1444e59..1c4efe7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # clue/redis-protocol [![CI status](https://github.com/clue/redis-protocol/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/redis-protocol/actions) +[![code coverage](https://img.shields.io/badge/code%20coverage-100%25-success)](#tests) [![installs on Packagist](https://img.shields.io/packagist/dt/clue/redis-protocol?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/clue/redis-protocol) A streaming Redis protocol (RESP) parser and serializer written in pure PHP. @@ -26,6 +27,7 @@ implementations. * [Model](#model) * [Serializer](#serializer) * [Install](#install) +* [Tests](#tests) * [License](#license) ## Support us @@ -139,11 +141,34 @@ The recommended way to install this library is [through Composer](https://getcom This will install the latest supported version: ```bash -$ composer require clue/redis-protocol:^0.3.1 +composer require clue/redis-protocol:^0.3.1 ``` More details and upgrade guides can be found in the [CHANGELOG](CHANGELOG.md). +## Tests + +To run the test suite, you first need to clone this repo and then install all +dependencies [through Composer](https://getcomposer.org/): + +```bash +composer install +``` + +To run the test suite, go to the project root and run: + +```bash +vendor/bin/phpunit +``` + +The test suite is set up to always ensure 100% code coverage across all +supported environments. If you have the Xdebug extension installed, you can also +generate a code coverage report locally like this: + +```bash +XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text +``` + ## License Its parser and serializer originally used to be based on diff --git a/src/Clue/Redis/Protocol/Parser/ResponseParser.php b/src/Clue/Redis/Protocol/Parser/ResponseParser.php index 19ac90c..ce853b6 100644 --- a/src/Clue/Redis/Protocol/Parser/ResponseParser.php +++ b/src/Clue/Redis/Protocol/Parser/ResponseParser.php @@ -143,7 +143,6 @@ private function readResponse() break; default: throw new ParserException('Invalid message can not be parsed: "' . $reply . '"'); - break; } /* Party on */ return $response;