in reply to Running specific test files with sudo
Why rerun your test through prove instead of simply rerunning your test program? That way, whatever harness the user uses will just receive the output from your restarted program...
Also, there is a skip command in Test::More, which is a bit cumbersome to use but outputs a nicer message than a passing test:
use Test::More; plan tests => 10; if( $> != 0 ) { # re-exec as root: # hope we didn't have -Ilib or -Mblib on the invocation line exec 'sudo', $0, @ARGV; # Also see Devel::PL_origargv }; if( $> != 0 ) { SKIP: { skip "Must be root", 10; }; exit; }; ... run tests as root ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Running specific test files with sudo
by stevieb (Canon) on Mar 19, 2017 at 17:07 UTC |