Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Various cleanups #3

Closed
wants to merge 20 commits into from

2 participants

Shlomi Fish R. Bernstein
Shlomi Fish

Hi Rocky,

Please pull the changes here that include various cleanups like "use English qw( -no_match_vars)" , strict and warnings on separate lines, a refactoring of t/Helper.pm etc.

Note that it doesn't contain the fix for the ReadLine loading / t/20*.t tests failing on my system which is on a different branch.

Regards,

-- Shlomi Fish

shlomif added some commits
Shlomi Fish shlomif Made Build.PL non-executable and sha-bang-less. 959bf27
Shlomi Fish shlomif Fix the Psh required ver to three-dots.
The Psh required version was warned when given 1.8.1 which is more
recent than "1.8" (or 1.8.0). So it was fixed here.
dbf98a7
Shlomi Fish shlomif Remove a warning with recent perls.
Deprecated using qw(...) directly as a list.
d877a95
Shlomi Fish shlomif Merge https://github.com/rocky/Perl-Devel-Trepan 9597cfe
Shlomi Fish shlomif Cleaned up the use statements in t/Helper.pm.
Removed duplicate ones, those that are both on the same line, etc.
bd52240
Shlomi Fish shlomif More loading cleanups.
Moved some use/require to the top.
b0d2ec3
Shlomi Fish shlomif Add -no_match_vars to use English.
This makes it faster.
ee83ecb
Shlomi Fish shlomif Add -no_match_vars to use English statements.
This is faster and more recommended (see perldoc English).
b64ddf6
Shlomi Fish shlomif Started cleaning up t/Helper.pm. 7956382
Shlomi Fish shlomif More Helper.pm cleanup.
Broke a line and removed an unneeded one.
a3fef16
Shlomi Fish shlomif Extract a closure. 3dc282c
Shlomi Fish shlomif More cleanups to Helper.pm. fdcff91
Shlomi Fish shlomif "file" in identifiers to "fn". aa3ee3b
Shlomi Fish shlomif Add a blurb for the is. 5afbebf
Shlomi Fish shlomif Add an explicit return. 9abc556
Shlomi Fish shlomif Reorganized the strict and warnings. 0e0c7bb
Shlomi Fish shlomif More strict and warnings cleanup. 4894b10
Shlomi Fish shlomif Separate lines for strict/warnings. 0b790fe
Shlomi Fish shlomif use statements cleanup. 449b0f8
Shlomi Fish shlomif Got rid of strict and warnings in the same line.
Cleaned up the loaded pragmas otherwise.
6f49cae
R. Bernstein
Owner

I really think this kind of change is really silly, if not bad. I string the lines across because basically each of the lines is boilerplate and I'd like to skip over all of it as much as possible. Computer displays tend to be limited in line length more than they are in column length.

Are Perl experts so rigid that one can't tolerate different styles?

rocky:

Well, this is the first time I've seen such putting several "use" statements on the same line. It has given me a "WTF?" moment, and I found it hard to read. Furthermore, your boilerplat is a little different every time, and I also moved package statements right at the top, which is important.

If you're so keen on keeping them out of the way, you can configure your text editor to fold these lines out of the way:

http://vim.wikia.com/wiki/Folding

(This is for Vim - other decent editors should have similar features.).

Owner

Is this so hard to read?

    $x = 1;  $y = 2; $z = 3; 

that you go around splitting this on several lines? And if it is

     $x = $y = $z = 0;

do you write that as:

     $x = 
     $y = 
     $z = 0;

? Or split this into 3 separate assignment statements?

Do you try to line up the = sign in:

    $first  = 1;
    $second  = 2;
    $third = 3;

?

because this is easier to read? I guess part of the point I am trying to make is that I doubt that just putting stuff on more lines in of itself makes things readable.

The thing about style is it is largely a matter of what one is used to. At one time I preferred indentation to be two spaces because again it is the minimum amount that gets the point across clearly. In some programming languages folks want 2 spaces, in some 4, and in some something different. After a while, I found I could just get used to any. So although I could get used to the multiple line thing, I think it silly and sad I can't write in the way I find the most logical and suits me the best.

When I say boilerplate, part of what I mean is that this stuff is uninteresting. Uninteresting to the point that if you totally skipped those lines and never read them, it wouldn't impact one iota the essentials of the program - the organization of classes, the algorithms, the fundamentals of what this program does and so on.

I know how to elide blocks of code, and I don't see a need to customize my Editor to elide this stuff. I want to write code in this way. The fact that you haven't seen it doesn't in of itself mean that this is a bad thing to do. Try it and live with it for a bit. If after trying it you can elucidate why it is so hard to read and why it is so important for you to be able read this, then let's discuss.

