NAME
Test::Smoke::Patcher - OO interface to help patching the source-tree
SYNOPSIS
use
Test::Smoke::Patcher;
my
$patcher
= Test::Smoke::Patcher->new(
single
=> {
ddir
=>
$build_dir
,
pfile
=>
$patch
,
popts
=>
'-p1'
,
v
=> 1,
# 0..2
});
$patcher
->patch;
or
my
$patcher
= Test::Smoke::Patcher->new(
multi
=> {
ddir
=>
$buildir
,
pfile
=>
$patch_info
,
v
=> 1,
#0..2
});
$patcher
->patch;
DESCRIPTION
Okay, you will need a working patch program, which I believe is available for most platforms perl runs on.
There are two ways to initialise the Test::Smoke::Patcher object.
- single mode
-
The pfile attribute is a pointer to a single patch. There are four (4) ways to specify that patch.
- refernece to a SCALAR
-
The scalar holds the complete patch as literal text.
- reference to an ARRAY
-
The array holds a list of lines (with newlines) that make up the patch as literal text (
$patch = join "", @$array_ref
). - reference to a GLOB
-
You passed an opened filehandle to a file containing the patch.
- filename
-
If none of the above apply, it is assumed you passed a filename. Relative paths are rooted at the builddir (ddir attribute).
- multi mode
-
The pfile attribute is a pointer to a recource that contains filenames of patches. The format of this recource is one filename per line optionally followed by a semi-colon (;) and switches for the patch program.
The patch-resource can also be specified in four (4) ways.
TRY_REGEN_HEADERS
Constant: 1
MAX_FLAG_COUNT
Constant: 16
ALL_FLAGS
Constant: 2**MAX_FLAG_COUNT) - 1
METHODS
- Test::Smoke::Patcher->new( $type => \%args );
-
new()
crates the object. Valid types are single and multi. Valid keys for%args
:* ddir: the build directory
* fdir: the intermediate forest dir (preferred)
* pfile: path to either the patch (single) or a textfile (multi)
* popts: options to pass to
'patch'
(-p1)
* patchbin: full path to the patch binary (patch)
* regen: flag to set/unset the TRY_REGEN_HEADERS flag
* v: verbosity 0..2
- Test::Smoke::Patcher->config( $key[, $value] )
-
config()
is an interface to the package lexical%CONFIG
, which holds all the default values for thenew()
arguments.With the special key all_defaults this returns a reference to a hash holding all the default values.
- $patcher->patch
-
patch()
is a simple dispatcher. - perl_regen_headers( )
-
Try to run regen_headers.pl if the flag is set.
- $patcher->patch_single( )
-
patch_single()
checks if the pfile attribute is a plain scalar or a ref to a scalar, array, glob. In the first case this is taken to be a filename. A GLOB-ref is a filehandle, the other two are taken to be literal content. - $patcher->patch_multi( )
-
patch_multi()
checks the pfile attribute is a plain scalar or a ref to a scalar, array, glob. In the first case this is taken to be a filename. A GLOB-ref is a filehandle, the other two are taken to be literal content. - $self->_make_opts( $switches )
-
_make_opts()
just creates a string of options to pass to the patch program. Some implementations of patch do not grog '-u', so be careful! - $patcher->call_patch( $ref_to_content )
-
call_patch()
opens a pipe to the patch program and prints$$ref_to_content
to it. It will Carp::croak() on any error!
SEE ALSO
patch, Test::Smoke::Syncer::Snapshot
COPYRIGHT
(c) 2002-2003, All rights reserved.
* Abe Timmerman <abeltje
@cpan
.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See:
http://www.perl.com/perl/misc/Artistic.html
http://www.gnu.org/copyleft/gpl.html
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.