Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-File-Contents CPAN distribution.

Report information
The Basics
Id: 30937
Status: new
Priority: 0/
Queue: Test-File-Contents

People
Owner: Nobody in particular
Requestors: zardoz [...] infoserve.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Test::File::Contents suggestion
Date: 23 Nov 2007 15:38:18 +0000
To: bug-test-file-contents [...] rt.cpan.org
From: zardoz <zardoz [...] infoserve.net>
Hi, Nice file testing module. I've been using a hand rolled function filtered_compare_files() for years. You might like to add something like this to your module. Basically it does an exact file comparison but allows you to pass a filtering function so that things like dates and such can be replaced with YYYYMMDD for example so that the comparisons ignore the date the test plan was run. Perhaps: file_contents_identical( $file1, $file2, $rcFilterSub, $test_description); Example usage file_contents_identical( 'got.txt', 'expected.txt', sub {}, 'compare files ignoring dates');
Subject: Test::File::Contents suggestion (COMPLETE)
Date: 23 Nov 2007 15:44:07 +0000
To: bug-test-file-contents [...] rt.cpan.org
From: zardoz <zardoz [...] infoserve.net>
Hi, (This email complete, hit the send key by mistake previously) Nice file testing module. I've been using a hand rolled function filtered_compare_files() for years. You might like to add something like this to your module. Basically it does an exact file comparison but allows you to pass a filtering function so that things like dates and such can be replaced with YYYYMMDD for example so that the comparisons ignore the date the test plan was run. Perhaps: file_contents_filtered( $file1, $file2, $rcFilterSub, $test_description); Example usage file_contents_filtered( 'got.txt', 'expected.txt', sub { my ($contents) = @ARG; $contents =~ s{\d\d\d\d - \d\d - \d\d}{YYYY-MM-DD}xmsg; $contents =~ s{\w+ \@ \w+}{USER\@HOST}xmsg; return $contents; }, 'compare files ignoring dates and hostnames' ); The function loads the contents of each file into memory, uses the code ref passed in to transform each then does an 'eq' comparison for identicalness. Cheers, Zardoz