Hello,

When trying to use a custom dump with the test pg_upgrade/002_pg_upgrade,
I observe the following test failure on Windows:
>meson test --suite setup
>echo create database regression>...\dump.sql
>set olddump=...\dump.sql& set oldinstall=.../tmp_install/usr/local/pgsql& 
meson test pg_upgrade/002_pg_upgrade

1/1 postgresql:pg_upgrade / pg_upgrade/002_pg_upgrade ERROR            11.38s   
exit status 1

regress_log_002_pg_upgrade.txt contains:
...
[09:07:06.704](3.793s) ok 11 - run of pg_upgrade for new instance
...
[09:07:07.301](0.001s) not ok 15 - old and new dumps match after pg_upgrade
[09:07:07.301](0.000s) #   Failed test 'old and new dumps match after 
pg_upgrade'
#   at .../src/bin/pg_upgrade/t/002_pg_upgrade.pl line 452.
[09:07:07.301](0.000s) #          got: '1'
#     expected: '0'
=== diff of ...\build\testrun\pg_upgrade\002_pg_upgrade\data\tmp_test_ifk8/dump1.sql and ...\build\testrun\pg_upgrade\002_pg_upgrade\data\tmp_test_ifk8/dump2.sql
=== stdout ===
=== stderr ===
=== EOF ===


>dir "testrun\pg_upgrade\002_pg_upgrade\data\tmp_test_ifk8/"
11/25/2023  09:06 AM             2,729 dump1.sql
11/25/2023  09:07 AM             2,590 dump2.sql

>diff -s "testrun\pg_upgrade\002_pg_upgrade\data\tmp_test_ifk8\dump1.sql" "testrun\pg_upgrade\002_pg_upgrade\data\tmp_test_ifk8\dump2.sql" Files testrun\pg_upgrade\002_pg_upgrade\data\tmp_test_ifk8\dump1.sql and testrun\pg_upgrade\002_pg_upgrade\data\tmp_test_ifk8\dump2.sql are identical

As I can see, dump1.sql contains line endings 0d 0a, while dump2.sql — 0a.

The attached patch fixes the issue for me.

Best regards,
Alexander
diff --git a/src/bin/pg_upgrade/t/002_pg_upgrade.pl b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
index c6d83d3c21..d34b45e346 100644
--- a/src/bin/pg_upgrade/t/002_pg_upgrade.pl
+++ b/src/bin/pg_upgrade/t/002_pg_upgrade.pl
@@ -293,6 +293,7 @@ if (defined($ENV{oldinstall}))
 	}
 
 	open my $fh, ">", $dump1_file or die "could not open dump file";
+	binmode $fh;
 	print $fh $dump_data;
 	close $fh;
 

Reply via email to