Also sad to me is that were spending this amount of time over things like this rather than:

  • adding watchpoints
  • adding out-of-process debugging
  • adding signal handlers like gdb's "handle" command
  • figuring out how to remove the globalness of the debugger to allow say profiing and debugging to be totally independent
  • finishing and removing some of the weirdnesses of tab ReadLine completion

These to me are the more important issues.

Owner

One other thing I had meant to mention. You said that the boilerplate is different and that puts you off. In some cases I have "strict" before "warnings" and some the other way around. But when you split into several lines, you kept this irregularity in some cases. But again, I think this is all irrelevant; if you are spending time looking at this stuff and making sure strict comes before warnings (or vice versa) then I think you are concerned with the parts of the program that are the least important.

By different boilerplate, I did not mean "strict" before "warnings" or vice-versa (which makes little difference). Instead, I meant stuff like "no warnings $something" which are also there sometimes (and are placed on the same line).

In any case, I'm likely to run into such style issues first when starting to work on your code, and it will likely give other Perl developers besides me some "WTF?" moments. I've introduced some more meaningful changes like the "use English qw( -no_match_vars ) ;" cleanup and the t/Helper.pm cleanup, and I'm still waiting for input on why there are so many "use lib '../../../'" statements in the code (which like I said might prove to be a security breach).

R. Bernstein
Owner

Reine Urban later noticed this and issued a separate pull request. So this has been encorporated now.

R. Bernstein
Owner

This change has been encorporated.

R. Bernstein
Owner

requires has been moved up. There is now a Helper package so the "use English" has to come after that.

R. Bernstein
Owner

Change incorporated. Thanks.

R. Bernstein
Owner

Applied with slight change.

R. Bernstein
Owner

Applied.

R. Bernstein
Owner

Applied. Thanks.

R. Bernstein
Owner

Applied.

R. Bernstein
Owner

Most of this seems dubious.

R. Bernstein
Owner

I don't like fn since it reminds me of function. So using filename is a compromise. With this caveat, applied.

R. Bernstein
Owner

I think I have all of the important changes merged in. Some things I disagree with as noted before. If there's anything you feel missing, let me know.

Thanks for the help.

R. Bernstein rocky closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 26, 2011
  1. Shlomi Fish
  2. Shlomi Fish

    Fix the Psh required ver to three-dots.

    shlomif authored
    The Psh required version was warned when given 1.8.1 which is more
    recent than "1.8" (or 1.8.0). So it was fixed here.
Commits on Oct 29, 2011
  1. Shlomi Fish

    Remove a warning with recent perls.

    shlomif authored
    Deprecated using qw(...) directly as a list.
  2. Shlomi Fish
Commits on Oct 30, 2011
  1. Shlomi Fish

    Cleaned up the use statements in t/Helper.pm.

    shlomif authored
    Removed duplicate ones, those that are both on the same line, etc.
  2. Shlomi Fish

    More loading cleanups.

    shlomif authored
    Moved some use/require to the top.
  3. Shlomi Fish

    Add -no_match_vars to use English.

    shlomif authored
    This makes it faster.
  4. Shlomi Fish

    Add -no_match_vars to use English statements.

    shlomif authored
    This is faster and more recommended (see perldoc English).
  5. Shlomi Fish
  6. Shlomi Fish

    More Helper.pm cleanup.

    shlomif authored
    Broke a line and removed an unneeded one.
  7. Shlomi Fish

    Extract a closure.

    shlomif authored
  8. Shlomi Fish

    More cleanups to Helper.pm.

    shlomif authored
  9. Shlomi Fish
  10. Shlomi Fish

    Add a blurb for the is.

    shlomif authored
  11. Shlomi Fish
  12. Shlomi Fish
  13. Shlomi Fish
  14. Shlomi Fish
Commits on Oct 31, 2011
  1. Shlomi Fish

    use statements cleanup.

    shlomif authored
  2. Shlomi Fish

    Got rid of strict and warnings in the same line.

    shlomif authored
    Cleaned up the loaded pragmas otherwise.
