/
author-04-examples.t
88 lines (72 loc) · 3.7 KB
/
author-04-examples.t
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use v6.c;
use lib 't/lib';
use Test;
use Template;
use nqp;
plan 16;
constant AUTHOR = ?%*ENV<AUTHOR_TESTING>;
if not AUTHOR {
skip-rest "Skipping author test";
exit;
}
my $tmpdir = '.tmp/test-platform-06-examples'.IO.absolute;
run <rm -rf>, $tmpdir if $tmpdir.IO.e;
mkdir $tmpdir;
ok $tmpdir.IO.e, "got $tmpdir";
{
my $proc = run <perl6 -Ilib bin/platform --project=examples/files-and-dirs run>, :out;
my $out = $proc.out.slurp-rest;
$proc = run <docker exec files-and-dirs ls -la /foo>, :out;
$out = $proc.out.slurp-rest;
for $out.lines -> $line {
next if $line ~~ / ^total /;
# drwxr-xr-x 1 root root 4096 Apr 19 11:33 ..
my @parts = $line.split(/ \s+ /);
next if @parts[8] eq '..';
is @parts[0], 'drwxr-xr-x', "/foo perm@'{@parts[8]}'";
is @parts[2], 'root', "/foo uid@'{@parts[8]}'";
is @parts[3], 'root', "/foo gid@'{@parts[8]}'";
}
$proc = run <docker exec files-and-dirs ls -la /bar>, :out;
$out = $proc.out.slurp-rest;
for $out.lines -> $line {
next if $line ~~ / ^total /;
my @parts = $line.split(/ \s+ /);
next if @parts[8] eq '..';
is @parts[0], 'drwxrwx---', "/bar perm@'{@parts[8]}'";
is @parts[2], 'nobody', "/bar uid@'{@parts[8]}'";
is @parts[3], 'nogroup', "/bar gid@'{@parts[8]}'";
}
$proc = run <docker exec files-and-dirs cat /lorem-ipsum.txt>, :out;
$out = $proc.out.slurp-rest;
is $out.Str.trim, 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis blandit auctor mollis. Praesent volutpat, dolor quis iaculis sagittis, ex ante rhoncus est, ultricies auctor libero justo sit amet leo. Vestibulum vitae semper quam. Pellentesque feugiat in est non consequat. Sed iaculis eget ex ut cursus. Nam convallis ex tortor, vel vestibulum lectus aliquet sagittis. Aenean elementum odio ut orci elementum rutrum. Aenean id elementum augue, condimentum semper leo.', 'got content /lorem-ipsum.txt';
$proc = run <docker exec files-and-dirs cat /b/words-from-file.p6>, :out;
$out = $proc.out.slurp-rest;
ok $out ~~ / word \s is \s a \s palindrome /, 'got content /b/words-from-file.p6';
$proc = run <docker exec files-and-dirs cat /code/examples/perl6/hello-world.p6>, :out;
$out = $proc.out.slurp-rest;
ok $out ~~ / ^\# /, 'shebang found on /code/examples/perl6/hello-world.p6';
ok $out ~~ / Hello \s Perl \s 6 \s World /, 'got content /code/examples/perl6/hello-world.p6';
$proc = run <docker exec files-and-dirs ls -la /code/examples/perl6/hello-world.p6>, :out;
$out = $proc.out.slurp-rest;
for $out.lines -> $line {
next if $line ~~ / ^total /;
my @parts = $line.split(/ \s+ /);
next if @parts[8] eq '..';
is @parts[0], '-rwxr-x---', "../hello-world.p6 perm@'{@parts[8]}'";
is @parts[2], 'nobody', "../hello-world.p6 uid@'{@parts[8]}'";
is @parts[3], 'nogroup', "../hello-world.p6 gid@'{@parts[8]}'";
}
run <perl6 -Ilib bin/platform --project=examples/files-and-dirs stop>;
run <perl6 -Ilib bin/platform --project=examples/files-and-dirs rm>;
}
{
my $proc = run <perl6 -Ilib bin/platform --project=examples/openldap run>, :out;
my $out = $proc.out.slurp-rest;
ok $out ~~ / 'uccessfully built' /, 'openldap built and executed';
$proc = shell 'docker exec openldap ldapsearch -x -H ldap://localhost -b dc=acme,dc=company -D cn=admin,dc=acme,dc=company -w aiquoD1F', :out;
$out = $proc.out.slurp-rest;
ok $out ~~ / 'uid=seppo,ou=people,dc=acme,dc=company' /, 'found seppo on ldap directory';
run <perl6 -Ilib bin/platform --project=examples/openldap stop>;
run <perl6 -Ilib bin/platform --project=examples/openldap rm>;
}