git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] userdiff: php: Improved tests catching "abstract" and "final" functions

From
Johannes Sixt <j6t@kdbg.org>
Date
Nov 14, 2020, 23:46 UTC
Message-ID
<ce6d8478-41f7-3664-12bb-9f91e5231f61@kdbg.org>
In-Reply-To
<pull.915.git.git.1605388687554.gitgitgadget@gmail.com>
Am 14.11.20 um 22:18 schrieb Javier Spagnoletti via GitGitGadget:
Show 5 quoted lines
> From: Javier Spagnoletti <phansys@gmail.com>
> 
> Since the original tests cases were using other detectable keywords (like
> "public" or "protected"), they are able to pass even if the keywords
> intended to be covered are not present.

Good find! I had to look at the patch text, though, before I could understand what the description wants to say. How about:

We have dedicated tests that "abstract" and "final" declarations are picked up as hunk context. However, the tests also use the keywords "public" and "protected" that by themselves denote hunk context lines. For this reason, the tests would not fail if the patterns for "abstract" and "final" were to become non-functional. Remove the distracting keywords from the two tests.

Show 53 quoted lines
> 
> Signed-off-by: Javier Spagnoletti <phansys@gmail.com>
> ---
>      userdiff: php: Improved test cases used to catch "abstract" and "final"
>      functions
>      
>      Since the original tests cases were using other detectable keywords
>      (like "public" or "protected"), they are able to pass even if the
>      keywords intended to be covered are not present. In the case of the test
>      for "abstract" keyword, the method's body was removed in the fixture,
>      since PHP doesn't allow an abstract method to have a body.
>      
>      Signed-off-by: Javier Spagnoletti phansys@gmail.com [phansys@gmail.com]
> 
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-915%2Fphansys%2Fpr_864-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-915/phansys/pr_864-v1
> Pull-Request: https://github.com/git/git/pull/915
> 
>   t/t4018/php-abstract-method | 5 ++++-
>   t/t4018/php-final-method    | 2 +-
>   2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/t/t4018/php-abstract-method b/t/t4018/php-abstract-method
> index ce215df75a..14d77e6c15 100644
> --- a/t/t4018/php-abstract-method
> +++ b/t/t4018/php-abstract-method
> @@ -1,7 +1,10 @@
>   abstract class Klass
>   {
> -    abstract public function RIGHT(): ?string
> +    abstract function RIGHT(): ?string
>       {
> +        // PHP doesn't allow abstract methods to have a body,
> +        // but this is here just for diff ckeck purposes.
> +
>           return 'ChangeMe';
>       }
>   }
> diff --git a/t/t4018/php-final-method b/t/t4018/php-final-method
> index 537fb8ad9a..f7dd2dec17 100644
> --- a/t/t4018/php-final-method
> +++ b/t/t4018/php-final-method
> @@ -1,6 +1,6 @@
>   class Klass
>   {
> -    final public function RIGHT(): string
> +    final function RIGHT(): string
>       {
>           return 'ChangeMe';
>       }
> 
> base-commit: e31aba42fb12bdeb0f850829e008e1e3f43af500
> 
-- Hannes
Previous: Javier Spagnoletti via GitGitGadgetNext: Junio C Hamano
Message 2 of 3 in “userdiff: php: Improved tests catching "abstract" and "final" functions”
  1. userdiff: php: Improved tests catching "abstract" and "final" functionsJavier Spagnoletti via GitGitGadget, Nov 14, 2020
  2. Johannes SixtNov 14, 2020
  3. Junio C HamanoNov 16, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.