Test::Exec(3pm)

Test::Exec3pm

Test that some code calls exec without terminating testing

Usage

 use Test::More;
 use Test::Exec;
 
 is_deeply exec_arrayref { exec 'foo', 'bar', 'baz' }, [qw( foo bar baz )], 'found exec!';
 is exec_arrayref { }, undef, 'did not exec!';
 
 done_testing;

Version

version 0.07

Overview

Test::Exec provides the most simple possible tools for testing code that might call "exec", which would otherwise end your test by calling another program. This code should detect and capture "exec" calls, even if they are inside an "eval".

The concept was implementation was based on Test::Exit, but applied to "exec" instead of "exit".

Functions

exec_arrayref

 exec_arrayref { ... }

runs the given code. If the code calls "exec", then this function will return an arrayref with its arguments. If the code never calls "exec", it will return "undef".

never_exec_ok

 never_exec_ok { ... }

Runs the given code. If the code calls "exec", then the test will fail (but exec will be intercepted and not performed).

Caveats

This module installs its own version of "exec" in "CORE::GLOBAL::exec", and may interact badly with any other code that is also trying to do such things.

Author

Author: Graham Ollis <[email protected]>

Contributors:

Jeremy Mates (THRIG)

From perl-test2-tools-process 0.07-7 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.