Skip to content

Commit

Permalink
finally fix RT #84096
Browse files Browse the repository at this point in the history
  • Loading branch information
dakkar committed Mar 27, 2013
1 parent 30c9212 commit 047bc11
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@
{{$NEXT}}
- hopefully fix nonetwork.t under Win32
- fix nonetwork.t under Win32, see RT #84096

1.06 2013-03-01 15:49:54 Europe/London
- better work around exceptions in File::ChangeNotify
Expand Down
2 changes: 2 additions & 0 deletions t/lib/BrokerTestApp.pm
Expand Up @@ -9,6 +9,8 @@ my $app = sub {
my $data = JSON::XS::decode_json($body);
my $response = {};

exit 0 if $data->{exit_now};

$response->{path_info} = $env->{PATH_INFO};

if ($data->{reply_to}) {
Expand Down
2 changes: 2 additions & 0 deletions t/lib/RunTestApp.pm
Expand Up @@ -69,6 +69,7 @@ sub _build_child {
# values across the fork
my $pid = fork();
if ($pid == 0) {
$SIG{TERM}=sub{exit 0};
my $runner = Plack::Handler::Stomp->new({
servers => [ { hostname => 'localhost', port => 61613 } ],
subscriptions => [
Expand Down Expand Up @@ -102,6 +103,7 @@ sub _build_child {

sub DEMOLISH {
my ($self) = @_;

return unless $self->has_child;

my $child = $self->child;
Expand Down
6 changes: 5 additions & 1 deletion t/lib/RunTestAppNoNet.pm
Expand Up @@ -40,7 +40,11 @@ sub _build_child {
my $trace_dir = $self->trace_dir; # make sure we don't get two
# values across the fork
my $pid = fork();
if ($pid == 0) {
if (!defined $pid) {
die "Can't start server: $!";
}
elsif ($pid == 0) {
$SIG{TERM}=sub{exit 0};
my $runner = Plack::Handler::Stomp::NoNetwork->new({
subscriptions => [
{ destination => '/queue/plack-handler-stomp-test' },
Expand Down
10 changes: 9 additions & 1 deletion t/nonetwork.t
Expand Up @@ -138,8 +138,16 @@ test 'talk to the app' => sub {
);

};
};

$prod->send(
'/topic/plack-handler-stomp-test',
{
type => 'test_foo',
},
JSON::XS::encode_json({exit_now=>1}),
);
};

run_me;

done_testing;
15 changes: 14 additions & 1 deletion t/real_broker.t
Expand Up @@ -104,8 +104,21 @@ test 'talk to the app' => sub {
@case_comparers,
],
'tracing works'
)
);
};

# we send the "exit now" command on the topic, so we're sure we
# won't find it on the next run
#
# BrokerTestApp exits without ACK-ing the message, so it would
# remain on the queue, ready to stop the application the next time
# we try to run the test
$conn->send( {
destination => '/topic/plack-handler-stomp-test',
body => JSON::XS::encode_json({exit_now=>1}),
JMSType => 'test_foo',
} );

};

run_me;
Expand Down

0 comments on commit 047bc11

Please sign in to comment.