Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Running an editor in a test with "prove" command

by haukex (Bishop)
on May 31, 2020 at 16:12 UTC ( #11117536=note: print w/replies, xml ) Need Help??

in reply to Running an editor in a test with "prove" command

Tests that require an interactive TTY don't mix well with non-interactive test environments; consider for example what would happen if this test were to be run on CPAN Testers. An alternative to the below is to use something like prompt from ExtUtils::MakeMaker, which can be forced to use defaults if run non-interactively.

use warnings; use strict; use Test::More; use Proc::InvokeEditor; use IO::Interactive qw/is_interactive/; SKIP: { skip "running non-interactively", 1 unless is_interactive; my $edited_text = Proc::InvokeEditor->edit('edit me'); is $edited_text, "edit you\n", 'can edit text'; } done_testing;

Replies are listed 'Best First'.
Re^2: Running an editor in a test with "prove" command
by nysus (Parson) on May 31, 2020 at 16:23 UTC

    Nice. I was scratching my head wondering if there was a way I could determine if I was running the script as a test or not. IO::Interactive is exactly what I needed. Thanks!

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      I think -t STDOUT would also do it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11117536]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-05-06 01:47 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (69 votes). Check out past polls.