diff options
author | Steve McIntyre <steve@einval.com> | 2018-05-31 17:02:09 +0100 |
---|---|---|
committer | Steve McIntyre <steve@einval.com> | 2018-05-31 17:02:09 +0100 |
commit | 4ec44f544a78659d86d846fc85a3e724ddb0c4af (patch) | |
tree | 05030adf32cabd843d782c2904b9352474287d67 /vcs-test.pl | |
parent | 688cde2de34c6272d808e06ea661090fed07b61c (diff) |
Cope with being called from directories other than the webwml root
Added extra directory handling code to allow for this where it makes
sense. This should now work for all public APIs, except:
* cache_file()
* cache_repo()
* path_info()
* get_topdir()
The first two are almost internal anyway, and the last doesn't take
any arguments to allow for anything to work *except* when the caller
is somewhere within the webwml repo. path_info() is *hard* to change
here, and all the callers I can find are already expecting to be in
webwml anyway. I've added checks in each of these to at least complain
clearly when expectations are not met.
These changes might slow things down slightly due to repeated chdir()
calls, but meh.
Also added some extra tests for this in the vcs-test.pl script.
Diffstat (limited to 'vcs-test.pl')
-rwxr-xr-x | vcs-test.pl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/vcs-test.pl b/vcs-test.pl index 29bdca8fc93..0870c62bcf0 100755 --- a/vcs-test.pl +++ b/vcs-test.pl @@ -13,6 +13,7 @@ use Local::Cvsinfo; use Local::VCS; use Webwml::TransCheck; use Webwml::Langs; +use Cwd qw/cwd/; my $file = "english/CD/faq/index.wml"; my $rev1; @@ -98,6 +99,33 @@ print "4. (old, new) returned $ret\n"; ########################################################## print "#############################\n"; +print "VCS->cmp_rev::: from another directory\n"; +my $startdir = cwd; +chdir "/tmp"; +$ret = $VCS->cmp_rev("$startdir/$file", , ,); +if (!defined $ret) { + $ret = "<undef>"; +} +print "1. (no revs specified) returned $ret\n"; +$ret = $VCS->cmp_rev("$startdir/english/../english/CD/faq/index.wml", $rev1, $rev1); +if (!defined $ret) { + $ret = "<undef>"; +} +print "2. (equal revs) returned $ret\n"; +$ret = $VCS->cmp_rev("$startdir/english/CD/faq/index.wml", $rev1, $rev2); +if (!defined $ret) { + $ret = "<undef>"; +} +print "3. (new, old) returned $ret\n"; +$ret = $VCS->cmp_rev("$startdir/english/CD/faq/index.wml", $rev2, $rev1); +if (!defined $ret) { + $ret = "<undef>"; +} +print "4. (old, new) returned $ret\n"; +chdir "$startdir"; + +########################################################## +print "#############################\n"; print "VCS->count_changes:::\n"; $ret = $VCS->count_changes("english/CD/faq/index.wml", , ,); if (!defined $ret) { |