|
|
| |
VCP::TestUtils(3) |
User Contributed Perl Documentation |
VCP::TestUtils(3) |
VCP::TestUtils - support routines for VCP testing
- copy_dir_tree
-
copy_dir_tree $src, $dest;
Copy source directory tree to a destination directory. Accepts
absolute or relative directory names, but doesn't do tilde
expansion.
- rm_dir_tree
-
rm_dir_tree $path;
Remove a directory tree. Does not complain if it's not there
to remove.
- assert_eq
- DEPRECATED. Use ok_or_diff() instead.
assert_eq $test_name, $expected, $got;
- ok_or_diff
-
ok_or_diff $got, $expected, ...;
Use instead of ok to compare two strings and output a diff if
they are indeed different. Uses Test::Difference's eq_or_diff()
if present, otherwise falls back to Text::Diff::diff(). Calls
Test::ok().
If $got is empty and
$expected is longer than 2 lines, diff()
is not called and a special message is generated. This is to prevent
SPAMming out huge diffs when no output is received but
$expected is big.
- slurp
-
$guts = slurp $filename ;
@lines = slurp $filename;
read entire contents of file and return as a scalar, or array in
array context (splitting on newlines.)
- perl_cmd
-
@perl = perl_cmd
Returns a list containing the Perl executable and some options
to reproduce the current Perl options , like -I.
- find_command
-
@vcp = find_command "vcp"
Find a script within the main distro directory or one subdir
under it. Looks for "bin/<cmd>" and
"../bin/<cmd>". This should be adequate for almost all
uses.
- vcp_cmd
-
@vcp = vcp_cmd
Returns a list containing the Perl executable and some options
to reproduce the current Perl options , like -I.
vcp_cmd assumes it is called from within the main distro
directory or one subdir under it, since it looks for "bin/vcp"
and "../bin/vcp". This should be adequate for almost all
uses.
vcp_cmd caches it's results to allow it to be run from other
directories after the first time it's called. (this is not a significant
performance improvement; running the vcp process takes several orders of
magnitude longer than the quick checks vcp_cmd does).
If $ENV{VCPTESTCOMMAND} is set, it is
treated as a path to the executable to run plus parameters. If the path
includes spaces, it must be enclosed in quotation marks. If the path is
relative, it is assumed to be relative to the current working
directory.
- compile_dtd_cmd
-
@compile_dtd = compile_dtd_cmd
Returns a list containing the Perl executable and some options
to reproduce the current Perl options , like -I.
compile_dtd_cmd assumes it is called from within the main
distro directory or one subdir under it, since it looks for
"bin/compile_dtd" and "../bin/compile_dtd". This
should be adequate for almost all uses.
compile_dtd_cmd caches it's results to allow it to be run from
other directories after the first time it's called.
- run
- Run a command using IPC::Run3::run3(), but with logging and a
verbose exception on non-0 result code.
Arguments are the same as and are passed to
IPC::Run3::run3().
- run_p4
- calls 'run' to run p4 binary after deciding which platform specific
program to run.
determines p4 executable name based on operating system.
builds p4 options string from
$p4_options hash
examples:
run_p4 \@args, \$stdin, \$stdout, \$stderr, $p4_options;
run_p4 [ qw(files) ], \undef, \$stdout, $p4_options;
arguments:
- 1.
- array of words to add to end of p4 command
- 2.
- 2...
remaining arguments passed on to 'run' sub (except final
arg)
- 3.
- final arg:
p4_options hash (may contain: port, user, client, password ...
?)
- parse_files_and_revids_from_head_revs_db <options-hash>
- options:
state_dir
repo_id
remove_rev_root (string to be removed from front of filename)
given a vcp state directory and repo_id, dump the head revs to
a string, and parse out the <name> and <rev_id> elements
within each <rev>, then return a string (sorted by line) of the
form:
<name1> <max_revision_num1>
<name2> <max_revision_num2>
<name3> <max_revision_num3>
.
.
.
examples:
my $revs = parse_files_and_revids_from_head_revs_db
{ state_dir => $state_dir, repo_id => $repo_id }
my $revs = parse_files_and_revids_from_head_revs_db $state_dir $repo_id
{ state_dir => $state_dir, repo_id => $repo_id, remove_rev_root => "/ignore/" }
- parse_files_and_revids_from_revml
- given one or more revml filenames, slurp them up, parse out the
<name> and <rev_id> elements within each <rev>, then
return a string (sorted by line) of the form:
<name1> <max_revision_num1>
<name2> <max_revision_num2>
<name3> <max_revision_num3>
.
.
.
The final (optional) argument may be a reference to a hash of
parameters. Currently the only parameter is
IGNORE_REVS_WITH_DELETE_FLAG, which if true, causes any revs containing
the <delete /> or <delete/> tags to be ignored.
examples:
my $revs = parse_files_and_revids_from_revml $infile ;
my $revs = parse_files_and_revids_from_revml $infile1, $infile2 ;
- parse_files_and_revids_from_p4_files
- Run p4 files command line to get list of changed files. Parse the output
so it can be diffed with the output of parse_files_and_revids_from_revml.
returns a string containing names and revision numbers, 1 per
line. See that sub above for a description of the output format.
arguments are:
- 1.
- revision root, e.g. "//depot/something/". This string will be
removed from the output so it may be diffed with
parse_files_and_revids_from_revml output.
- 2.
- options hash for run_p4()
- 3.
- 3...
1 or more file[revRange] spec for p4 files command (run 'p4
help files' and 'p4 help revisions' command line for formatting
help)
example usage:
parse_files_and_revids_from_p4_files $p4_rev_root, $p4_options, "//..."
- parse_files_and_revids_from_cvs_history
- Run cvs history command line to get list of changed files. Parse the
output so it can be diffed with the output of
parse_files_and_revids_from_revml.
returns a string containing names and revision numbers, 1 per
line. See that sub above for a description of the output format.
arguments are:
- 1.
- cvs root directory.
- 2.
- cvs module name. This string will be removed from the output so it may be
diffed with parse_files_and_revids_from_revml output.
example usage:
parse_files_and_revids_from_cvs_history "/home/blah/blah/cvsroot_0/", "module-blah"
- get_vcp_output
-
@vcp = get_vcp_output "foo:", "-bar" ;
Does a:
run [ vcp_cmd, @_, "sort:", "--", "revml:", ... ], \undef, \$out
or croak "`vcp blahdy blah` returned $?";
and returns $out. The "..."
refers to whatever output options are needed to make the test output
agree with "bin/gentrevml"'s test
files (t/test-*.revml).
You may pass in options as a hash reference as the final
argument. The supported option is:
revml_out_spec
which, if present, is tacked on to the revml: output spec's
list of options,
These are used to get rid of content or elements that are known to differ when
comparing the revml fed in to a repository with the revml that comes out.
- s_content
-
s_content
$elt_type1, $elt_type2, ..., \$string1, \$string2, ..., $new_content ;
Changes the contents of the elements, since some things, like
suer id or mod_time can't be the same after going through a
repository.
If $new_val is not supplied, a
constant string is used.
- rm_elts
-
rm_elts $elt_type1, $elt_type2, ..., \$string1, \$string2
rm_elts $elt_type1, $elt_type2, ..., qr/$content_re/, \$string1, \$string2
Removes the specified elements from the strings, including
leading whitespace and trailing line separators. If the optional
$content_re regular expression is provided, then
only elements containing that pattern will be removed.
- p4_borken
- Returns true if the p4 is missing or too old (< 99.2).
- tmpdir
-
my $d = tmpdir ## create a directory like /tmp/vcp_95cvs2p4_#####
my $d = tmpdir( "foo" ); ## create a directory like /tmp/vcp_95cvs2p4_foo_#####
Return a temporary directory that will be deleted in an END
block.
The prefix is advisory only and is meant to allow developers
to intuit the purpose of a temporary directory from its name.
See File::Spec::Unix's tmpdir() function for details,
but you can set the TMPDIR environment variable to control where the VCP
test suite places temp dirs (and, after testing, where vcp places test
dirs, but vcp has separate temp directory management functions).
- cvs_borken
- Returns true if cvs -v works and outputs "Concurrent Versions
System".
- init_cvsroot
-
my $cvs_options = init_cvsroot $prefix, $module_name ;
my $cvs_options = init_cvsroot $prefix, $module_name, $rootdir ;
Creates a CVS repository containing an empty module. Also sets
$ENV{LOGNAME} if it notices that we're running
as root, so CVS won't give a "cannot commit files as 'root'"
error. Tries "nobody", then "guest".
Returns the options needed to access the cvs repository.
- vss_borken
- Returns true if MKSS may be run.
Copyright 2000, Perforce Software, Inc. All Rights Reserved.
This module and the VCP package are licensed according to the
terms given in the file LICENSE accompanying this distribution, a copy of
which is included in vcp.
Hey! The above document had some coding errors, which are explained
below:
- Around line 472:
- Expected '=item 2'
- Around line 476:
- Expected '=item 3'
- Around line 695:
- Expected '=item 3'
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc. |