From fdab9843ba84d64e96e461c9f8e78a932cc366e1 Mon Sep 17 00:00:00 2001
From: Georgios Kokolatos <gkokolatos@pm.me>
Date: Fri, 2 Dec 2022 16:02:51 +0000
Subject: [PATCH v14 1/4] Provide coverage for pg_dump default compression for
 dir format

The restore program will succeed regardless of whether the dumped output was
compressed or not. This commit implements a portable way to check the contents
of the directory via perl's build in filename expansion.
---
 src/bin/pg_dump/t/002_pg_dump.pl | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 709db0986d..03b5375e70 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -215,6 +215,7 @@ my %pgdump_runs = (
 	# Do not use --no-sync to give test coverage for data sync.
 	defaults_dir_format => {
 		test_key => 'defaults',
+		compile_option => 'gzip',
 		dump_cmd => [
 			'pg_dump',                             '-Fd',
 			"--file=$tempdir/defaults_dir_format", 'postgres',
@@ -224,6 +225,7 @@ my %pgdump_runs = (
 			"--file=$tempdir/defaults_dir_format.sql",
 			"$tempdir/defaults_dir_format",
 		],
+		glob_pattern => "$tempdir/defaults_dir_format/*.dat.gz"
 	},
 
 	# Do not use --no-sync to give test coverage for data sync.
@@ -4153,6 +4155,13 @@ foreach my $run (sort keys %pgdump_runs)
 		command_ok(\@full_compress_cmd, "$run: compression commands");
 	}
 
+	if ($pgdump_runs{$run}->{glob_pattern})
+	{
+		my $glob_pattern = $pgdump_runs{$run}->{glob_pattern};
+		my @glob_output = glob($glob_pattern);
+		is(scalar(@glob_output) > 0, 1, "glob pattern matched")
+	}
+
 	if ($pgdump_runs{$run}->{restore_cmd})
 	{
 		$node->command_ok(\@{ $pgdump_runs{$run}->{restore_cmd} },
-- 
2.34.1

