[Rt-commit] rt branch, 4.2/test-crypt-race-condition, created. rt-4.2.3-30-g4b6ce71
Alex Vandiver
alexmv at bestpractical.com
Thu Mar 13 11:36:04 EDT 2014
The branch, 4.2/test-crypt-race-condition has been created
at 4b6ce71cdcfbfc65ffabd7f5eba2d83eda72241e (commit)
- Log -----------------------------------------------------------------
commit 4b6ce71cdcfbfc65ffabd7f5eba2d83eda72241e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Mar 12 23:15:59 2014 -0400
Avoid a race condition in crypt testing
Test::Warn fails us here because it only captures the first line of a
multi-line warning. Opening up the debug log and searching over it
leads to race conditions, as the error we're looking for may not have
been flushed to disk by the time we read it.
Instead, use a simple __WARN__ handler to look for the desired warning.
diff --git a/t/crypt/no-signer-address.t b/t/crypt/no-signer-address.t
index 8f4a0b1..31ba5eb 100644
--- a/t/crypt/no-signer-address.t
+++ b/t/crypt/no-signer-address.t
@@ -2,7 +2,7 @@ use strict;
use warnings;
use RT::Test::GnuPG
- tests => 6,
+ tests => undef,
gnupg_options => {
passphrase => 'rt-test',
'trust-model' => 'always',
@@ -19,18 +19,24 @@ my $queue;
ok !$queue->CorrespondAddress, 'address not set';
}
-use Test::Warn;
-warnings_like {
- my $ticket = RT::Ticket->new( RT->SystemUser );
- my ($status, undef, $msg) = $ticket->Create(
- Queue => $queue->id,
- Subject => 'test',
- Requestor => 'root at localhost',
- );
- ok $status, "created ticket" or diag "error: $msg";
+# We don't use Test::Warn here, because it apparently only captures up
+# to the first newline -- and the meat of this message is on the fourth
+# line.
+my @warnings;
+local $SIG{__WARN__} = sub {
+ push @warnings, "@_";
+};
+
+my $ticket = RT::Ticket->new( RT->SystemUser );
+my ($status, undef, $msg) = $ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test',
+ Requestor => 'root at localhost',
+);
+ok( $status, "created ticket" ) or diag "error: $msg";
- my $log = RT::Test->file_content([RT::Test->temp_directory, 'rt.debug.log']);
- like $log, qr{secret key not available}, 'error in the log';
- unlike $log, qr{Scrip .*? died}m, "scrip didn't die";
-} [qr{gpg: keyring .*? created}];
+is( scalar @warnings, 1, "Got a warning" );
+like( $warnings[0], qr{signing failed: secret key not available},
+ "Found warning of no secret key");
+done_testing;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list