[Rt-commit] r20019 - rt/3.8/trunk/lib/RT

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Jun 18 08:41:46 EDT 2009


Author: sunnavy
Date: Thu Jun 18 08:41:46 2009
New Revision: 20019

Modified:
   rt/3.8/trunk/lib/RT/Test.pm

Log:
tweak the strategy of finding data/gnupg/keys dir

Modified: rt/3.8/trunk/lib/RT/Test.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Test.pm	(original)
+++ rt/3.8/trunk/lib/RT/Test.pm	Thu Jun 18 08:41:46 2009
@@ -689,19 +689,34 @@
 
 sub import_gnupg_key {
     my $self = shift;
-    my $key = shift;
+    my $key  = shift;
     my $type = shift || 'secret';
 
     $key =~ s/\@/-at-/g;
     $key .= ".$type.key";
 
     require RT::Crypt::GnuPG;
-    # this is a bit hackish; calling it from somewhere that's not a subdir
-    # of t/ will fail
+
+    # simple strategy find data/gnupg/keys, from the dir where test file lives
+    # to updirs, try 3 times in total
+    my $path = File::Spec->catfile( 'data', 'gnupg', 'keys' );
+    my $abs_path;
+    for my $up ( 0 .. 2 ) {
+        my $p = get_relocatable_dir($path);
+        if ( -e $p ) {
+            $abs_path = $p;
+            last;
+        }
+        else {
+            $path = File::Spec->catfile( File::Spec->updir(), $path );
+        }
+    }
+
+    die "can't find the dir where gnupg keys are stored"
+      unless $abs_path;
+
     return RT::Crypt::GnuPG::ImportKey(
-        RT::Test->file_content([get_relocatable_dir(File::Spec->updir(),
-                qw(data gnupg keys)), $key])
-    );
+        RT::Test->file_content( [ $abs_path, $key ] ) );
 }
 
 


More information about the Rt-commit mailing list