File: shell_guess__os_proc.t

package info (click to toggle)
libshell-guess-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 256 kB
  • sloc: perl: 166; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use strict;
use warnings;
use Test::More;
use File::Spec;
use lib 't/lib';
use FakeLogin;
use Shell::Guess;

my $sh  = File::Spec->catdir('', 'bin', 'sh');
my $csh = File::Spec->catdir('', 'bin', 'csh');

plan skip_all => 'test requires a /proc filesystem' unless -f File::Spec->catdir('', 'proc', $$, 'cmdline');
plan skip_all => 'test requires bourne shell in /bin/sh' unless -x $sh;
plan skip_all => 'test requires c shell in /bin/csh' unless -x $csh;
plan skip_all => 'test requires that PERL5OPT not be set' if defined $ENV{PERL5OPT};

plan tests => 3;

is(Shell::Guess->login_shell->is_bourne, 1, 'faked out a bourne shell');

$ENV{PERL5OPT} = "-It/lib -MFakeLogin";

like `$^X -MShell::Guess -e 'print Shell::Guess->login_shell->name, "\n"'`, qr{bourne}, 'sub process still found fake bourne shell';

my $lib = -d File::Spec->catdir('blib') ? '-Mblib' : "-I" . File::Spec->catdir('lib');

note "lib = $lib";

like `$csh -c '$^X $lib corpus/print_guess.pl'`, qr{c}, 'sub process found real c shell';