File: 81_opts.t

package info (click to toggle)
libextutils-modulemaker-perl 0.63-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 744 kB
  • sloc: perl: 7,331; makefile: 11
file content (348 lines) | stat: -rw-r--r-- 12,870 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# t/81-opts.t
# tests of ExtUtils::ModuleMaker::Opts methods
use strict;
use warnings;
use Test::More;
use_ok( 'ExtUtils::ModuleMaker::Opts' );
use IO::Capture::Stdout;
use IO::Capture::Stderr;

my ($eumm_package, $eumm_script, $opt);
$eumm_package = q{ExtUtils::ModuleMaker};
$eumm_script  = q{modulemaker};

{
    note("Case 1: Simplest possible use; INTERACTIVE declined");

    my $name = 'Alpha::Beta';
    local @ARGV = ('-n' => $name, '-I' => 0);

    $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    ok(defined $opt, "ExtUtils::ModuleMaker::Opts returned defined value");
    isa_ok($opt, 'ExtUtils::ModuleMaker::Opts');

    my %stan = $opt->get_standard_options();
    is($stan{NAME}, $name, "NAME correctly set to $name");
    ok(! exists $stan{ABSTRACT}, "No ABSTRACT set");

    like($stan{USAGE_MESSAGE},
        qr/^modulemaker.*Currently Supported Features/s,
        "Got USAGE MESSAGE"
    );
}

{
    note("Case 2: Simplest possible use; assign values to several options; INTERACTIVE declined");

    my $name = 'Alpha::Beta';
    my $abstract = 'Traverse the Greek alphabet';
    my $author = 'Chango Ta Beni';
    my $cpanid = 'CHANGO';
    my $email = 'chango_ta_beni@example.com';
    local @ARGV = (
        '-a' => $abstract,
        '-u' => $author,
        '-p' => $cpanid,
        '-e' => $email,
        '-n' => $name,
        '-I' => ''   # -I must go last
    );

    $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    ok(defined $opt, "ExtUtils::ModuleMaker::Opts returned defined value");
    isa_ok($opt, 'ExtUtils::ModuleMaker::Opts');

    my %stan = $opt->get_standard_options();
    is($stan{NAME}, $name, "NAME correctly set to $name");
    is($stan{ABSTRACT}, $abstract, "ABSTRACT correctly set to $abstract");
    is($stan{AUTHOR}, $author, "AUTHOR correctly set to $author");
    is($stan{CPANID}, $cpanid, "CPANID correctly set to $cpanid");
    is($stan{EMAIL}, $email, "EMAIL correctly set to $email");
}

{
    note("Case 3: Simplest possible use; mix options with take/do not take values (grouped); INTERACTIVE declined");

    my $name = 'Alpha::Beta';
    my $abstract = 'Traverse the Greek alphabet';
    my $author = 'Chango Ta Beni';
    my $cpanid = 'CHANGO';
    my $email = 'chango_ta_beni@example.com';
    local @ARGV = (
        '-a' => $abstract,
        '-u' => $author,
        '-p' => $cpanid,
        '-e' => $email,
        '-n' => $name,
        '-cVPq',
        '-I' => ''   # -I must go last
    );

    $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    ok(defined $opt, "ExtUtils::ModuleMaker::Opts returned defined value");
    isa_ok($opt, 'ExtUtils::ModuleMaker::Opts');

    my %stan = $opt->get_standard_options();
    is($stan{NAME}, $name, "NAME correctly set to $name");
    is($stan{ABSTRACT}, $abstract, "ABSTRACT correctly set to $abstract");
    is($stan{AUTHOR}, $author, "AUTHOR correctly set to $author");
    is($stan{CPANID}, $cpanid, "CPANID correctly set to $cpanid");
    is($stan{EMAIL}, $email, "EMAIL correctly set to $email");
    ok($stan{COMPACT}, "COMPACT build requested");
    ok($stan{VERBOSE}, "VERBOSE output requested");
    ok(!$stan{NEED_POD}, "NEED_POD output requested");
    ok(!$stan{NEED_NEW_METHOD}, "NEED_NEW_METHOD output requested");
}

{
    note("Case 4: Simplest possible use; mix options with take/do not take values (ungrouped); INTERACTIVE declined");

    my $name = 'Alpha::Beta';
    my $abstract = 'Traverse the Greek alphabet';
    my $author = 'Chango Ta Beni';
    my $cpanid = 'CHANGO';
    my $email = 'chango_ta_beni@example.com';
    my $organization = 'World Wide Web, Inc.';
    my $website = 'http://example.com';
    my $permissions = '0711';
    my $version = '0.03';
    my $license = 'apache';
    local @ARGV = (
        '-a' => $abstract,
        '-u' => $author,
        '-p' => $cpanid,
        '-e' => $email,
        '-n' => $name,
        '-o' => $organization,
        '-w' => $website,
        '-r' => $permissions,
        '-v' => $version,
        '-l' => $license,
        '-c',
        '-C',  # Changes in POD
        '-V',
        '-b',
        '-I' => ''   # -I must go last
    );

    $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    ok(defined $opt, "ExtUtils::ModuleMaker::Opts returned defined value");
    isa_ok($opt, 'ExtUtils::ModuleMaker::Opts');

    my %stan = $opt->get_standard_options();
    is($stan{NAME}, $name, "NAME correctly set to $name");
    is($stan{ABSTRACT}, $abstract, "ABSTRACT correctly set to $abstract");
    is($stan{AUTHOR}, $author, "AUTHOR correctly set to $author");
    is($stan{CPANID}, $cpanid, "CPANID correctly set to $cpanid");
    is($stan{EMAIL}, $email, "EMAIL correctly set to $email");
    is($stan{ORGANIZATION}, $organization, "ORGANIZATION correctly set to $organization");
    is($stan{WEBSITE}, $website, "WEBSITE correctly set to $website");
    is($stan{PERMISSIONS}, $permissions, "PERMISSIONS correctly set to $permissions");
    is($stan{VERSION}, $version, "VERSION correctly set to $version");
    is($stan{LICENSE}, $license, "LICENSE correctly set to $license");
    ok($stan{COMPACT}, "COMPACT build requested");
    ok($stan{CHANGES_IN_POD}, "CHANGES_IN_POD build requested");
    ok($stan{VERBOSE}, "VERBOSE output requested");
    ok($stan{BUILD_SYSTEM}, "BUILD_SYSTEM set to true; will request Module::Build");
}

{
    note("Case 5:  test help switch '-h'");

    local @ARGV = ( '-h' );

	my $capture = IO::Capture::Stdout->new();
    $capture->start();
    my $opt =  ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    $capture->stop();
    ok(! $opt, "system call to modulemaker exited successfully");

    my $stdout = join("\n" => $capture->read());
    like($stdout, qr/^modulemaker \[-CIPVbch\]/s,
        "Got expected start of Usage message");
    like($stdout, qr/Currently Supported Features/s,
        "Got expected middle of Usage message");
    like($stdout, qr/modulemaker\s+ExtUtils::ModuleMaker\sversion:\s+\d\.\d{2}$/s,
        "Got expected end of Usage message");
}

{
    note("Case 6:  test absence of switch: '-n'");

    local @ARGV = ( '-cI' );

    my $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    my %stan = $opt->get_standard_options();
    ok(! $stan{NAME}, "NAME not set");
    ok($stan{COMPACT}, "COMPACT build requested");
}

note("Long options");

{
    note("Case 101: Simplest possible use; INTERACTIVE declined");

    my $name = 'Alpha::Beta';
    local @ARGV = ('--name' => $name, '--no-interactive' => 0);

    $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    ok(defined $opt, "ExtUtils::ModuleMaker::Opts returned defined value");
    isa_ok($opt, 'ExtUtils::ModuleMaker::Opts');

    my %stan = $opt->get_standard_options();
    is($stan{NAME}, $name, "NAME correctly set to $name");
    ok(! exists $stan{ABSTRACT}, "No ABSTRACT set");

    like($stan{USAGE_MESSAGE},
        qr/^modulemaker.*Currently Supported Features/s,
        "Got USAGE MESSAGE"
    );
}

{
    note("Case 102: Simplest possible use; assign values to several options; INTERACTIVE declined");

    my $name = 'Alpha::Beta';
    my $abstract = 'Traverse the Greek alphabet';
    my $author = 'Chango Ta Beni';
    my $cpanid = 'CHANGO';
    my $email = 'chango_ta_beni@example.com';
    local @ARGV = (
        '--abstract' => $abstract,
        '--author' => $author,
        '--cpanid' => $cpanid,
        '--email' => $email,
        '--name' => $name,
        '--no_interactive' => ''   # -I must go last
    );

    $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    ok(defined $opt, "ExtUtils::ModuleMaker::Opts returned defined value");
    isa_ok($opt, 'ExtUtils::ModuleMaker::Opts');

    my %stan = $opt->get_standard_options();
    is($stan{NAME}, $name, "NAME correctly set to $name");
    is($stan{ABSTRACT}, $abstract, "ABSTRACT correctly set to $abstract");
    is($stan{AUTHOR}, $author, "AUTHOR correctly set to $author");
    is($stan{CPANID}, $cpanid, "CPANID correctly set to $cpanid");
    is($stan{EMAIL}, $email, "EMAIL correctly set to $email");
}

{
    note("Case 103: Simplest possible use; mix options with take/do not take values (grouped); INTERACTIVE declined");

    my $name = 'Alpha::Beta';
    my $abstract = 'Traverse the Greek alphabet';
    my $author = 'Chango Ta Beni';
    my $cpanid = 'CHANGO';
    my $email = 'chango_ta_beni@example.com';
    local @ARGV = (
        '--abstract' => $abstract,
        '--author' => $author,
        '--cpanid' => $cpanid,
        '--email' => $email,
        '--name' => $name,
        '-cVPq',
        '--no_interactive' => ''   # -I must go last
    );

    $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    ok(defined $opt, "ExtUtils::ModuleMaker::Opts returned defined value");
    isa_ok($opt, 'ExtUtils::ModuleMaker::Opts');

    my %stan = $opt->get_standard_options();
    is($stan{NAME}, $name, "NAME correctly set to $name");
    is($stan{ABSTRACT}, $abstract, "ABSTRACT correctly set to $abstract");
    is($stan{AUTHOR}, $author, "AUTHOR correctly set to $author");
    is($stan{CPANID}, $cpanid, "CPANID correctly set to $cpanid");
    is($stan{EMAIL}, $email, "EMAIL correctly set to $email");
    ok($stan{COMPACT}, "COMPACT build requested");
    ok($stan{VERBOSE}, "VERBOSE output requested");
    ok(!$stan{NEED_POD}, "NEED_POD output requested");
    ok(!$stan{NEED_NEW_METHOD}, "NEED_NEW_METHOD output requested");
}

{
    note("Case 104: Simplest possible use; mix options with take/do not take values (ungrouped); INTERACTIVE declined");

    my $name = 'Alpha::Beta';
    my $abstract = 'Traverse the Greek alphabet';
    my $author = 'Chango Ta Beni';
    my $cpanid = 'CHANGO';
    my $email = 'chango_ta_beni@example.com';
    my $organization = 'World Wide Web, Inc.';
    my $website = 'http://example.com';
    my $permissions = '0711';
    my $version = '0.03';
    my $license = 'apache';
    local @ARGV = (
        '--abstract' => $abstract,
        '--author' => $author,
        '--cpanid' => $cpanid,
        '--email' => $email,
        '--name' => $name,
        '--organization' => $organization,
        '--website' => $website,
        '--permissions' => $permissions,
        '--version' => $version,
        '--license' => $license,
        '--compact',
        '--changes_in_pod',  # Changes in POD
        '--verbose',
        '--build_system',
        '--no_interactive' => ''   # -I must go last
    );

    $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    ok(defined $opt, "ExtUtils::ModuleMaker::Opts returned defined value");
    isa_ok($opt, 'ExtUtils::ModuleMaker::Opts');

    my %stan = $opt->get_standard_options();
    is($stan{NAME}, $name, "NAME correctly set to $name");
    is($stan{ABSTRACT}, $abstract, "ABSTRACT correctly set to $abstract");
    is($stan{AUTHOR}, $author, "AUTHOR correctly set to $author");
    is($stan{CPANID}, $cpanid, "CPANID correctly set to $cpanid");
    is($stan{EMAIL}, $email, "EMAIL correctly set to $email");
    is($stan{ORGANIZATION}, $organization, "ORGANIZATION correctly set to $organization");
    is($stan{WEBSITE}, $website, "WEBSITE correctly set to $website");
    is($stan{PERMISSIONS}, $permissions, "PERMISSIONS correctly set to $permissions");
    is($stan{VERSION}, $version, "VERSION correctly set to $version");
    is($stan{LICENSE}, $license, "LICENSE correctly set to $license");
    ok($stan{COMPACT}, "COMPACT build requested");
    ok($stan{CHANGES_IN_POD}, "CHANGES_IN_POD build requested");
    ok($stan{VERBOSE}, "VERBOSE output requested");
    ok($stan{BUILD_SYSTEM}, "BUILD_SYSTEM set to true; will request Module::Build");
}

{
    note("Case 105:  test help switch '--help'");

    local @ARGV = ( '--help' );

	my $capture = IO::Capture::Stdout->new();
    $capture->start();
    my $opt =  ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    $capture->stop();
    ok(! $opt, "system call to modulemaker exited successfully");

    my $stdout = join("\n" => $capture->read());
    like($stdout, qr/^modulemaker \[-CIPVbch\]/s,
        "Got expected start of Usage message");
    like($stdout, qr/Currently Supported Features/s,
        "Got expected middle of Usage message");
    like($stdout, qr/modulemaker\s+ExtUtils::ModuleMaker\sversion:\s+\d\.\d{2}$/s,
        "Got expected end of Usage message");
}

{
    note("Case 106:  test absence of switch: '--name'");

    local @ARGV = ( '--compact', '--no-interactive' );

    my $opt = ExtUtils::ModuleMaker::Opts->new( $eumm_package, $eumm_script );
    my %stan = $opt->get_standard_options();
    ok(! $stan{NAME}, "NAME not set");
    ok($stan{COMPACT}, "COMPACT build requested");
}

done_testing();