dbdpg
dbdpg copied to clipboard
Tests fail if root's shell is not a Bourne shell
At line 40 in t/dbdpg_test_setup.pl there's an "su" call which redirects output using Bourne shell syntax: $info = qx{su -m $testuser -c "$initdb --locale=C -E UTF8 -D $testdir/data 2>&1"}; If root's shell is, for example, tcsh, the above fails as follows: it writes to a file called "1" in the testdir: initdb: error: too many command-line arguments (first is "2") Try "initdb --help" for more information. In other words, it interprets the command, including "2>&1", using (in my case) tcsh.
I was able to work around that by setting the environment variable SHELL to /bin/sh before calling "cpan DBD::Pg", but you might consider setting that in the test environment, or as a --shell option to su, or perhaps putting a warning about this in the README file.
Thanks very much for DBD-Pg - I use it all the time! Much appreciated!
Anne.
Unfortunately, su -s /bin/sh doesn't work on macOS, Solaris, or FreeBSD. The su commands on those operating systems don't support -s/--shell. I'm not sure if all those are supported by DBD::Pg, but I know there are some macOS users.
Maybe $info = qx{su -m $testuser -c "/bin/sh -c '$initdb --locale=C -E UTF8 -D $testdir/data 2>&1'"};? (Untested.)
That seems to work, from my limited testing by forcing tcsh as a default shell. @AnneBennett could you test the solution above on your system?
That seems to work, from my limited testing by forcing tcsh as a default shell. @AnneBennett could you test the solution above on your system?
I'll look into this in a couple of weeks; I don't have access to the environment to test this just now.
Anne.
That seems to work, from my limited testing by forcing tcsh as a default shell. @AnneBennett could you test the solution above on your system?
Sorry about the delay.
I went to the first build directory that cpan had created for this installation back in November, and I edited t/dbdpg_test_setup.pl at line 410 from:
$info = qx{su -m $testuser -c "$initdb --locale=C -E UTF8 -D $testdir/data 2>&1"};
to:
$info = qx{su -m $testuser -c "/bin/sh -c '$initdb --locale=C -E UTF8 -D $testdir/data 2>&1'"};
Then I ran "make clean; /path/to/perl Makefile.PL; make; make test". Tests passed! :-)
Anne.
Thanks, @AnneBennett ! I have submitted PR #114 with the change you've tested in order to address this.
Fixed as of DBD::Pg version 3.16.2