This page is out of date. Refresh to see the latest.
Showing with 303 additions and 120 deletions.
  1. +3 −1 bin/trepanpl
  2. +11 −3 lib/Devel/Trepan/BrkptMgr.pm
  3. +13 −8 lib/Devel/Trepan/CmdProcessor.pm
  4. +1 −1  lib/Devel/Trepan/CmdProcessor/Command/Action.pm
  5. +1 −1  lib/Devel/Trepan/CmdProcessor/Command/Break.pm
  6. +1 −1  lib/Devel/Trepan/CmdProcessor/Command/Condition.pm
  7. +1 −1  lib/Devel/Trepan/CmdProcessor/Command/Delete.pm
  8. +1 −1  lib/Devel/Trepan/CmdProcessor/Command/Display.pm
  9. +1 −1  lib/Devel/Trepan/CmdProcessor/Command/List.pm
  10. +1 −1  lib/Devel/Trepan/CmdProcessor/Command/Macro.pm
  11. +1 −1  lib/Devel/Trepan/CmdProcessor/Command/Restart.pm
  12. +1 −1  lib/Devel/Trepan/CmdProcessor/Command/Undisplay.pm
  13. +8 −3 lib/Devel/Trepan/CmdProcessor/Frame.pm
  14. +6 −2 lib/Devel/Trepan/CmdProcessor/Hook.pm
  15. +1 −1  lib/Devel/Trepan/CmdProcessor/Location.pm
  16. +6 −5 lib/Devel/Trepan/CmdProcessor/Running.pm
  17. +7 −4 lib/Devel/Trepan/CmdProcessor/Validate.pm
  18. +6 −2 lib/Devel/Trepan/Condition.pm
  19. +3 −3 lib/Devel/Trepan/DB.pm
  20. +1 −1  lib/Devel/Trepan/DB/Backtrace.pm
  21. +7 −2 lib/Devel/Trepan/DB/Breakpoint.pm
  22. +6 −3 lib/Devel/Trepan/DB/Display.pm
  23. +8 −3 lib/Devel/Trepan/DB/Eval.pm
  24. +10 −5 lib/Devel/Trepan/DB/LineCache.pm
  25. +1 −1  lib/Devel/Trepan/DB/Sub.pm
  26. +5 −3 lib/Devel/Trepan/IO.pm
  27. +4 −2 lib/Devel/Trepan/IO/Input.pm
  28. +4 −1 lib/Devel/Trepan/IO/StringArray.pm
  29. +6 −2 lib/Devel/Trepan/Interface/Script.pm
  30. +7 −2 lib/Devel/Trepan/Interface/User.pm
  31. +2 −1  lib/Devel/Trepan/Position.pm
  32. +6 −3 lib/Devel/Trepan/Util.pm
  33. +1 −1  t/10test-db-brkpt.t
  34. +6 −1 t/10test-intf-user.t
  35. +6 −2 t/10test-linecache.t
  36. +5 −1 t/10test-options.t
  37. +6 −1 t/10test-proc-hook.t
  38. +7 −1 t/10test-proc-load.t
  39. +6 −2 t/20test-autolist.t
  40. +4 −1 t/20test-break.t
  41. +4 −1 t/20test-display.t
  42. +6 −2 t/20test-eval.t
  43. +4 −1 t/20test-list1.t
  44. +4 −1 t/20test-list2.t
  45. +4 −1 t/20test-list3.t
  46. +4 −1 t/20test-next.t
  47. +4 −1 t/20test-seq1.t
  48. +6 −2 t/20test-step.t
  49. +4 −1 t/20test-trace.t
  50. +5 −2 t/20test-trepanpl-opts.t
  51. +77 −27 t/Helper.pm
