in reply to Testing a .pl script

Maybe define/override the function should_stop so it always returns false?

Replies are listed 'Best First'.
Re^2: Test automation
by perl_help26 (Beadle) on Jul 01, 2015 at 14:35 UTC
    I like that. So I should put something like this in my test.pl?
    local *should_stop = sub { return 1; }; require ('wrong_settings_detection.pl');
    Also,suppose i change my code to:
    package X; sub func1 {....} sub func2 {....} until (should_stop()){...}
    Can i export the package into my test.pl ???

      You can still override the things:

      package X; use strict; use Exporter 'import'; use vars '@EXPORT_OK'; @EXPORT_OK = qw(func1 func2 ); sub func1 { ... }; sub func2 { ... }; sub should_stop { ... }; until (should_stop()){...}

      And then in your test file:

      local *X::should_stop = sub { return 1 }; require X; X->import('func1');