[Rt-commit] rt branch, 4.4/test-fail-content-dump, created. rt-4.4.0rc2-16-gd39d56b
Shawn Moore
shawn at bestpractical.com
Fri Dec 4 11:35:41 EST 2015
The branch, 4.4/test-fail-content-dump has been created
at d39d56baf4e931c43c06f4932fae406bb5c816e5 (commit)
- Log -----------------------------------------------------------------
commit d39d56baf4e931c43c06f4932fae406bb5c816e5
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Nov 17 16:45:22 2015 +0000
On content_* or text_* fails, dump content in tmp
Fixes: I#31408
diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index 46cdc05..5c2d441 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -432,6 +432,38 @@ sub dom {
return Mojo::DOM->new( $self->content );
}
+# override content_* and text_* methods in Test::Mech to dump the content
+# on failure, to speed investigation
+for my $method_name (qw/
+ content_is content_contains content_lacks content_like content_unlike
+ text_contains text_lacks text_like text_unlike
+/) {
+ my $super_method = __PACKAGE__->SUPER::can($method_name);
+ my $implementation = sub {
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ my $self = shift;
+ my $ok = $self->$super_method(@_);
+ if (!$ok) {
+ my $dir = RT::Test->temp_directory;
+ my ($name) = $self->uri =~ m{/([^/]+)$};
+ $name ||= 'index.html';
+
+ my $file = $dir . '/' . RT::Test->builder->current_test . '-' . $name;
+
+ open my $handle, '>', $file or die $!;
+ print $handle $self->content or die $!;
+ close $handle or die $!;
+
+ Test::More::diag("Dumped failing test page content to $file");
+ }
+ return $ok;
+ };
+
+ no strict 'refs';
+ *{$method_name} = $implementation;
+}
+
sub DESTROY {
my $self = shift;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list