You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Allow modules to be included for testing without requiring coverage.
Sometimes it is useful to get at the internals of a module that is not being tested for coverage in order to provide coverage for another module that is being tested. The include directive allows this. Update modules that had previously been added to coverage that only need to be included.
This commit is contained in:
		| @@ -21,6 +21,8 @@ | ||||
| # Some options are unique to tests: | ||||
| #     * total - total runs in the test | ||||
| #     * vm - VMs that the test will be run on | ||||
| #     * include - modules to include directly into test.c (all files in coverage are automatically included) | ||||
| #           This is useful when a module's internal data needs to be manipulated for testing but no coverage is added by the test. | ||||
| # ********************************************************************************************************************************** | ||||
|  | ||||
| # ********************************************************************************************************************************** | ||||
| @@ -427,7 +429,9 @@ unit: | ||||
|           storage/cifs/storage: full | ||||
|           storage/posix/storage: full | ||||
|           storage/helper: full | ||||
|           storage/storage: full | ||||
|  | ||||
|         include: | ||||
|           - storage/storage | ||||
|  | ||||
|       # ---------------------------------------------------------------------------------------------------------------------------- | ||||
|       - name: posix | ||||
| @@ -453,10 +457,12 @@ unit: | ||||
|           storage/remote/storage: full | ||||
|           storage/remote/write: full | ||||
|           storage/helper: full | ||||
|           storage/read: full | ||||
|           storage/write: full | ||||
|           storage/storage: full | ||||
|  | ||||
|         include: | ||||
|           - storage/read | ||||
|           - storage/write | ||||
|  | ||||
|       # ---------------------------------------------------------------------------------------------------------------------------- | ||||
|       - name: s3 | ||||
|         total: 3 | ||||
| @@ -587,7 +593,9 @@ unit: | ||||
|         coverage: | ||||
|           command/backup/file: full | ||||
|           command/backup/protocol: full | ||||
|           storage/storage: full | ||||
|  | ||||
|         include: | ||||
|           - storage/storage | ||||
|  | ||||
|       # ---------------------------------------------------------------------------------------------------------------------------- | ||||
|       - name: command | ||||
|   | ||||
| @@ -53,6 +53,8 @@ use constant TESTDEF_DEFINE_TEST                                    => 'define-t | ||||
|     push @EXPORT, qw(TESTDEF_DEFINE_TEST); | ||||
| use constant TESTDEF_DEBUG_UNIT_SUPPRESS                            => 'debugUnitSuppress'; | ||||
|     push @EXPORT, qw(TESTDEF_DEBUG_UNIT_SUPPRESS); | ||||
| use constant TESTDEF_INCLUDE                                        => 'include'; | ||||
|     push @EXPORT, qw(TESTDEF_INCLUDE); | ||||
| use constant TESTDEF_INDIVIDUAL                                     => 'individual'; | ||||
|     push @EXPORT, qw(TESTDEF_INDIVIDUAL); | ||||
| use constant TESTDEF_TOTAL                                          => 'total'; | ||||
| @@ -180,6 +182,9 @@ sub testDefLoad | ||||
|                         push(@{$hCoverageList->{$strCodeModule}}, {strModule=> $strModule, strTest => $strTest}); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 # Set include list | ||||
|                 $hTestDefHash->{$strModule}{$strTest}{&TESTDEF_INCLUDE} = $hModuleTest->{&TESTDEF_INCLUDE}; | ||||
|             } | ||||
|  | ||||
|             $hModuleTest->{$strModule} = \@stryModuleTest; | ||||
|   | ||||
| @@ -291,6 +291,8 @@ sub run | ||||
|  | ||||
|                 foreach my $strFile (sort(keys(%{$self->{oStorageTest}->manifest($self->{strGCovPath})}))) | ||||
|                 { | ||||
|                     my $strFileNoExt = substr($strFile, 0, length($strFile) - 2); | ||||
|  | ||||
|                     # Skip all files except .c files (including .auto.c) | ||||
|                     next if $strFile !~ /(?<!\.auto)\.c$/; | ||||
|  | ||||
| @@ -300,7 +302,7 @@ sub run | ||||
|                     # Skip test.c -- it will be added manually at the end | ||||
|                     next if $strFile =~ /test\.c$/; | ||||
|  | ||||
|                     if (!defined($hTestCoverage->{substr($strFile, 0, length($strFile) - 2)}) && | ||||
|                     if (!defined($hTestCoverage->{$strFileNoExt}) && !grep(/^$strFileNoExt$/, @{$hTest->{&TESTDEF_INCLUDE}}) && | ||||
|                         $strFile !~ /^test\/module\/[^\/]*\/.*Test\.c$/) | ||||
|                     { | ||||
|                         push(@stryCFile, "${strFile}"); | ||||
| @@ -313,7 +315,7 @@ sub run | ||||
|                     "test/module/$self->{oTest}->{&TEST_MODULE}/" . testRunName($self->{oTest}->{&TEST_NAME}, false) . 'Test.c'; | ||||
|                 my $strCInclude; | ||||
|  | ||||
|                 foreach my $strFile (sort(keys(%{$hTestCoverage}))) | ||||
|                 foreach my $strFile (sort(keys(%{$hTestCoverage}), @{$hTest->{&TESTDEF_INCLUDE}})) | ||||
|                 { | ||||
|                     # Don't include the test file as it is already included below | ||||
|                     next if $strFile =~ /Test$/; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user