[Rt-commit] rt branch, 4.0/test-warnings, updated. rt-4.0.0-189-gd651af2
Alex Vandiver
alexmv at bestpractical.com
Tue May 10 14:07:40 EDT 2011
The branch, 4.0/test-warnings has been updated
via d651af28aa82f97c928beda2d6b3b7fee7b57b92 (commit)
via ce3f25314db03579eda3ebaf6ef0096b70340762 (commit)
from fa7b773f536047852540c7d608adcda04c6d895a (commit)
Summary of changes:
t/mail/crypt-gnupg.t | 16 ++++++++--------
t/mail/gnupg-reverification.t | 2 ++
2 files changed, 10 insertions(+), 8 deletions(-)
- Log -----------------------------------------------------------------
commit ce3f25314db03579eda3ebaf6ef0096b70340762
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue May 10 13:18:31 2011 -0400
We can still use Test::Warn for this case, albeit with a different check
Test::Warn only returns the first line of the warn, unfortunately. This
particular case is more verbose than "bad passphrase" -- it notices that
it has +no_ passphrase given, and throws an additional warning that it
can't ask for the passphrase from the user, as it is being run
non-interactively. While we'd ideally also test for "bad passphrase",
simply testing for "can't query passphrase in batch mode" is not wrong.
diff --git a/t/mail/crypt-gnupg.t b/t/mail/crypt-gnupg.t
index fd75928..c0a8756 100644
--- a/t/mail/crypt-gnupg.t
+++ b/t/mail/crypt-gnupg.t
@@ -54,17 +54,19 @@ diag 'only signing. correct passphrase';
diag 'only signing. missing passphrase';
{
- my $warnings;
- local $SIG{__WARN__} = sub {
- $warnings .= "@_";
- };
-
my $entity = MIME::Entity->build(
From => 'rt at example.com',
Subject => 'test',
Data => ['test'],
);
- my %res = RT::Crypt::GnuPG::SignEncrypt( Entity => $entity, Encrypt => 0, Passphrase => '' );
+ my %res;
+ warning_like {
+ %res = RT::Crypt::GnuPG::SignEncrypt(
+ Entity => $entity,
+ Encrypt => 0,
+ Passphrase => ''
+ );
+ } qr/can't query passphrase in batch mode/;
ok( $res{'exit_code'}, "couldn't sign without passphrase");
ok( $res{'error'} || $res{'logger'}, "error is here" );
@@ -72,8 +74,6 @@ diag 'only signing. missing passphrase';
is( scalar @status, 1, 'one record');
is( $status[0]->{'Operation'}, 'PassphraseCheck', 'operation is correct');
is( $status[0]->{'Status'}, 'MISSING', 'missing passphrase');
-
- like($warnings, qr/bad passphrase/);
}
diag 'only signing. wrong passphrase';
commit d651af28aa82f97c928beda2d6b3b7fee7b57b92
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue May 10 13:43:27 2011 -0400
Note why we still write our own __WARN__ handler in this case
diff --git a/t/mail/gnupg-reverification.t b/t/mail/gnupg-reverification.t
index 03c00e3..96a37a0 100644
--- a/t/mail/gnupg-reverification.t
+++ b/t/mail/gnupg-reverification.t
@@ -35,6 +35,8 @@ foreach my $file ( @files ) {
my ($status, $id);
{
+ # We don't use Test::Warn here because we get multi-line
+ # warnings, which Test::Warn only records the first line of.
local $SIG{__WARN__} = sub {
$warnings .= "@_";
};
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list