Hi all, I noticed that src/bin/initdb/t/001_initdb.pl uses directly rm via a system() call like that: system_or_bail "rm -rf '$tempdir'/*";
This way of doing is not portable, particularly on platforms that do not have rm like... Windows where the equivalent is del. And we could actually use remove_tree with its option keep_root to get the same effect in pure perl as mentioned here: http://perldoc.perl.org/File/Path.html With this formulation: remove_tree($tempdir, {keep_root => 1}); Attached is a patch doing that. Regards, -- Michael
diff --git a/src/bin/initdb/t/001_initdb.pl b/src/bin/initdb/t/001_initdb.pl index d12be84..85db9ff 100644 --- a/src/bin/initdb/t/001_initdb.pl +++ b/src/bin/initdb/t/001_initdb.pl @@ -1,6 +1,7 @@ use strict; use warnings; use TestLib; +use File::Path qw(remove_tree); use Test::More tests => 19; my $tempdir = TestLib::tempdir; @@ -18,27 +19,27 @@ command_fails([ 'initdb', '-S', "$tempdir/data3" ], mkdir "$tempdir/data4" or BAIL_OUT($!); command_ok([ 'initdb', "$tempdir/data4" ], 'existing empty data directory'); -system_or_bail "rm -rf '$tempdir'/*"; +remove_tree($tempdir, {keep_root => 1}); command_ok([ 'initdb', '-X', "$tempdir/pgxlog", "$tempdir/data" ], 'separate xlog directory'); -system_or_bail "rm -rf '$tempdir'/*"; +remove_tree($tempdir, {keep_root => 1}); command_fails( [ 'initdb', "$tempdir/data", '-X', 'pgxlog' ], 'relative xlog directory not allowed'); -system_or_bail "rm -rf '$tempdir'/*"; +remove_tree($tempdir, {keep_root => 1}); mkdir "$tempdir/pgxlog"; command_ok([ 'initdb', '-X', "$tempdir/pgxlog", "$tempdir/data" ], 'existing empty xlog directory'); -system_or_bail "rm -rf '$tempdir'/*"; +remove_tree($tempdir, {keep_root => 1}); mkdir "$tempdir/pgxlog"; mkdir "$tempdir/pgxlog/lost+found"; command_fails([ 'initdb', '-X', "$tempdir/pgxlog", "$tempdir/data" ], 'existing nonempty xlog directory'); -system_or_bail "rm -rf '$tempdir'/*"; +remove_tree($tempdir, {keep_root => 1}); command_ok([ 'initdb', '-T', 'german', "$tempdir/data" ], 'select default dictionary');
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers