| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | use UR; | ||
| 4 | use Command; | ||
| 5 | |||
| 6 | package Command::Test::Echo; | ||
| 7 | |||
| 8 | class Command::Test::Echo { | ||
| 9 | is => 'Command', | ||
| 10 | has => [ | ||
| 11 | in => { is => 'Text' }, | ||
| 12 | out => { is => 'Text', is_output => 1, is_optional => 1 }, | ||
| 13 | ], | ||
| 14 | doc => 'echo the input back, and die or fail if those words appear in the input', | ||
| 15 | }; | ||
| 16 | |||
| 17 | sub execute { | ||
| 18 | my $self = shift; | ||
| 19 | print "job " . $self->id . " started at " . $self->__context__->now . "\n"; | ||
| 20 | print STDERR "test error!\n"; | ||
| 21 | for (1..10) { | ||
| 22 | print $self->in,"\n"; | ||
| 23 | sleep 1; | ||
| 24 | } | ||
| 25 | if ($self->in =~ /fail/) { | ||
| 26 | return; | ||
| 27 | } | ||
| 28 | elsif ($self->in =~ /die/) { | ||
| 29 | die $self->in; | ||
| 30 | } | ||
| 31 | $self->out($self->in); | ||
| 32 | return 1; | ||
| 33 | } | ||
| 34 | |||
| 35 | 1; | ||
| 36 |