From feecd7cf2ea7905b0ed0eff6da4a4559ccc57396 Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Tue, 7 May 2019 12:51:55 +0100 Subject: [PATCH] [bazel] Fix UrlCheckerTest execution on macOS by breaking the sandbox --- java/client/test/org/openqa/selenium/net/BUILD.bazel | 3 +++ .../test/org/openqa/selenium/net/UrlCheckerTest.java | 7 ++++--- java/rules.bzl | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/java/client/test/org/openqa/selenium/net/BUILD.bazel b/java/client/test/org/openqa/selenium/net/BUILD.bazel index 98c48258bddfb..8e510f9cf8044 100644 --- a/java/client/test/org/openqa/selenium/net/BUILD.bazel +++ b/java/client/test/org/openqa/selenium/net/BUILD.bazel @@ -12,6 +12,9 @@ java_library( java_test_suite( name = "SmallTests", size = "small", + tags = [ + "no-sandbox", + ], srcs = glob(["*Test.java"]), deps = [ ":net", diff --git a/java/client/test/org/openqa/selenium/net/UrlCheckerTest.java b/java/client/test/org/openqa/selenium/net/UrlCheckerTest.java index b390469345a38..9e5f8a13474db 100644 --- a/java/client/test/org/openqa/selenium/net/UrlCheckerTest.java +++ b/java/client/test/org/openqa/selenium/net/UrlCheckerTest.java @@ -35,6 +35,7 @@ public class UrlCheckerTest { private final UrlChecker urlChecker = new UrlChecker(); + private final ExecutorService executorService = Executors.newSingleThreadExecutor(); private JreAppServer server; private URL url; @@ -50,8 +51,6 @@ public void buildServer() throws MalformedURLException { this.url = new URL(server.whereIs("/")); } - ExecutorService executorService = Executors.newSingleThreadExecutor(); - @Test public void testWaitUntilAvailableIsTimely() throws Exception { long delay = 200L; @@ -88,7 +87,9 @@ public void testWaitUntilUnavailableIsTimely() throws Exception { @After public void cleanup() { - server.stop(); + if (server != null) { + server.stop(); + } executorService.shutdown(); } } diff --git a/java/rules.bzl b/java/rules.bzl index b8628eaf17879..e161ef4406bfa 100644 --- a/java/rules.bzl +++ b/java/rules.bzl @@ -61,7 +61,8 @@ def java_test_suite( resources=None, deps=None, visibility=None, - size = None): + size = None, + tags = []): # By default bazel computes the name of test classes based on the # standard Maven directory structure, which we don't use in @@ -90,12 +91,13 @@ def java_test_suite( size = size, test_class = test_class, resources = resources, + tags = tags, deps = deps, visibility = ["//visibility:private"]) native.test_suite( name = name, tests = tests, - tags = ["manual"], + tags = ["manual"] + tags, visibility = visibility)