Explorar o código

Add SKIP label and follow rest of test code conventions

Vangelis Katsikaros %!s(int64=9) %!d(string=hai) anos
pai
achega
5c5693de35
Modificáronse 1 ficheiros con 33 adicións e 27 borrados
  1. 33 27
      t/CanStartBinary.t

+ 33 - 27
t/CanStartBinary.t

@@ -177,37 +177,43 @@ TIMEOUT: {
 }
 
 FIXED_PORTS: {
-    my $driver;
-    my $port = 50000;
-
-    my $socket = IO::Socket::INET->new(
-        LocalHost => '127.0.0.1',
-        LocalPort => $port,
-        Proto => 'tcp',
-        Listen => 5,
-    ) or BAIL_OUT("Can't bind tcp port $port: $!");
-
-    isa_ok(
-        exception {
+  SKIP: {
+        my $has_geckodriver = which('geckodriver');
+        skip 'Firefox geckodriver not found in path', 1
+          unless $has_geckodriver;
+
+        my $firefox;
+        my $port = 50000;
+
+        my $socket = IO::Socket::INET->new(
+            LocalHost => '127.0.0.1',
+            LocalPort => $port,
+            Proto => 'tcp',
+            Listen => 5,
+        ) or BAIL_OUT("Can't bind tcp port $port: $!");
+
+        isa_ok(
+            exception {
+                Selenium::Firefox->new(
+                    binary_port => $port,
+                    fixed_ports => 1,
+                );
+            },
+            qr/port $port is not free and have requested fixed ports/,
+            "Driver failed to be created because input port $port is already occupied and flag fixed_ports is true"
+        );
+
+        $firefox = try {
             Selenium::Firefox->new(
                 binary_port => $port,
-                fixed_ports => 1,
             );
-        },
-        qr/port $port is not free and have requested fixed ports/,
-        "Driver failed to be created because input port $port is already occupied and flag fixed_ports is true"
-    );
-
-    $driver = try {
-        Selenium::Firefox->new(
-            binary_port => $port,
-        );
-    };
-    my $non_fixed_port = $driver->port;
-    cmp_ok($non_fixed_port, '>=', $port, "Driver could not acquire already occupied $port and a higer port $non_fixed_port was acquired");
+        };
+        my $non_fixed_port = $firefox->port;
+        cmp_ok($non_fixed_port, '>=', $port, "Driver could not acquire already occupied $port and a higer port $non_fixed_port was acquired");
 
-    $driver->shutdown_binary();
-    $socket->close();
+        $firefox->shutdown_binary();
+        $socket->close();
+    }
 }
 
 sub is_proper_phantomjs_available {