| 1 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| 2 | # contributor license agreements. See the NOTICE file distributed with | ||
| 3 | # this work for additional information regarding copyright ownership. | ||
| 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| 5 | # (the "License"); you may not use this file except in compliance with | ||
| 6 | # the License. You may obtain a copy of the License at | ||
| 7 | # | ||
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | # | ||
| 10 | # Unless required by applicable law or agreed to in writing, software | ||
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | # See the License for the specific language governing permissions and | ||
| 14 | # limitations under the License. | ||
| 15 | # | ||
| 16 | #no 'package Apache::TestPerlDB.pm' here, else we change perldb's package | ||
| 17 | use strict; | ||
| 18 | |||
| 19 | sub Apache::TestPerlDB::lwpd { | ||
| 20 | print Apache::TestRequest::lwp_debug(shift || 1); | ||
| 21 | } | ||
| 22 | |||
| 23 | sub Apache::TestPerlDB::bok { | ||
| 24 | my $n = shift || 1; | ||
| 25 | print "breakpoint set at test $n\n"; | ||
| 26 | DB::cmd_b_sub('ok', "\$Test::ntest == $n"); | ||
| 27 | } | ||
| 28 | |||
| 29 | my %help = ( | ||
| 30 | lwpd => 'Set the LWP debug level for Apache::TestRequest', | ||
| 31 | bok => 'Set breakpoint at test n', | ||
| 32 | ); | ||
| 33 | |||
| 34 | my $setup_db_aliases = sub { | ||
| 35 | my $package = 'Apache::TestPerlDB'; | ||
| 36 | my @cmds; | ||
| 37 | no strict 'refs'; | ||
| 38 | |||
| 39 | while (my($name, $val) = each %{"$package\::"}) { | ||
| 40 | next unless defined &$val; | ||
| 41 | *{"main::$name"} = \&{$val}; | ||
| 42 | push @cmds, $name; | ||
| 43 | } | ||
| 44 | |||
| 45 | print "$package added perldb commands:\n", | ||
| 46 | map { " $_ - $help{$_}\n" } @cmds; | ||
| 47 | |||
| 48 | }; | ||
| 49 | |||
| 50 | $setup_db_aliases->(); | ||
| 51 | |||
| 52 | 1; | ||
| 53 | __END__ |