Kaynağa Gözat

Use FindBin to make tests more $(cwd) independent

Daniel Gempesaw 11 yıl önce
ebeveyn
işleme
1a203a2b5e
2 değiştirilmiş dosya ile 7 ekleme ve 5 silme
  1. 3 2
      t/Firefox-Profile.t
  2. 4 3
      t/http-server.pl

+ 3 - 2
t/Firefox-Profile.t

@@ -24,11 +24,12 @@ my %selenium_args = %{ $harness->base_caps };
 unless ($harness->mocks_exist_for_platform) {
     plan skip_all => "Mocking of tests is not been enabled for this platform";
 }
+my $fixture_dir = $FindBin::Bin . '/www/';
 
 CUSTOM_EXTENSION_LOADED: {
     my $profile = Selenium::Remote::Driver::Firefox::Profile->new;
     my $website = 'http://localhost:63636';
-    my $mock_encoded_profile = "t/www/encoded_profile.b64";
+    my $mock_encoded_profile = $fixture_dir . 'encoded_profile.b64';
     my $encoded;
 
     # Set this to true to re-encode the profile. This should not need
@@ -49,7 +50,7 @@ CUSTOM_EXTENSION_LOADED: {
         #     contentScript: 'document.body.innerHTML = ' +
         #         ' "<h1>Page matches ruleset</h1>";'
         # });
-        $profile->add_extension('t/www/redisplay.xpi');
+        $profile->add_extension($fixture_dir . 'redisplay.xpi');
 
         $encoded = $profile->_encode;
 

+ 4 - 3
t/http-server.pl

@@ -4,6 +4,7 @@
 use warnings;
 use strict;
 use IO::Socket;
+use FindBin;
 use File::stat;
 use File::Basename;
 
@@ -14,15 +15,15 @@ my $server = IO::Socket::INET->new(
     ReuseAddr => 1
 );
 
-my $server_root = "t/";
+my $server_root = $FindBin::Bin . '/';
 
 die "Server failed.\n" unless $server;
 
 while ( my $client = $server->accept() ) {
     $client->autoflush(1);
-    
+
     my $request = <$client>;
-    
+
     my $filename;
     my $filesize;
     my $content_type;