Changeset 23875
- Timestamp:
- Apr 15, 2009, 11:32:16 AM (17 years ago)
- Location:
- branches/neb_distrib_20081210/Nebulous
- Files:
-
- 2 edited
-
bin/neb-ls (modified) (7 diffs)
-
t/70_neb-ls.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/neb_distrib_20081210/Nebulous/bin/neb-ls
r18092 r23875 1 1 #!/usr/bin/env perl 2 2 3 # Copyright (C) 2007-2008 Joshua Hoblitt 4 # 5 # $Id: neb-ls,v 1.7 2008-06-12 20:03:37 jhoblitt Exp $ 3 # Copyright (C) 2007-2009 Joshua Hoblitt 6 4 7 5 use strict; … … 9 7 10 8 use vars qw( $VERSION ); 11 $VERSION = '0.0 2';9 $VERSION = '0.03'; 12 10 13 11 use Nebulous::Client; … … 16 14 use Pod::Usage qw( pod2usage ); 17 15 18 my ($server, $long, $recursive); 16 my ( 17 $server, 18 $long, 19 # $recursive, 20 ); 19 21 20 22 $server = $ENV{'NEB_SERVER'} unless $server; … … 22 24 GetOptions( 23 25 'server|s=s' => \$server, 24 'recursive|r' => \$recursive,26 # 'recursive|r' => \$recursive, 25 27 'l|1' => \$long, 26 28 ) || pod2usage( 2 ); … … 39 41 unless defined $neb; 40 42 41 # default to listing everything (bad idea?)42 $pattern ||= " .*";43 # default to listing root 44 $pattern ||= "/"; 43 45 44 if ($recursive) {45 $pattern = "^" . $pattern . ".*";46 } else {47 $pattern = "^" . $pattern . "\$";48 }46 #if ($recursive) { 47 # $pattern = "^" . $pattern . ".*"; 48 #} else { 49 # $pattern = "^" . $pattern . "\$"; 50 #} 49 51 50 52 my $keys = $neb->find_objects($pattern); … … 86 88 Optional 87 89 88 =item * --recursive|-r 89 90 By default C<neb-ls> will only try to match the exact string provided to it. 91 With this option set all keys which match C<<pattern>> as a REGEX or substring 92 will be returned. 93 94 Optional 95 90 =cut 91 #=item * --recursive|-r 92 # 93 #By default C<neb-ls> will only try to match the exact string provided to it. 94 #With this option set all keys which match C<<pattern>> as a REGEX or substring 95 #will be returned. 96 # 97 #Optional 98 # 96 99 =item * --server|-s <URL> 97 100 … … 130 133 =head1 COPYRIGHT 131 134 132 Copyright (C) 2007-200 8Joshua Hoblitt. All rights reserved.135 Copyright (C) 2007-2009 Joshua Hoblitt. All rights reserved. 133 136 134 137 This program is free software; you can redistribute it and/or modify it under -
branches/neb_distrib_20081210/Nebulous/t/70_neb-ls.t
r23867 r23875 2 2 3 3 # Copyright (C) 2009 Joshua Hoblitt 4 5 use strict;6 use warnings;7 8 use lib qw( ./lib ./t );9 10 use Test::Cmd;11 use Test::More tests => 3;12 4 13 5 =head1 NAME … … 21 13 =cut 22 14 15 use strict; 16 use warnings; 17 18 use Apache::Test qw( -withtestmore ); 19 plan tests => 31; 20 21 use lib qw( ./lib ./t ); 22 23 use Test::Cmd; 24 use Nebulous::Client; 25 use Test::Nebulous; 26 27 my $hostport = Apache::Test->config->{ 'hostport' }; 28 my $neb_url = "http://$hostport/nebulous"; 29 30 23 31 my $cmd = 'bin/neb-ls'; 24 32 … … 26 34 chmod 0755, 'bin/neb-ls'; 27 35 28 29 36 my $test = Test::Cmd->new(prog => $cmd, workdir => ''); 30 37 isa_ok($test, 'Test::Cmd'); 31 38 39 # NEB_SERVER env var not set 40 Test::Nebulous->setup; 41 32 42 { 33 43 $test->run(args => ''); 34 44 missing_args(2, "Required options: --server"); 35 45 } 46 47 # NEB_SERVER set 48 Test::Nebulous->setup; 49 50 { 51 $ENV{NEB_SERVER} = $neb_url; 52 53 $test->run(args => ''); 54 is($? >> 8, 0, "exit code"); 55 } 56 57 Test::Nebulous->setup; 58 59 { 60 my $neb = Nebulous::Client->new( 61 proxy => $neb_url, 62 ); 63 $neb->create('foo'); 64 65 $test->run(args => ''); 66 67 is($? >> 8, 0, "exit code"); 68 like($test->stdout, qr/^foo$/, "stdout"); 69 like($test->stderr, qr/^$/, "stderr"); 70 } 71 72 Test::Nebulous->setup; 73 74 { 75 my $neb = Nebulous::Client->new( 76 proxy => $neb_url, 77 ); 78 $neb->create('foo'); 79 $neb->create('bar'); 80 81 $test->run(args => ''); 82 83 is($? >> 8, 0, "exit code"); 84 like($test->stdout, qr/^foo bar$/, "stdout"); 85 like($test->stderr, qr/^$/, "stderr"); 86 } 87 88 Test::Nebulous->setup; 89 90 { 91 my $neb = Nebulous::Client->new( 92 proxy => $neb_url, 93 ); 94 $neb->create('foo'); 95 $neb->create('bar'); 96 97 $test->run(args => '-l'); 98 99 is($? >> 8, 0, "exit code"); 100 like($test->stdout, qr/^foo\nbar\n$/, "stdout"); 101 like($test->stderr, qr/^$/, "stderr"); 102 } 103 104 Test::Nebulous->setup; 105 106 { 107 my $neb = Nebulous::Client->new( 108 proxy => $neb_url, 109 ); 110 $neb->create('foo'); 111 $neb->create('bar'); 112 113 $test->run(args => '-1'); 114 115 is($? >> 8, 0, "exit code"); 116 like($test->stdout, qr/^foo\nbar\n$/, "stdout"); 117 like($test->stderr, qr/^$/, "stderr"); 118 } 119 120 Test::Nebulous->setup; 121 122 { 123 my $neb = Nebulous::Client->new( 124 proxy => $neb_url, 125 ); 126 $neb->create('a/foo'); 127 128 $test->run(args => ''); 129 130 is($? >> 8, 0, "exit code"); 131 like($test->stdout, qr||, "stdout"); 132 like($test->stderr, qr/^$/, "stderr"); 133 } 134 135 Test::Nebulous->setup; 136 137 { 138 my $neb = Nebulous::Client->new( 139 proxy => $neb_url, 140 ); 141 $neb->create('a/foo'); 142 143 $test->run(args => 'a'); 144 145 is($? >> 8, 0, "exit code"); 146 like($test->stdout, qr|^a/foo$|, "stdout"); 147 like($test->stderr, qr/^$/, "stderr"); 148 } 149 150 Test::Nebulous->setup; 151 152 { 153 my $neb = Nebulous::Client->new( 154 proxy => $neb_url, 155 ); 156 $neb->create('a/foo'); 157 $neb->create('a/bar'); 158 159 $test->run(args => 'a'); 160 161 is($? >> 8, 0, "exit code"); 162 like($test->stdout, qr|^a/foo a/bar$|, "stdout"); 163 like($test->stderr, qr/^$/, "stderr"); 164 } 165 166 Test::Nebulous->setup; 167 168 { 169 my $neb = Nebulous::Client->new( 170 proxy => $neb_url, 171 ); 172 $neb->create('a/foo'); 173 $neb->create('foo'); 174 175 $test->run(args => 'a'); 176 177 is($? >> 8, 0, "exit code"); 178 like($test->stdout, qr|^a/foo$|, "stdout"); 179 like($test->stderr, qr/^$/, "stderr"); 180 } 181 182 Test::Nebulous->setup; 183 184 { 185 my $neb = Nebulous::Client->new( 186 proxy => $neb_url, 187 ); 188 $neb->create('a/foo'); 189 $neb->create('a/b/foo'); 190 191 $test->run(args => 'a'); 192 193 is($? >> 8, 0, "exit code"); 194 like($test->stdout, qr|^a/foo$|, "stdout"); 195 like($test->stderr, qr/^$/, "stderr"); 196 } 197 198 Test::Nebulous->cleanup; 36 199 37 200 sub missing_args
Note:
See TracChangeset
for help on using the changeset viewer.
