From 1919f16632d60d4b87e3320e21361aea14b9ee94 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Mon, 28 Dec 2020 18:38:49 +0100 Subject: [PATCH 1/2] /proc/$*PID/status is a binary file on Solaris, so skip this test there. The test is for reading line-by-line, so trying to change it to handle binary files defeats the intent. --- S16-io/eof.t | 2 ++ 1 file changed, 2 insertions(+) diff --git a/S16-io/eof.t b/S16-io/eof.t index a4e8776dfe..a52d4fe0d7 100644 --- a/S16-io/eof.t +++ b/S16-io/eof.t @@ -83,6 +83,8 @@ subtest '.eof on empty files' => { subtest "reading from '$p'" => { plan 3; when not $p.e { skip "don't have '$p' available", 3 } + # issue 1533 was all about line-by-line reading, so this skip seems reasonable: + when $*KERNEL.name eq 'sunos' { skip "'$p' is a binary file on Solaris", 3 } with $p.open { is-deeply .eof, False, 'eof is False before any reads'; cmp-ok .get, &[!~~], Nil, '.get reads something'; From 1aa335ddd947f4880208f730c2bedbe21815edff Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 30 Dec 2020 11:40:50 +0100 Subject: [PATCH 2/2] Tweak the subtest "run and shell's :cwd" so that it also passes on Solaris. It turns out that `echo $PWD` isn't *quite* portable. The test assumes that the shell will set the environment variable PWD to the current directory as part of its startup. This is needed, because the implementation detail being tested here is that the command is run with a *different* current directory from the Raku code - ie there is a `chdir` happening as part of the command invocation, without affecting the invokee. Solaris (these days) uses ksh93, and *that* turns out to be wonderfully special. If the current directory is `/` or `~`, then it *does* set PWD (to the canonical path). Otherwise it leaves PWD unchanged. I *guess* that this is because it has to figure out the name => (dev,ino) mapping for these two paths anyway, and it's cheap to stat("."), so it updates PWD if it happens to find that it knows the pathname corresponding to "."'s (dev,ino), but doesn't do any extra work if it doesn't recognise ".". I don't find this documented anywhere. AIX appears to use an older ksh, and that *is* updating PWD. (That's all the vendor OSes I currently have access to, to test.) So run `pwd` instead of relying on $PWD being set. I think that this will also work even if the shell is a Bourne Shell, as I don't believe that there's any *requirement* for the shell to set this variable. So Zoffix Znet was correct to write Don't know how sanely portable that is... in Jan 2018 in https://github.com/Raku/roast/issues/375 --- S29-os/system.t | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/S29-os/system.t b/S29-os/system.t index 06eee5347c..4d1da723f8 100644 --- a/S29-os/system.t +++ b/S29-os/system.t @@ -103,10 +103,21 @@ throws-like { shell("program_that_does_not_exist_ignore_errors_please.exe") }, subtest "run and shell's :cwd" => { plan 4; + # So... + # `echo $PWD` works *nearly* everywhere, because the shell sets the + # environment variable PWD to the current directory on startup. + # Except on Solaris, where /bin/sh only sets $PWD to the current directory + # if it happens to be / or the user's home directory. + # Otherwise it leaves it unchanged. + # (Even AIX isn't this nuts. Why is ksh93 so special?) + # Which matters to this test, because we (eg MoarVM) call chdir to our temp + # directory before we exec the shell, and we don't change PWD in our C + # environment. + # So use pwd instead. And use `exec pwd` to test that we have run the shell. my @run-cmd = $*DISTRO.is-win ?? ('cmd.exe', '/C', 'echo %CD%') - !! ('/bin/sh', '-c', 'echo $PWD'); + !! ('/bin/sh', '-c', 'exec pwd'); my $shell-cmd = $*DISTRO.is-win ?? 'echo %CD%' - !! 'echo $PWD'; + !! 'exec pwd'; indir (my $cwd = make-temp-dir.absolute), { (my $p = run @run-cmd, :!err, :out)