From 5035e076a0e1cf4ee56b6c8447a5fc085298b1d4 Mon Sep 17 00:00:00 2001 From: wickedOne Date: Sat, 17 Feb 2024 10:10:50 +0100 Subject: [PATCH] functional tests - added functional tests for provided integration scripts - bumped version to 1.1.1 - made codeowner file configurable and modified documentation accordingly --- Makefile.PL | 1 + README.md | 1 + codeowner2commaseparatedlist.pl | 3 +- codeowner2phpstan.pl | 7 +-- codeowner2psalm.pl | 6 ++- coverage2codeowner.pl | 11 ++-- doc/Infection.md | 5 -- doc/PHPMD.md | 6 --- doc/PHPStan.md | 3 -- doc/PHPUnit.md | 5 -- doc/Psalm.md | 10 ---- lib/GPH.pm | 2 +- lib/GPH/PHPUnit.pm | 2 +- stdin2codeowner-filter.pl | 6 ++- t/functional/codeowner2commaseparatedlist.t | 45 ++++++++++++++++ t/functional/codeowner2phpmd.t | 51 ++++++++++++++++++ t/functional/codeowner2phpstan.t | 51 ++++++++++++++++++ t/functional/codeowner2psalm.t | 51 ++++++++++++++++++ t/functional/coverage2codeowner.t | 51 ++++++++++++++++++ t/functional/infection2escapee-warning.t | 51 ++++++++++++++++++ t/share/Gitlab/CODEOWNERS-functional | 9 ++++ .../Infection/infection-output-functional.txt | 14 +++++ .../Infection/infection-report-functional.txt | 17 ++++++ t/share/PHPMD/phpmd-ruleset-functional.xml | 8 +++ t/share/PHPStan/phpstan-functional.neon | 15 ++++++ t/share/PHPUnit/phpunit-output-functional.txt | 52 +++++++++++++++++++ t/share/PHPUnit/phpunit-report-functional.txt | 29 +++++++++++ t/share/Psalm/psalm-functional.xml | 23 ++++++++ t/unit/GPH/PHPUnit.t | 1 + 29 files changed, 493 insertions(+), 43 deletions(-) mode change 100755 => 100644 stdin2codeowner-filter.pl create mode 100644 t/functional/codeowner2commaseparatedlist.t create mode 100644 t/functional/codeowner2phpmd.t create mode 100644 t/functional/codeowner2phpstan.t create mode 100644 t/functional/codeowner2psalm.t create mode 100644 t/functional/coverage2codeowner.t create mode 100644 t/functional/infection2escapee-warning.t create mode 100644 t/share/Gitlab/CODEOWNERS-functional create mode 100644 t/share/Infection/infection-output-functional.txt create mode 100644 t/share/Infection/infection-report-functional.txt create mode 100644 t/share/PHPMD/phpmd-ruleset-functional.xml create mode 100644 t/share/PHPStan/phpstan-functional.neon create mode 100644 t/share/PHPUnit/phpunit-output-functional.txt create mode 100644 t/share/PHPUnit/phpunit-report-functional.txt create mode 100644 t/share/Psalm/psalm-functional.xml diff --git a/Makefile.PL b/Makefile.PL index 1871707..fbe6f05 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -22,6 +22,7 @@ WriteMakefile( "Test2::Tools::Spec" => 0, "Data::Dumper" => 0, "Readonly" => 0, + "File::Temp" => 0, }, 'test' => { TESTS => 't/unit/GPH/*.t t/unit/GPH/*/*.t' diff --git a/README.md b/README.md index 15ba05e..d6ac6a5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ these scripts rely on a couple of environment variables. the following environment variables are used by all scripts - `DEV_TEAM`: owner as defined in the `CODEOWNERS` file - `EXCLUDE_PATHS`: (optional): comma seperated list of paths to exclude while defined in the `CODEOWNERS` file for owner `DEV_TEAM`. defaults to empty string. +- `CODEOWNERS`: (optional): path to codeowners file, defaults to `./CODEOWNERS` ## details diff --git a/codeowner2commaseparatedlist.pl b/codeowner2commaseparatedlist.pl index 205239e..a3f0a4e 100755 --- a/codeowner2commaseparatedlist.pl +++ b/codeowner2commaseparatedlist.pl @@ -9,10 +9,11 @@ my $owner = $ENV{'DEV_TEAM'} or die "please define owner in DEV_TEAM env var"; my @excludes = split /,/, ($ENV{'EXCLUDE_PATHS'} || ''); +my $codeonwers = $ENV{'CODEOWNERS'} || './CODEOWNERS'; my %config = ( owner => $owner, - codeowners => './CODEOWNERS', + codeowners => $codeonwers, excludes => \@excludes, ); diff --git a/codeowner2phpstan.pl b/codeowner2phpstan.pl index 0675ea7..28888a4 100755 --- a/codeowner2phpstan.pl +++ b/codeowner2phpstan.pl @@ -10,10 +10,11 @@ my $owner = $ENV{'DEV_TEAM'} or die "please define owner in DEV_TEAM env var"; my @excludes = split /,/, ($ENV{'EXCLUDE_PATHS'} || ''); +my $codeonwers = $ENV{'CODEOWNERS'} || './CODEOWNERS'; my %gitlabConfig = ( owner => $owner, - codeowners => './CODEOWNERS', + codeowners => $codeonwers, excludes => \@excludes, ); @@ -22,13 +23,13 @@ my @includes = split /,/, ($ENV{'PHPSTAN_INCLUDES'} || './phpstan.ci.neon'); my @ignored = split /,/, ($ENV{'PHPSTAN_IGNORED_DIRS'} || ''); -@ignored = (@ignored, $gitlab->getBlacklistPaths()); # merge ignored dirs with blacklist +@ignored = (@ignored, @{$gitlab->getBlacklistPaths()}); # merge ignored dirs with blacklist my %config = ( level => $ENV{'PHPSTAN_LEVEL'} || 6, paths => $gitlab->getPaths(), baseline => $ENV{'PHPSTAN_BASELINE'}, - ignoredDirectories => @ignored, + ignoredDirectories => \@ignored, cacheDir => $ENV{'PHPSTAN_CACHE_DIR'}, includes => \@includes, threads => $ENV{'PHPSTAN_THREADS'} diff --git a/codeowner2psalm.pl b/codeowner2psalm.pl index 022202b..dc7718d 100755 --- a/codeowner2psalm.pl +++ b/codeowner2psalm.pl @@ -10,10 +10,11 @@ my $owner = $ENV{'DEV_TEAM'} or die "please define owner in DEV_TEAM env var"; my @excludes = split /,/, ($ENV{'EXCLUDE_PATHS'} || ''); +my $codeonwers = $ENV{'CODEOWNERS'} || './CODEOWNERS'; my %gitlabConfig = ( owner => $owner, - codeowners => './CODEOWNERS', + codeowners => $codeonwers, excludes => \@excludes, ); @@ -40,8 +41,9 @@ if ($clone eq 1) { my @blacklist = split /,/, ($ENV{'PSALM_EXCLUDE_HANDLERS'} || ''); + my $base = $ENV{'PSALM_BASE_CONFIG'} || './psalm.xml'; - print $psalm->getConfigWithIssueHandlers('./psalm.xml', @blacklist); + print $psalm->getConfigWithIssueHandlers($base, @blacklist); } else { print $psalm->getConfig(); diff --git a/coverage2codeowner.pl b/coverage2codeowner.pl index f909041..686d834 100755 --- a/coverage2codeowner.pl +++ b/coverage2codeowner.pl @@ -7,13 +7,16 @@ use GPH::PHPUnit; -my $owner = $ENV{'DEV_TEAM'} or die "please define owner in DEV_TEAM env var"; +my $owner = $ENV{'DEV_TEAM'} or die "please define owner in DEV_TEAM env var"; my @excludes = split /,/, ($ENV{'EXCLUDE_PATHS'} || ''); +my $codeonwers = $ENV{'CODEOWNERS'} || './CODEOWNERS'; +my $classmap = $ENV{'CLASSMAP'} || './vendor/composer/autoload_classmap.php'; + my %config = ( owner => $owner, - classmap => './vendor/composer/autoload_classmap.php', - codeowners => './CODEOWNERS', - threshold => $ENV{'MIN_COVERAGE'}, + classmap => $classmap, + codeowners => $codeonwers, + threshold => $ENV{'MIN_COVERAGE'}, excludes => \@excludes, baseline => $ENV{'PHPUNIT_BASELINE'} ); diff --git a/doc/Infection.md b/doc/Infection.md index 5d1db3d..a685d67 100644 --- a/doc/Infection.md +++ b/doc/Infection.md @@ -5,11 +5,6 @@ several ways to interact with infection, here are some... this script collects the paths defined in your CODEOWNERS file for given codeowner and outputs them to a value which can be used as for example a filter value for php infection. -### assumptions - -this script assumes the presence of the CODEOWNERS file in the root directory of you project. -though configurable in the `codeowner2commaseparatedlist.pl` file, for now no plans to make that configurable or accept it as input parameter. - > [!CAUTION] > the `codeowner2commaseparatedlist.pl` script requires either an optimised or an authoritative classmap file so make sure to generate one of those in your configuration (see example below). diff --git a/doc/PHPMD.md b/doc/PHPMD.md index a1ae325..e5b4de6 100644 --- a/doc/PHPMD.md +++ b/doc/PHPMD.md @@ -7,12 +7,6 @@ use `codeowner2phpmd.pl` this script generates a phpmd config which currently on the following environment variable is used by the codeowner2phpmd script - `CYCLO_LEVEL`: cyclomatic complexity threshold. defaults to 10 -### global variables - -the following environment variables are used by all scripts -- `DEV_TEAM`: owner as defined in the `CODEOWNERS` file -- `EXCLUDE_PATHS`: (optional): comma seperated list of paths to exclude while defined in the `CODEOWNERS` file for owner `DEV_TEAM`. defaults to empty string. - ### example config > gitlab-ci-yml diff --git a/doc/PHPStan.md b/doc/PHPStan.md index d0f2baa..a00854b 100644 --- a/doc/PHPStan.md +++ b/doc/PHPStan.md @@ -11,10 +11,7 @@ the following environment variables are used by the codeowner2phpstan script - `PHPSTAN_IGNORED_DIRS`: (optional) directories to ignore - `PHPSTAN_INCLUDES`: (optional) comma seperated list of files to include - `PHPSTAN_THREADS`: (optional) number of threads to use (defaults to `4`) -- -### assumptions -this script assumes the presence of the CODEOWNERS file in the root directory of you project. ### example config diff --git a/doc/PHPUnit.md b/doc/PHPUnit.md index 0dd3b41..e1ae320 100644 --- a/doc/PHPUnit.md +++ b/doc/PHPUnit.md @@ -16,11 +16,6 @@ the following environment variable is used by the coverage2codeowner script - `MIN_COVERAGE` (optional): minimum coverage required for the job to succeed. defaults to 0.1 - `PHPUNIT_BASELINE` (optional): filepath of file containing paths to files and / or directories which are within the defined code space, but should be ignored while calculating coverage statistics. -### assumptions - -this script assumes the presence of composer at the usual location and the CODEOWNERS file in the root directory of you project. -though both paths are configurable in the `coverage2codeowner.pl` file, for now no plans to make that configurable or accept them as input parameters. - > [!CAUTION] > the `GPH::Composer.pm` module requires either an optimised or an authoritative classmap file so make sure to generate one of those in your configuration (see example below). diff --git a/doc/Psalm.md b/doc/Psalm.md index becb89c..64d15bf 100644 --- a/doc/Psalm.md +++ b/doc/Psalm.md @@ -2,16 +2,6 @@ `codeowner2psalm.pl` script generates a psalm config based on the paths defined in your `CODEOWNERS` file. -### assumptions - -this script assumes the presence of the CODEOWNERS file in the root directory of you project. - -### global variables - -the following environment variables are used by all scripts -- `DEV_TEAM`: owner as defined in the `CODEOWNERS` file -- `EXCLUDE_PATHS`: (optional): comma seperated list of paths to exclude while defined in the `CODEOWNERS` file for owner `DEV_TEAM`. defaults to empty string. - ### variables the following environment variables are used by the codeowner2psalm script diff --git a/lib/GPH.pm b/lib/GPH.pm index ff2f111..6203986 100644 --- a/lib/GPH.pm +++ b/lib/GPH.pm @@ -3,6 +3,6 @@ package GPH; use strict; use warnings FATAL => 'all'; -our $VERSION = '1.1.0'; +our $VERSION = '1.1.1'; 1; \ No newline at end of file diff --git a/lib/GPH/PHPUnit.pm b/lib/GPH/PHPUnit.pm index 2334a17..ec19233 100755 --- a/lib/GPH/PHPUnit.pm +++ b/lib/GPH/PHPUnit.pm @@ -52,7 +52,7 @@ sub new { bless $self, $class; - if (exists($args{baseline})) { + if (exists($args{baseline}) and defined $args{baseline}) { open(my $fh, '<', $args{baseline}) or die "unable to open phpunit baseline file $args{baseline} $!"; my @lines = (); diff --git a/stdin2codeowner-filter.pl b/stdin2codeowner-filter.pl old mode 100755 new mode 100644 index cadf93c..0a705bc --- a/stdin2codeowner-filter.pl +++ b/stdin2codeowner-filter.pl @@ -9,10 +9,12 @@ my $owner = $ENV{'DEV_TEAM'} or die "please define owner in DEV_TEAM env var"; my @excludes = split /,/, ($ENV{'EXCLUDE_PATHS'} || ''); +my $codeonwers = $ENV{'CODEOWNERS'} || './CODEOWNERS'; + my %config = ( owner => $owner, - codeowners => './CODEOWNERS', - excludes => \@excludes + codeowners => $codeonwers, + excludes => \@excludes, ); my $gitlab = GPH::Gitlab->new(%config); diff --git a/t/functional/codeowner2commaseparatedlist.t b/t/functional/codeowner2commaseparatedlist.t new file mode 100644 index 0000000..4af2469 --- /dev/null +++ b/t/functional/codeowner2commaseparatedlist.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Test2::V0; +use Test2::Tools::Spec; + +use Data::Dumper; +use File::Temp; + +BEGIN { + @ENV{"DEV_TEAM", "EXCLUDE_PATHS", "CODEOWNERS"} = ('@teams/alpha', '.gitlab-ci.yml', './t/share/Gitlab/CODEOWNERS-functional'); +} + +describe "generate phpmd config" => sub { + tests "compare config" => sub { + my ($c, $fh, $exception, $warnings, $stdout, $file); + + $exception = dies { + $warnings = warns { + $file = File::Temp::tmpnam(); + $c = system("$^X codeowner2commaseparatedlist.pl > $file"); + }; + }; + + is($exception, undef, 'no exception thrown'); + is($warnings, 0, 'no warnings generated'); + is($c, 0, 'program exited with successful exit code', $c); + + open $fh, '<', $file or die $!; + $stdout = do { + local $/; + <$fh> + }; + close($fh); + + is($stdout, '/src/Command/,/src/Service/', 'config content correct') or diag Dumper($stdout); + + unlink($file); + + }; +}; + +done_testing(); + diff --git a/t/functional/codeowner2phpmd.t b/t/functional/codeowner2phpmd.t new file mode 100644 index 0000000..59fb831 --- /dev/null +++ b/t/functional/codeowner2phpmd.t @@ -0,0 +1,51 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Test2::V0; +use Test2::Tools::Spec; + +use Data::Dumper; +use File::Temp; + +BEGIN { + @ENV{"DEV_TEAM", "CYCLO_LEVEL"} = ('@teams/alpha', "3"); +} + +describe "generate phpmd config" => sub { + tests "compare config" => sub { + my ($c, $fh, $file, $mock, $stdout, $exception, $warnings); + + $exception = dies { + $warnings = warns { + $file = File::Temp::tmpnam(); + $c = system("$^X codeowner2phpmd.pl > $file"); + }; + }; + + is($exception, undef, 'no exception thrown'); + is($warnings, 0, 'no warnings generated'); + is($c, 0, 'program exited with successful exit code', $c); + + open $fh, '<', './t/share/PHPMD/phpmd-ruleset-functional.xml' or die $!; + $mock = do { + local $/; + <$fh> + }; + close($fh); + + open $fh, '<', $file or die $!; + $stdout = do { + local $/; + <$fh> + }; + close($fh); + + is($stdout, $mock, 'config content correct') or diag Dumper($stdout); + + unlink($file); + }; +}; + +done_testing(); + diff --git a/t/functional/codeowner2phpstan.t b/t/functional/codeowner2phpstan.t new file mode 100644 index 0000000..ccde4f8 --- /dev/null +++ b/t/functional/codeowner2phpstan.t @@ -0,0 +1,51 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Test2::V0; +use Test2::Tools::Spec; + +use Data::Dumper; +use File::Temp; + +BEGIN { + @ENV{"DEV_TEAM", "CODEOWNERS", "EXCLUDE_PATHS", "PHPSTAN_LEVEL", "PHPSTAN_IGNORED_DIRS", "PHPSTAN_INCLUDES", "PHPSTAN_BASELINE", "PHPSTAN_CACHE_DIR", "PHPSTAN_THREADS"} = ('@teams/alpha', './t/share/Gitlab/CODEOWNERS-functional', '.gitlab-ci.yml', '1', "/ignored/", '/includes/', './baselines/baseline.xml', '/tmp', '6'); +} + +describe "generate PHPStan config" => sub { + tests "compare config" => sub { + my ($c, $fh, $file, $mock, $stdout, $exception, $warnings); + + $exception = dies { + $warnings = warns { + $file = File::Temp::tmpnam(); + $c = system("$^X codeowner2phpstan.pl > $file"); + }; + }; + + is($exception, undef, 'no exception thrown'); + is($warnings, 0, 'no warnings generated'); + is($c, 0, 'program exited with successful exit code', $c); + + open $fh, '<', './t/share/PHPStan/phpstan-functional.neon' or die $!; + $mock = do { + local $/; + <$fh> + }; + close($fh); + + open $fh, '<', $file or die $!; + $stdout = do { + local $/; + <$fh> + }; + close($fh); + + is($stdout, $mock, 'config content correct') or diag Dumper($stdout); + + unlink($file); + }; +}; + +done_testing(); + diff --git a/t/functional/codeowner2psalm.t b/t/functional/codeowner2psalm.t new file mode 100644 index 0000000..aaf64d4 --- /dev/null +++ b/t/functional/codeowner2psalm.t @@ -0,0 +1,51 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Test2::V0; +use Test2::Tools::Spec; + +use Data::Dumper; +use File::Temp; + +BEGIN { + @ENV{"DEV_TEAM", "EXCLUDE_PATHS", "CODEOWNERS", "PSALM_BASE_CONFIG", "PSALM_IGNORED_DIRS", "PSALM_PLUGINS", "PSALM_LEVEL", "PSALM_BASELINE", "PSALM_EXCLUDE_HANDLERS"} = ('@teams/alpha', '.gitlab-ci.yml', './t/share/Gitlab/CODEOWNERS-functional', './t/share/Psalm/psalm-stub.xml', 'vendor', 'Psalm\SymfonyPsalmPlugin\Plugin', '2', 'baselines/psalm-baseline.xml', 'MoreSpecificImplementedParamType'); +} + +describe "generate Psalm config" => sub { + tests "compare config" => sub { + my ($c, $fh, $file, $mock, $stdout, $exception, $warnings); + + $exception = dies { + $warnings = warns { + $file = File::Temp::tmpnam(); + $c = system("$^X codeowner2psalm.pl > $file"); + }; + }; + + is($exception, undef, 'no exception thrown'); + is($warnings, 0, 'no warnings generated'); + is($c, 0, 'program exited with successful exit code', $c); + + open $fh, '<', './t/share/Psalm/psalm-functional.xml' or die $!; + $mock = do { + local $/; + <$fh> + }; + close($fh); + + open $fh, '<', $file or die $!; + $stdout = do { + local $/; + <$fh> + }; + close($fh); + + is($stdout, $mock, 'config content correct') or diag Dumper($stdout); + + unlink($file); + }; +}; + +done_testing(); + diff --git a/t/functional/coverage2codeowner.t b/t/functional/coverage2codeowner.t new file mode 100644 index 0000000..16062b6 --- /dev/null +++ b/t/functional/coverage2codeowner.t @@ -0,0 +1,51 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Test2::V0; +use Test2::Tools::Spec; + +use Data::Dumper; + +BEGIN { + @ENV{"DEV_TEAM", "EXCLUDE_PATHS", "CODEOWNERS", "CLASSMAP"} = ('@teams/alpha', '.gitlab-ci.yml', './t/share/Gitlab/CODEOWNERS-functional', './t/share/Composer/autoload_classmap.php'); +} + +describe "parse phpunit output" => sub { + tests "parse" => sub { + my ($c, $fh, $file, $mock, $stdout, $exception, $warnings); + + $exception = dies { + $warnings = warns { + $file = File::Temp::tmpnam(); + $c = system("/bin/cat ./t/share/PHPUnit/phpunit-output-functional.txt | ./coverage2codeowner.pl > $file"); + }; + }; + + is($exception, undef, 'no exception thrown'); + is($warnings, 0, 'no warnings generated'); + is($c, 0, 'program exited with successful exit code', $c); + + open $fh, '<', './t/share/PHPUnit/phpunit-report-functional.txt' or die $!; + $mock = do { + local $/; + <$fh> + }; + close($fh); + + open $fh, '<', $file or die $!; + while (<$fh>) { + # replacing datetime of the report until someone tells me how to mock it + $_ = ' 2024-02-17 08:49:26' . "\n" if $. == 2; + $stdout .= $_; + } + close($fh); + + is($stdout, $mock, 'report output correct') or diag Dumper($stdout); + + unlink($file); + }; +}; + +done_testing(); + diff --git a/t/functional/infection2escapee-warning.t b/t/functional/infection2escapee-warning.t new file mode 100644 index 0000000..85d5810 --- /dev/null +++ b/t/functional/infection2escapee-warning.t @@ -0,0 +1,51 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Test2::V0; +use Test2::Tools::Spec; + +use Data::Dumper; + +BEGIN { + @ENV{"MIN_MSI", "MIN_COVERED_MSI"} = ('90', '95'); +} + +describe "parse infection output" => sub { + tests "parse" => sub { + my ($c, $fh, $file, $mock, $stdout, $exception, $warnings); + + $exception = dies { + $warnings = warns { + $file = File::Temp::tmpnam(); + $c = system("/bin/cat ./t/share/Infection/infection-output-functional.txt | ./infection2escapee-warning.pl > $file"); + }; + }; + + is($exception, undef, 'no exception thrown'); + is($warnings, 0, 'no warnings generated'); + # system times the exit code by 256 + is($c, 256 * 8, 'program exited with correct exit code', $c); + + open $fh, '<', './t/share/Infection/infection-report-functional.txt' or die $!; + $mock = do { + local $/; + <$fh> + }; + close($fh); + + open $fh, '<', $file or die $!; + $stdout = do { + local $/; + <$fh> + }; + close($fh); + + is($stdout, $mock, 'report output correct') or diag Dumper($stdout); + + unlink($file); + }; +}; + +done_testing(); + diff --git a/t/share/Gitlab/CODEOWNERS-functional b/t/share/Gitlab/CODEOWNERS-functional new file mode 100644 index 0000000..245f827 --- /dev/null +++ b/t/share/Gitlab/CODEOWNERS-functional @@ -0,0 +1,9 @@ +[alpha] +/src/Command/**/* @teams/alpha +/src/Service/ @teams/alpha @#!$%^ +.gitlab-ci.yml @teams/alpha + +[beta] +/src/Command/Config/ConfigPhraseKeyCommand.php @teams/beta +/src/DependencyInjection/ @teams/beta +.gitlab-ci.yml @teams/beta \ No newline at end of file diff --git a/t/share/Infection/infection-output-functional.txt b/t/share/Infection/infection-output-functional.txt new file mode 100644 index 0000000..935efde --- /dev/null +++ b/t/share/Infection/infection-output-functional.txt @@ -0,0 +1,14 @@ +121 mutations were generated: + 121 mutants were killed + 0 mutants were configured to be ignored + 0 mutants were not covered by tests + 3 covered mutants were not detected + 0 errors were encountered + 0 syntax errors were encountered + 0 time outs were encountered + 0 mutants required more time than configured + +Metrics: + Mutation Score Indicator (MSI): 95% + Mutation Code Coverage: 100% + Covered Code MSI: 95% diff --git a/t/share/Infection/infection-report-functional.txt b/t/share/Infection/infection-report-functional.txt new file mode 100644 index 0000000..9037e61 --- /dev/null +++ b/t/share/Infection/infection-report-functional.txt @@ -0,0 +1,17 @@ +121 mutations were generated: + 121 mutants were killed + 0 mutants were configured to be ignored + 0 mutants were not covered by tests + 3 covered mutants were not detected + 0 errors were encountered + 0 syntax errors were encountered + 0 time outs were encountered + 0 mutants required more time than configured + +Metrics: + Mutation Score Indicator (MSI): 95% + Mutation Code Coverage: 100% + Covered Code MSI: 95% + + +[warning] even though MSI is within allowed boundaries 3 mutants were not detected. please improve your tests! diff --git a/t/share/PHPMD/phpmd-ruleset-functional.xml b/t/share/PHPMD/phpmd-ruleset-functional.xml new file mode 100644 index 0000000..ec81de8 --- /dev/null +++ b/t/share/PHPMD/phpmd-ruleset-functional.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/t/share/PHPStan/phpstan-functional.neon b/t/share/PHPStan/phpstan-functional.neon new file mode 100644 index 0000000..2cb3303 --- /dev/null +++ b/t/share/PHPStan/phpstan-functional.neon @@ -0,0 +1,15 @@ +includes: + - ./baselines/baseline.xml + - /includes/ + +parameters: + level: 1 + tmpDir: /tmp + parallel: + maximumNumberOfProcesses: 6 + paths: + - /src/Command/ + - /src/Service/ + excludePaths: + - /ignored/ + - /src/Command/Config/ConfigPhraseKeyCommand.php \ No newline at end of file diff --git a/t/share/PHPUnit/phpunit-output-functional.txt b/t/share/PHPUnit/phpunit-output-functional.txt new file mode 100644 index 0000000..a7a4a91 --- /dev/null +++ b/t/share/PHPUnit/phpunit-output-functional.txt @@ -0,0 +1,52 @@ +PHPUnit 10.5.10 by Sebastian Bergmann and contributors. + +Runtime: PHP 8.2.8 with Xdebug 3.2.1 +Configuration: phpunit.xml.dist + +.............R................. 31 / 31 (100%) + +Time: 00:00.681, Memory: 18.00 MB + +There was 1 risky test: + +1) WickedOne\PhraseTagBundle\Tests\Unit\Command\PhraseKeyUntagCommandTest::testTagProviderException +This test did not perform any assertions + +/tests/Unit/Command/PhraseKeyUntagCommandTest.php:59 + +OK, but there were issues! +Tests: 31, Assertions: 101, Risky: 1. + +Generating code coverage report in Cobertura XML format ... done [00:00.009] + + +Code Coverage Report: + 2024-02-09 08:43:00 + + Summary: + Classes: 75.00% (6/8) + Methods: 91.67% (22/24) + Lines: 97.39% (149/153) + +WickedOne\PhraseTagBundle\Command\AbstractPhraseKeyCommand + Methods: 100.00% ( 4/ 4) Lines: 100.00% ( 30/ 30) +WickedOne\PhraseTagBundle\Command\PhraseKeyTagCommand + Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 13/ 13) +WickedOne\PhraseTagBundle\Command\Config\ConfigPhraseKeyCommand + Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 13/ 13) +WickedOne\PhraseTagBundle\Command\PhraseKeyUntagCommand + Methods: 50.00% ( 1/ 2) Lines: 76.92% ( 10/ 13) +WickedOne\PhraseTagBundle\DependencyInjection\Configuration + Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 9/ 9) +WickedOne\PhraseTagBundle\DependencyInjection\WickedOnePhraseTagExtension + Methods: 100.00% ( 5/ 5) Lines: 100.00% ( 20/ 20) +WickedOne\PhraseTagBundle\Service\PhraseTagService + Methods: 80.00% ( 4/ 5) Lines: 97.96% ( 48/ 49) +WickedOne\PhraseTagBundle\Service\PhraseTaggerFactory + Methods: 100.00% ( 3/ 3) Lines: 100.00% ( 18/ 18) +WickedOne\PhraseTagBundle\Service\Provider\SomethingProvider + Methods: 66.66% ( 2/ 3) Lines: 80.00% ( 8/ 10) +WickedOne\PhraseTagBundle\WickedOnePhraseTagBundle + Methods: 100.00% ( 1/ 1) Lines: 100.00% ( 1/ 1) + +Generating code coverage report in PHPUnit XML format ... done [00:00.123] diff --git a/t/share/PHPUnit/phpunit-report-functional.txt b/t/share/PHPUnit/phpunit-report-functional.txt new file mode 100644 index 0000000..9401244 --- /dev/null +++ b/t/share/PHPUnit/phpunit-report-functional.txt @@ -0,0 +1,29 @@ +Code Coverage Report for @teams/alpha: + 2024-02-17 08:49:26 + +Summary: + Classes: 50.00% (3/6) + Methods: 84.21% (16/19) + Lines: 95.49% (127/133) + +WickedOne\PhraseTagBundle\Command\AbstractPhraseKeyCommand + Methods: 100.00% ( 4/ 4) Lines: 100.00% ( 30/ 30) + +WickedOne\PhraseTagBundle\Command\PhraseKeyTagCommand + Methods: 100.00% ( 2/ 2) Lines: 100.00% ( 13/ 13) + +WickedOne\PhraseTagBundle\Command\PhraseKeyUntagCommand + Methods: 50.00% ( 1/ 2) Lines: 76.92% ( 10/ 13) + +WickedOne\PhraseTagBundle\Service\PhraseTagService + Methods: 80.00% ( 4/ 5) Lines: 97.96% ( 48/ 49) + +WickedOne\PhraseTagBundle\Service\PhraseTaggerFactory + Methods: 100.00% ( 3/ 3) Lines: 100.00% ( 18/ 18) + +WickedOne\PhraseTagBundle\Service\Provider\SomethingProvider + Methods: 66.66% ( 2/ 3) Lines: 80.00% ( 8/ 10) + + + ! [NOTE] Your coverage is 95.49% percentage points over the required coverage. + ! Consider increasing the required coverage percentage. diff --git a/t/share/Psalm/psalm-functional.xml b/t/share/Psalm/psalm-functional.xml new file mode 100644 index 0000000..5254b93 --- /dev/null +++ b/t/share/Psalm/psalm-functional.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/t/unit/GPH/PHPUnit.t b/t/unit/GPH/PHPUnit.t index e1e3f44..96c23fb 100644 --- a/t/unit/GPH/PHPUnit.t +++ b/t/unit/GPH/PHPUnit.t @@ -30,6 +30,7 @@ describe "class `$CLASS`" => sub { tests "baseline file not found" => sub { ok(dies{$CLASS->new((codeowners => CODEOWNERS_FILE, owner =>'@teams/alpha', baseline => 'foo.txt'))}, 'died with baseline not found') or note ($@); + ok(lives{$CLASS->new((codeowners => CODEOWNERS_FILE, owner =>'@teams/alpha', classmap => CLASSMAP_FILE, baseline => PHPUNIT_BASELINE_FILE))}, 'lives with correct baseline') or note ($@); }; };