4 bin/trepanpl
View
@@ -2,7 +2,9 @@
# Standalone routine to invoke a Perl program under the debugger.
# The usual boilerplate...
-use strict; use warnings; use English;
+use strict;
+use warnings;
+use English qw( -no_match_vars );
use File::Basename; use File::Spec;
14 lib/Devel/Trepan/BrkptMgr.pm
View
@@ -1,10 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
-use strict; use warnings; no warnings 'redefine';
-use English;
+
+package Devel::Trepan::BrkptMgr;
+
+use strict;
+use warnings;
+no warnings 'redefine';
+
+use English qw( -no_match_vars );
+
+# TODO : What is the meaning of this use lib? Can it be removed?
use lib '../..';
+
use Devel::Trepan::DB::Breakpoint;
-package Devel::Trepan::BrkptMgr;
sub new($$)
{
21 lib/Devel/Trepan/CmdProcessor.pm
View
@@ -1,13 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
+package Devel::Trepan::CmdProcessor;
+
+use strict;
+use warnings;
+no warnings 'redefine';
+
use feature ":5.10"; # Includes "state" feature.
-use Exporter;
use feature 'switch';
-use warnings; use strict;
+
+use English qw( -no_match_vars );
+
+use Exporter;
# Showing eval results can be done using either data dump package.
-require Data::Dumper; require Data::Dumper::Perltidy;
+require Data::Dumper;
+require Data::Dumper::Perltidy;
+# TODO : Shouldn't this use lib be removed?
use lib '../..';
require Devel::Trepan::BrkptMgr;
require Devel::Trepan::DB::Display;
@@ -23,12 +33,7 @@ require Devel::Trepan::CmdProcessor::Load unless
defined $Devel::Trepan::CmdProcessor::Load_seen;
require Devel::Trepan::CmdProcessor::Running;
require Devel::Trepan::CmdProcessor::Validate;
-use strict;
-use warnings;
-no warnings 'redefine';
-package Devel::Trepan::CmdProcessor;
-use English;
use Devel::Trepan::Util qw(hash_merge uniq_abbrev);
use vars qw(@EXPORT @ISA $eval_result);
2  lib/Devel/Trepan/CmdProcessor/Command/Action.pm
View
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
use lib '../../../..';
package Devel::Trepan::CmdProcessor::Command::Action;
-use English;
+use English qw( -no_match_vars );
use if !defined @ISA, Devel::Trepan::Condition ;
use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
2  lib/Devel/Trepan/CmdProcessor/Command/Break.pm
View
@@ -6,7 +6,7 @@ use lib '../../../..';
# require_relative '../../app/condition'
package Devel::Trepan::CmdProcessor::Command::Break;
-use English;
+use English qw( -no_match_vars );
use if !defined @ISA, Devel::Trepan::CmdProcessor::Command;
unless (defined(@ISA)) {
eval "use constant ALIASES => qw(b);";
2  lib/Devel/Trepan/CmdProcessor/Command/Condition.pm
View
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
use lib '../../../..';
package Devel::Trepan::CmdProcessor::Command::Condition;
-use English;
+use English qw( -no_match_vars );
use if !defined @ISA, Devel::Trepan::Condition ;
use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
2  lib/Devel/Trepan/CmdProcessor/Command/Delete.pm
View
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
use lib '../../../..';
package Devel::Trepan::CmdProcessor::Command::Delete;
-use English;
+use English qw( -no_match_vars );
use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
2  lib/Devel/Trepan/CmdProcessor/Command/Display.pm
View
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
use lib '../../../..';
package Devel::Trepan::CmdProcessor::Command::Display;
-use English;
+use English qw( -no_match_vars );
use if !defined @ISA, Devel::Trepan::DB::Display ;
use if !defined @ISA, Devel::Trepan::Condition ;
2  lib/Devel/Trepan/CmdProcessor/Command/List.pm
View
@@ -6,7 +6,7 @@ use lib '../../../..';
# require_relative '../../app/condition'
package Devel::Trepan::CmdProcessor::Command::List;
-use English;
+use English qw( -no_match_vars );
use Devel::Trepan::DB::LineCache;
use Devel::Trepan::CmdProcessor::Validate;
use if !defined @ISA, Devel::Trepan::CmdProcessor::Command;
2  lib/Devel/Trepan/CmdProcessor/Command/Macro.pm
View
@@ -5,7 +5,7 @@ use warnings; no warnings 'redefine';
use lib '../../../..';
package Devel::Trepan::CmdProcessor::Command::Macro;
-use English;
+use English qw( -no_match_vars );
use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
unless (defined(@ISA)) {
eval "use constant CATEGORY => 'support';";
2  lib/Devel/Trepan/CmdProcessor/Command/Restart.pm
View
@@ -5,7 +5,7 @@ use warnings; no warnings 'redefine';
use lib '../../../..';
package Devel::Trepan::CmdProcessor::Command::Restart;
-use English;
+use English qw( -no_match_vars );
use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
unless (defined(@ISA)) {
2  lib/Devel/Trepan/CmdProcessor/Command/Undisplay.pm
View
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
use lib '../../../..';
package Devel::Trepan::CmdProcessor::Command::Undisplay;
-use English;
+use English qw( -no_match_vars );
use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
11 lib/Devel/Trepan/CmdProcessor/Frame.pm
View
@@ -1,12 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
-use strict; use warnings;
+
+package Devel::Trepan::CmdProcessor;
+
+use strict;
+use warnings;
+
+# TODO : I don't think this use lib is a good idea.
use lib '../../..';
use Devel::Trepan::DB::Sub;
use Devel::Trepan::Complete;
-package Devel::Trepan::CmdProcessor;
-use English;
+use English qw( -no_match_vars );
sub adjust_frame($$$)
{
8 lib/Devel/Trepan/CmdProcessor/Hook.pm
View
@@ -1,6 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
-use strict; use warnings;
+package Devel::Trepan::CmdProcessor::Hook;
+
+use strict;
+use warnings;
+
+# TODO : I don't think this lib is a good idea.
use lib '../../..';
use Class::Struct;
@@ -13,7 +18,6 @@ struct CmdProcessorHook => {
};
-package Devel::Trepan::CmdProcessor::Hook;
# attr_accessor :list
sub new($;$)
2  lib/Devel/Trepan/CmdProcessor/Location.pm
View
@@ -7,7 +7,7 @@ use lib '../../..';
# require_relative '../app/default'
package Devel::Trepan::CmdProcessor;
-use English;
+use English qw( -no_match_vars );
use Cwd 'abs_path';
use File::Basename;
11 lib/Devel/Trepan/CmdProcessor/Running.pm
View
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
-use strict; use warnings;
+package Devel::Trepan::CmdProcessor;
+use strict;
+use warnings;
use feature 'switch';
+
+# TODO : I don't think this use lib is a good idea.
use lib '../../..';
use Devel::Trepan::Position;
-package Devel::Trepan::CmdProcessor;
-use English;
-
-
+use English qw( -no_match_vars );
# attr_accessor :stop_condition # String or nil. When not nil
# # this has to eval non-nil
11 lib/Devel/Trepan/CmdProcessor/Validate.pm
View
@@ -3,13 +3,16 @@
# Trepan command input validation routines. A String type is
# usually passed in as the argument to validation routines.
-use strict; use warnings;
-use Exporter;
+package Devel::Trepan::CmdProcessor;
+use strict;
+use warnings;
use feature 'switch';
-use lib '../../..';
-package Devel::Trepan::CmdProcessor;
+use Exporter;
+
+# TODO : I don't think this use lib is a good idea.
+use lib '../../..';
use Cwd 'abs_path';
use Devel::Trepan::DB::Breakpoint;
8 lib/Devel/Trepan/Condition.pm
View
@@ -1,8 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
-use strict; use warnings;
+
package Devel::Trepan::Condition;
-use English;
+
+use strict;
+use warnings;
+use English qw( -no_match_vars );
+
use vars qw(@EXPORT @ISA);
@EXPORT = qw( is_valid_condition );
@ISA = qw(Exporter);
6 lib/Devel/Trepan/DB.pm
View
@@ -9,7 +9,7 @@ use lib '../..';
package DB;
use feature 'switch';
use warnings; no warnings 'redefine';
-use English;
+use English qw( -no_match_vars );
use vars qw($usrctxt $running $caller
$event @ret $ret $return_value @return_value
@@ -87,11 +87,11 @@ BEGIN {
require threads;
require threads::shared;
import threads::shared qw(share);
- no strict; no warnings;
+ no strict;
+ no warnings;
$DBGR;
share(\$DBGR);
lock($DBGR);
- use strict; use warnings;
print "Thread support enabled\n";
} else {
*lock = sub(*) {};
2  lib/Devel/Trepan/DB/Backtrace.pm
View
@@ -1,6 +1,6 @@
package DB;
use warnings; no warnings 'redefine';
-use English;
+use English qw( -no_match_vars );
=head2 backtrace(skip[,count,scan_for_DB])
9 lib/Devel/Trepan/DB/Breakpoint.pm
View
@@ -39,9 +39,14 @@ sub icon_char($)
}
package DB;
+
use vars qw($brkpt $package $lineno $max_bp $max_action);
-use strict; use warnings; no warnings 'redefine';
-use English;
+
+use strict;
+use warnings;
+no warnings 'redefine';
+
+use English qw( -no_match_vars );
BEGIN {
$DB::brkpt = undef; # current breakpoint
9 lib/Devel/Trepan/DB/Display.pm
View
@@ -1,12 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
# FIXME: Could combine manager code from breakpoints and display
-use strict; use warnings; no warnings 'redefine';
-use English;
+
+use strict;
+use warnings;
+no warnings 'redefine';
+
+use English qw( -no_match_vars );
use lib '../..';
use Class::Struct;
-use strict;
struct DBDisplay => {
number => '$', # breakpoint/action number
11 lib/Devel/Trepan/DB/Eval.pm
View
@@ -1,11 +1,15 @@
# Eval part of Perl's Core DB.pm library and perl5db.pl with modification.
+# TODO : Shouldn't this use lib be removed?
use lib '../..';
package DB;
-use warnings; use strict;
-use English;
+
+use warnings;
+use strict;
use feature 'switch';
+
+use English qw( -no_match_vars );
use vars qw($eval_result @eval_result %eval_result
$eval_str $eval_opts $event $return_type );
@@ -30,7 +34,8 @@ sub eval {
$OUTPUT_FIELD_SEPARATOR,
$INPUT_RECORD_SEPARATOR,
$OUTPUT_RECORD_SEPARATOR, $WARNING) = @saved;
- no strict; no warnings;
+ no strict;
+ no warnings;
eval "$user_context $eval_str; &DB::save\n"; # '\n' for nice recursive debug
_warnall($@) if $@;
}
15 lib/Devel/Trepan/DB/LineCache.pm
View
@@ -39,11 +39,14 @@ use version; $VERSION = '0.1.0';
# A package to read and cache lines of a Perl program.
package DB::LineCache;
-use English;
-use strict; use warnings;
+
+use strict;
+use warnings;
no warnings 'once';
no warnings 'redefine';
+use English qw( -no_match_vars );
+
use Cwd 'abs_path';
use File::Basename;
use File::Spec;
@@ -562,12 +565,14 @@ sub update_cache($;$)
$lines_href->{plain} = $raw_lines;
if ($opts->{output} && defined($raw_lines)) {
# Some lines in $raw_lines may be undefined
- no strict; no warnings;
+ no strict;
+ no warnings;
local $WARNING=0;
my $highlight_lines = highlight_string(join('', @$raw_lines));
my @highlight_lines = split(/\n/, $highlight_lines);
$lines_href->{$opts->{output}} = \@highlight_lines;
- use strict; use warnings;
+ use strict;
+ use warnings;
}
my $entry = {
stat => $stat,
@@ -618,7 +623,7 @@ sub update_cache($;$)
# example usage
unless (caller) {
BEGIN {
- use English;
+ use English qw( -no_match_vars );
$PERLDB |= 0x400;
}; # Turn on saving @{_<$filename};
my $file=__FILE__;
2  lib/Devel/Trepan/DB/Sub.pm
View
@@ -4,7 +4,7 @@
package DB;
use warnings; no warnings 'redefine';
no warnings 'once';
-use English;
+use English qw( -no_match_vars );
use constant SINGLE_STEPPING_EVENT => 1;
use constant DEEP_RECURSION_EVENT => 4;
8 lib/Devel/Trepan/IO.pm
View
@@ -10,12 +10,14 @@
# Some ideas originiated as part of Matt Fleming's 2006 Google Summer of
# Code project.
-use strict; use warnings;
+package Devel::Trepan::IO::InputBase;
+
+use strict;
+use warnings;
+
use Exporter;
use lib '../..';
-package Devel::Trepan::IO::InputBase;
-
use Devel::Trepan::Util qw(hash_merge);
use vars qw(@EXPORT);
6 lib/Devel/Trepan/IO/Input.pm
View
@@ -5,12 +5,14 @@
# input or GNU Readline.
#
-use warnings; use strict;
+package Devel::Trepan::IO::Input;
+use warnings;
+use strict;
use Exporter;
use Term::ReadLine;
-package Devel::Trepan::IO::Input;
+# TODO : Shouldn't this use lib be removed?
use lib '../../..';
use Devel::Trepan::Util qw(hash_merge);
use Devel::Trepan::IO;
5 lib/Devel/Trepan/IO/StringArray.pm
View
@@ -4,8 +4,11 @@
# Simulate I/O using lists of strings.
package Devel::Trepan::IO::StringArrayInput;
-use warnings; use strict;
+use warnings;
+use strict;
+
+# TODO : Shouldn't this use lib be removed?
use lib '../../..';
use Devel::Trepan::IO;
8 lib/Devel/Trepan/Interface/Script.pm
View
@@ -2,12 +2,16 @@
# Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
# Module for reading debugger scripts
+package Devel::Trepan::Interface::Script;
+
+use strict;
+use warnings;
+no warnings 'redefine';
-use warnings; no warnings 'redefine'; use strict;
use Exporter;
use IO::File;
-package Devel::Trepan::Interface::Script;
+# TODO : Shouldn't this use lib be removed?
use lib '../../..';
use Devel::Trepan::Interface;
use Devel::Trepan::IO::Input;
9 lib/Devel/Trepan/Interface/User.pm
View
@@ -3,10 +3,15 @@
# Interface when communicating with the user.
-use warnings; no warnings 'once'; use strict;
+package Devel::Trepan::Interface::User;
+
+use strict;
+use warnings;
+no warnings 'once';
+
use Exporter;
-package Devel::Trepan::Interface::User;
+# TODO : Shouldn't this use lib be removed?
use lib '../../..';
use vars qw(@EXPORT @ISA $HAVE_READLINE);
@ISA = qw(Devel::Trepan::Interface Exporter);
3  lib/Devel/Trepan/Position.pm
View
@@ -1,4 +1,5 @@
-use strict; use warnings;
+use strict;
+use warnings;
use Class::Struct;
struct TrepanPosition => {pkg => '$', filename => '$', line => '$',
9 lib/Devel/Trepan/Util.pm
View
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
-use strict; use warnings;
-use feature 'switch';
package Devel::Trepan::Util;
+
+use strict;
+use warnings;
+use feature 'switch';
+
use vars qw(@EXPORT @ISA);
@EXPORT = qw( hash_merge safe_repr uniq_abbrev extract_expression
parse_eval_suffix);
@@ -125,7 +128,7 @@ unless (caller) {
print extract_expression($stmt), "\n";
}
- for my $cmd qw(eval eval$ eval% eval@ evaluate% none) {
+ for my $cmd (qw(eval eval$ eval% eval@ evaluate% none)) {
printf "parse_eval_suffix($cmd) => '%s'\n", parse_eval_suffix($cmd);
}
}
2  t/10test-db-brkpt.t
View
@@ -7,7 +7,7 @@ use Test::More 'no_plan';
note( "Testing Devel::Trepan::DB::Breakpoint" );
BEGIN {
- use English;
+ use English qw( -no_match_vars );
$PERLDB |= 0x400;
use_ok( 'Devel::Trepan::DB::Breakpoint' );
}
7 t/10test-intf-user.t
View
@@ -1,5 +1,10 @@
#!/usr/bin/env perl
-use strict; use warnings; no warnings 'redefine';
+
+use strict;
+use warnings;
+no warnings 'redefine';
+
+# TODO : What is the meaning of this use lib? Can it be removed?
use lib '../lib';
use vars qw($response);
8 t/10test-linecache.t
View
@@ -1,12 +1,16 @@
#!/usr/bin/env perl
-use strict; use warnings;
+
+use strict;
+use warnings;
+
+# TODO : What is the meaning of this use lib? Can it be removed?
use lib '../lib';
use Test::More 'no_plan';
note( "Testing Devel::Trepan::DB::LineCache" );
BEGIN {
- use English;
+ use English qw( -no_match_vars );
$PERLDB |= 0x400;
use_ok( 'Devel::Trepan::DB::LineCache' );
}
6 t/10test-options.t
View
@@ -1,5 +1,9 @@
#!/usr/bin/env perl
-use strict; use warnings; use English;
+
+use strict;
+use warnings;
+use English qw( -no_match_vars );
+
use lib '../lib';
use Test::More 'no_plan';
7 t/10test-proc-hook.t
View
@@ -1,5 +1,10 @@
#!/usr/bin/env perl
-use strict; use warnings; no warnings 'redefine';
+
+use strict;
+use warnings;
+no warnings 'redefine';
+
+# TODO : I don't think this use lib is a good idea.
use lib '../lib';
use vars qw(@args);
8 t/10test-proc-load.t
View
@@ -1,6 +1,12 @@
#!/usr/bin/env perl
-use strict; use warnings; no warnings 'redefine';
+
+use strict;
+use warnings;
+no warnings 'redefine';
+
+# TODO : I don't think this use lib is a good idea.
use lib '../lib';
+
use vars qw($response);
use Test::More 'no_plan';
8 t/20test-autolist.t
View
@@ -1,6 +1,10 @@
#!/usr/bin/env perl
-use warnings; use strict;
-use File::Basename; use File::Spec;
+
+use warnings;
+use strict;
+
+use File::Basename;
+use File::Spec;
use Test::More 'no_plan';
use lib dirname(__FILE__);
use Helper;
5 t/20test-break.t
View
@@ -1,5 +1,8 @@
#!/usr/bin/env perl
-use warnings; use strict;
+
+use warnings;
+use strict;
+
use File::Spec;
use File::Basename qw(dirname);
use lib dirname(__FILE__);
5 t/20test-display.t
View
@@ -1,5 +1,8 @@
#!/usr/bin/env perl
-use warnings; use strict;
+
+use warnings;
+use strict;
+
use File::Spec;
use File::Basename qw(dirname);
use lib dirname(__FILE__);
8 t/20test-eval.t
View
@@ -1,6 +1,10 @@
#!/usr/bin/env perl
-use warnings; use strict;
-use File::Basename; use File::Spec;
+
+use warnings;
+use strict;
+
+use File::Basename;
+use File::Spec;
use Test::More 'no_plan';
use lib dirname(__FILE__);
use Helper;
5 t/20test-list1.t
View
@@ -1,5 +1,8 @@
#!/usr/bin/env perl
-use warnings; use strict;
+
+use warnings;
+use strict;
+
use File::Basename; use File::Spec;
use Test::More 'no_plan';
use lib dirname(__FILE__);
5 t/20test-list2.t
View
@@ -1,5 +1,8 @@
#!/usr/bin/env perl
-use warnings; use strict;
+
+use warnings;
+use strict;
+
use File::Basename; use File::Spec;
use Test::More 'no_plan';
use lib dirname(__FILE__);
5 t/20test-list3.t
View
@@ -1,5 +1,8 @@
#!/usr/bin/env perl
-use warnings; use strict;
+
+use warnings;
+use strict;
+
use File::Basename; use File::Spec;
use Test::More 'no_plan';
use lib dirname(__FILE__);
5 t/20test-next.t
View
@@ -1,5 +1,8 @@
#!/usr/bin/env perl
-use warnings; use strict;
+
+use warnings;
+use strict;
+
use File::Basename; use File::Spec;
use Test::More 'no_plan';
use lib dirname(__FILE__);
5 t/20test-seq1.t
View
@@ -1,5 +1,8 @@
#!/usr/bin/env perl
-use warnings; use strict;
+
+use warnings;
+use strict;
+
use File::Spec;
use File::Basename qw(dirname);
use lib dirname(__FILE__);
8 t/20test-step.t
View
@@ -1,6 +1,10 @@
#!/usr/bin/env perl
-use warnings; use strict;
-use File::Basename; use File::Spec;
+
+use warnings;
+use strict;
+
+use File::Basename;
+use File::Spec;
use Test::More 'no_plan';
use lib dirname(__FILE__);
use Helper;
5 t/20test-trace.t
View
@@ -1,5 +1,8 @@
#!/usr/bin/env perl
-use warnings; use strict;
+
+use warnings;
+use strict;
+
use File::Spec;
use File::Basename qw(dirname);
use lib dirname(__FILE__);
7 t/20test-trepanpl-opts.t
View
@@ -1,7 +1,10 @@
#!/usr/bin/env perl
+
use strict;
-use warnings; use strict;
-use English;
+use warnings;
+
+use English qw( -no_match_vars );
+
use File::Basename;
use File::Spec;
my $trepanpl = File::Spec->catfile(dirname(__FILE__), qw(.. bin trepanpl));
104 t/Helper.pm
View
@@ -1,45 +1,95 @@
-use warnings; use strict;
+package Helper;
+
+use warnings;
+use strict;
+
use String::Diff;
+use File::Basename qw(dirname);
use File::Spec;
-use File::Basename;
+
+use English qw( -no_match_vars ) ;
+
+require Test::More;
+
my $trepanpl = File::Spec->catfile(dirname(__FILE__), qw(.. bin trepanpl));
my $debug = $^W;
-package Helper;
-use File::Basename qw(dirname); use File::Spec;
-use English;
-require Test::More;
+sub _slurp
+{
+ my ($filename) = @_;
+
+ open my $in, '<', $filename
+ or die "Cannot open '$filename' for slurping - $!";
+
+ local $/;
+ my $contents = <$in>;
+
+ close($in);
+
+ return $contents;
+}
+
sub run_debugger($$;$$)
{
- my ($test_invoke, $cmdfile, $rightfile, $opts) = @_;
+ my ($test_invoke, $cmd_fn, $right_fn, $opts) = @_;
+
$opts //= {};
- Test::More::note( "running $test_invoke with $cmdfile" );
+
+ Test::More::note( "running $test_invoke with $cmd_fn" );
+
my $run_opts = $opts->{run_opts} || "--basename --nx --no-highlight";
- my $full_cmdfile = File::Spec->catfile(dirname(__FILE__), 'data', $cmdfile);
- $run_opts .= " --command $full_cmdfile" unless ($opts->{no_cmdfile});
- ($rightfile = $full_cmdfile) =~ s/\.cmd/.right/ unless defined($rightfile);
+ my $full_cmd_fn = File::Spec->catfile(dirname(__FILE__), 'data', $cmd_fn);
+ my $ext_filename = sub {
+ my ($ext) = @_;
+
+ my $new_fn = $full_cmd_fn;
+
+ $new_fn =~ s/\.cmd\z/.$ext/;
+
+ return $new_fn;
+ };
+
+ $run_opts .= " --command $full_cmd_fn" unless ($opts->{no_cmdfile});
+
+ if (!defined($right_fn))
+ {
+ $right_fn = $ext_filename->('right');
+ }
+
my $cmd = "$EXECUTABLE_NAME $trepanpl $run_opts $test_invoke";
print $cmd, "\n" if $debug;
+
my $output = `$cmd`;
- print $output if $debug;
my $rc = $? >> 8;
- Test::More::is($rc, 0);
- open(RIGHT_FH, "<$rightfile");
- undef $INPUT_RECORD_SEPARATOR;
- my $right_string = <RIGHT_FH>;
- ($output, $right_string) = $opts->{filter}->($output, $right_string) if $opts->{filter};
- my $gotfile;
- ($gotfile = $full_cmdfile) =~ s/\.cmd/.got/;
- if ($right_string eq $output) {
- Test::More::ok(1);
- unlink $gotfile;
+
+ print $output if $debug;
+ Test::More::is($rc, 0, 'Debugger command was executed successfully');
+
+ my $right_string = _slurp($right_fn);
+
+ if ($opts->{filter})
+ {
+ ($output, $right_string) = $opts->{filter}->($output, $right_string);
+ }
+
+ my $got_fn = $ext_filename->('got');
+
+ # TODO : Perhaps make sure we optionally use eq_or_diff from
+ # Test::Differences here.
+ if (Test::More::is($right_string, $output, 'Output comparison')) {
+ unlink $got_fn;
} else {
- my $diff = String::Diff::diff_merge($output, $right_string);
- open(GOT_FH, ">$gotfile");
- print GOT_FH $output;
- print $diff;
- Test::More::ok(0, "Output comparison fails");
+ my $diff = String::Diff::diff_merge($output, $right_string);
+
+ open (my $got_fh, '>', $got_fn)
+ or die "Cannot open '$got_fn' for writing - $!";
+ print {$got_fh} $output;
+ close($got_fh);
+
+ Test::More::diag($diff);
}
+
+ return;
}
1;
Something went wrong with that request. Please try again.