| 1 |
NAME |
| 2 |
Test::Filename - Portable filename comparison |
| 3 |
|
| 4 |
VERSION |
| 5 |
version 0.03 |
| 6 |
|
| 7 |
SYNOPSIS |
| 8 |
use Test::Filename tests => 2; |
| 9 |
|
| 10 |
filename_is ( "some\path", "some/path", "should pass" ); |
| 11 |
filename_isnt( "some\path", "some/path", "should fail" ); |
| 12 |
|
| 13 |
DESCRIPTION |
| 14 |
Many cross-platform test failures -- particularly on Win32 -- are due to |
| 15 |
hard-coded file paths being used in comparison tests. |
| 16 |
|
| 17 |
my $file = get_file(); # returns "foo\bar.t"; |
| 18 |
is( $file, "foo/bar.t" ); # fails on Win32 |
| 19 |
|
| 20 |
This simple module provides some handy functions to convert all those |
| 21 |
path separators automatically so filename tests will just DWIM. |
| 22 |
|
| 23 |
The alternative is to write your own utility subroutine and use it |
| 24 |
everywhere or just keep on littering your test code with calls to |
| 25 |
File::Spec -- yuck! |
| 26 |
|
| 27 |
is( $file, File::Spec->canonpath("some/path"), "should pass" ); |
| 28 |
|
| 29 |
Since this module is so simple, you might not think it worth including |
| 30 |
as a dependency. After all, it's not *that* hard to always remember to |
| 31 |
use File::Spec, Path::Tiny or some other file utility, right? But odds |
| 32 |
are that, at some point, you'll be so busy writing tests that you'll |
| 33 |
forget and hard-code a path in your haste to show what a clever |
| 34 |
programmer you are. |
| 35 |
|
| 36 |
So just use this module and stop worrying about it. You'll be happier |
| 37 |
and so will anyone trying to install your modules on Win32. |
| 38 |
|
| 39 |
USAGE |
| 40 |
Just like Test::More, you have the option of providing a test plan as |
| 41 |
arguments when you use this module. The following functions are imported |
| 42 |
by default. |
| 43 |
|
| 44 |
filename_is |
| 45 |
=head2 filename_isnt |
| 46 |
filename_is ( $got, $expected, $label ); |
| 47 |
filename_isnt( $got, $expected, $label ); |
| 48 |
|
| 49 |
These functions work just like "is()" and "isnt()" from Test::More, but |
| 50 |
the first two argument will be cleaned up and normalized to Unix-style |
| 51 |
paths using Path::Tiny. This means that ".\foo.txt" will get normalized |
| 52 |
to "foo.txt" and so on. |
| 53 |
|
| 54 |
SEE ALSO |
| 55 |
* perlport |
| 56 |
|
| 57 |
* File::Spec |
| 58 |
|
| 59 |
* Path::Tiny |
| 60 |
|
| 61 |
* Test::More |
| 62 |
|
| 63 |
SUPPORT |
| 64 |
Bugs / Feature Requests |
| 65 |
Please report any bugs or feature requests through the issue tracker at |
| 66 |
<https://github.com/dagolden/test-filename/issues>. You will be notified |
| 67 |
automatically of any progress on your issue. |
| 68 |
|
| 69 |
Source Code |
| 70 |
This is open source software. The code repository is available for |
| 71 |
public review and contribution under the terms of the license. |
| 72 |
|
| 73 |
<https://github.com/dagolden/test-filename> |
| 74 |
|
| 75 |
git clone git://github.com/dagolden/test-filename.git |
| 76 |
|
| 77 |
AUTHOR |
| 78 |
David A. Golden <[email protected]> |
| 79 |
|
| 80 |
COPYRIGHT AND LICENSE |
| 81 |
This software is Copyright (c) 2007 by David A. Golden. |
| 82 |
|
| 83 |
This is free software, licensed under: |
| 84 |
|
| 85 |
The Apache License, Version 2.0, January 2004 |
| 86 |
|