-
Notifications
You must be signed in to change notification settings - Fork 138
/
002-messages.t
129 lines (102 loc) · 3.03 KB
/
002-messages.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#! perl
# Copyright (C) 2007, Parrot Foundation.
# 002-messages.t
use strict;
use warnings;
use Carp;
use Test::More tests => 13;
use lib qw( lib );
use Parrot::Configure::Messages qw|
print_introduction
print_conclusion
|;
use IO::CaptureOutput qw| capture |;
my $parrot_version = '0.4.10';
my $make_version = 'gnu make';
{
my ( $rv, $stdout );
capture(
sub { $rv = print_introduction($parrot_version); },
\$stdout,
);
ok( $rv, "print_introduction() returned true" );
# Following test is definitive.
like( $stdout, qr/$parrot_version/,
"Message included Parrot version number supplied as argument" );
# Following tests are NOT definitive. They will break if content of
# strings printed by function is changed.
like( $stdout, qr/Parrot\sVersion/i, "Message included string 'Parrot version'" );
like( $stdout, qr/Configure/i, "Message included string 'Configure'" );
like( $stdout, qr/Copyright/i, "Message included copyright notice" );
}
{
my ( $rv, $stdout );
my $pseudo_conf = {
log => [],
};
my $args = {};
capture(
sub { $rv = print_conclusion($pseudo_conf, $make_version, $args); },
\$stdout,
);
ok( $rv, "print_conclusion() returned true" );
# Following test is definitive.
like( $stdout, qr/$make_version/, "Message included make version supplied as argument" );
}
{
my ( $rv, $stdout, $stderr );
my $pseudo_conf = {
log => [],
};
my $args = { silent => 1 };
capture(
sub { $rv = print_conclusion($pseudo_conf, $make_version, $args); },
\$stdout,
\$stderr,
);
ok( $rv, "print_conclusion() returned true" );
# Following test is definitive.
ok( ! $stdout, "Configure.pl operated silently, as requested" );
}
{
my ( $rv, $stdout, $stderr );
my $pseudo_conf = {
log => [
undef,
{ step => q{init::manifest} },
],
};
my $args = {};
capture(
sub { $rv = print_conclusion($pseudo_conf, $make_version, $args); },
\$stdout,
\$stderr,
);
ok(! defined $rv, "print_conclusion() returned undefined value" );
ok( ! $stdout,
"Because of the error, nothing printed to standard output");
like( $stderr,
qr/During configuration the following steps failed:.*init::manifest/s,
"Got expected message re configuration step failure" );
}
pass("Completed all tests in $0");
################### DOCUMENTATION ###################
=head1 NAME
002-messages.t - test Parrot::Configure::Messages
=head1 SYNOPSIS
% prove t/configure/components/002-messages.t
=head1 DESCRIPTION
The files in this directory test functionality used by F<Configure.pl>.
The tests in this file test subroutines exported by
Parrot::Configure::Messages.
=head1 AUTHOR
James E Keenan
=head1 SEE ALSO
Parrot::Configure::Messages, F<Configure.pl>.
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: