7 use Test::More 'no_plan';
10 use Catalyst::Script::Server;
14 # Test default (no opts/args behaviour)
15 testOption( [ qw// ], ['3000', 'localhost', opthash()] );
17 # Old version supports long format opts with either one or two dashes. New version only supports two.
19 # help -? -help --help -h --help
20 # debug -d -debug --debug -d --debug
21 # host -host --host --host
22 testOption( [ qw/--host testhost/ ], ['3000', 'testhost', opthash()] );
23 testOption( [ qw/-h testhost/ ], ['3000', 'testhost', opthash()] );
25 # port -p -port --port -l --listen
26 testOption( [ qw/-p 3001/ ], ['3001', 'localhost', opthash()] );
27 testOption( [ qw/--port 3001/ ], ['3001', 'localhost', opthash()] );
29 # fork -f -fork --fork -f --fork
30 $testopts = opthash();
31 $testopts->{fork} = 1;
32 testOption( [ qw/--fork/ ], ['3000', 'localhost', $testopts] );
33 testOption( [ qw/-f/ ], ['3000', 'localhost', $testopts] );
35 # pidfile -pidfile --pid --pidfile
36 $testopts = opthash();
37 $testopts->{pidfile} = "cat.pid";
38 testOption( [ qw/--pidfile cat.pid/ ], ['3000', 'localhost', $testopts] );
40 # keepalive -k -keepalive --keepalive -k --keepalive
41 $testopts = opthash();
42 $testopts->{keepalive} = 1;
43 testOption( [ qw/-k/ ], ['3000', 'localhost', $testopts] );
44 testOption( [ qw/--keepalive/ ], ['3000', 'localhost', $testopts] );
46 # symlinks -follow_symlinks --sym --follow_symlinks
47 $testopts = opthash();
48 $testopts->{follow_symlinks} = 1;
49 testOption( [ qw/--follow_symlinks/ ], ['3000', 'localhost', $testopts] );
51 # background -background --bg --background
52 $testopts = opthash();
53 $testopts->{background} = 1;
54 testOption( [ qw/--background/ ], ['3000', 'localhost', $testopts] );
56 # Restart stuff requires a threaded perl, apparently.
57 # restart -r -restart --restart -R --restart
58 # restart dly -rd -restartdelay --rdel --restart_delay
59 # restart dir -restartdirectory --rdir --restart_directory
60 # restart regex -rr -restartregex --rxp --restart_regex
64 my ($argstring, $resultarray) = @_;
66 subtest "Test for ARGV: @$argstring" => sub
69 local @ARGV = @$argstring;
70 local @TestAppToTestScripts::RUN_ARGS;
72 Catalyst::Script::Server->new_with_options(application_name => 'TestAppToTestScripts')->run;
74 # First element of RUN_ARGS will be the script name, which we don't care about
75 shift @TestAppToTestScripts::RUN_ARGS;
76 is_deeply \@TestAppToTestScripts::RUN_ARGS, $resultarray, "is_deeply comparison";
81 # Returns the hash expected when no flags are passed
83 return { 'pidfile' => undef,
85 'follow_symlinks' => undef,
86 'background' => undef,