diff --git a/bramble-android/build.gradle b/bramble-android/build.gradle index 87279ad62..b12625bb0 100644 --- a/bramble-android/build.gradle +++ b/bramble-android/build.gradle @@ -49,8 +49,3 @@ project.afterEvaluate { into 'src/main/res/raw' } } - -tasks.withType(Test) { - // Use entropy-gathering device specified on command line, if any - systemProperty 'java.security.egd', System.getProperty('java.security.egd') -} diff --git a/bramble-api/build.gradle b/bramble-api/build.gradle index 520d5bf88..fc1634e8c 100644 --- a/bramble-api/build.gradle +++ b/bramble-api/build.gradle @@ -31,8 +31,3 @@ task jarTest(type: Jar, dependsOn: testClasses) { artifacts { testOutput jarTest } - -tasks.withType(Test) { - // Use entropy-gathering device specified on command line, if any - systemProperty 'java.security.egd', System.getProperty('java.security.egd') -} diff --git a/bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java b/bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java index 5bcf28d77..8b6a8177d 100644 --- a/bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java +++ b/bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; +import static java.util.Arrays.asList; import static org.briarproject.bramble.api.identity.Author.FORMAT_VERSION; import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH; import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH; @@ -173,4 +174,10 @@ public class TestUtils { Collection samples) { return Math.sqrt(getVariance(samples)); } + + public static boolean isOptionalTestEnabled(Class testClass) { + String optionalTests = System.getenv("OPTIONAL_TESTS"); + return optionalTests != null && + asList(optionalTests.split(",")).contains(testClass.getName()); + } } diff --git a/bramble-core/build.gradle b/bramble-core/build.gradle index da57caf0f..56ddcde1c 100644 --- a/bramble-core/build.gradle +++ b/bramble-core/build.gradle @@ -44,8 +44,3 @@ task jarTest(type: Jar, dependsOn: testClasses) { artifacts { testOutput jarTest } - -tasks.withType(Test) { - // Use entropy-gathering device specified on command line, if any - systemProperty 'java.security.egd', System.getProperty('java.security.egd') -} diff --git a/bramble-java/build.gradle b/bramble-java/build.gradle index eba3a7645..9d54698f5 100644 --- a/bramble-java/build.gradle +++ b/bramble-java/build.gradle @@ -40,7 +40,5 @@ project.afterEvaluate { } tasks.withType(Test) { - // Use entropy-gathering device specified on command line, if any - systemProperty 'java.security.egd', System.getProperty('java.security.egd') systemProperty 'java.library.path', 'libs' } diff --git a/bramble-java/src/test/java/org/briarproject/bramble/plugin/tor/BridgeTest.java b/bramble-java/src/test/java/org/briarproject/bramble/plugin/tor/BridgeTest.java index 779bf63a7..28f50be64 100644 --- a/bramble-java/src/test/java/org/briarproject/bramble/plugin/tor/BridgeTest.java +++ b/bramble-java/src/test/java/org/briarproject/bramble/plugin/tor/BridgeTest.java @@ -12,7 +12,6 @@ import org.briarproject.bramble.test.BrambleTestCase; import org.briarproject.bramble.test.DaggerBrambleJavaIntegrationTestComponent; import org.junit.AfterClass; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import java.io.File; @@ -28,11 +27,12 @@ import static java.util.Collections.singletonList; import static java.util.concurrent.TimeUnit.SECONDS; import static org.briarproject.bramble.test.TestUtils.deleteTestDirectory; import static org.briarproject.bramble.test.TestUtils.getTestDirectory; +import static org.briarproject.bramble.test.TestUtils.isOptionalTestEnabled; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; -@Ignore("Might fail non-deterministically when bridges are down") public class BridgeTest extends BrambleTestCase { private final static long TIMEOUT = SECONDS.toMillis(23); @@ -61,6 +61,9 @@ public class BridgeTest extends BrambleTestCase { @Before public void setUp() { + // Skip this test unless it's explicitly enabled in the environment + assumeTrue(isOptionalTestEnabled(BridgeTest.class)); + BrambleJavaIntegrationTestComponent component = DaggerBrambleJavaIntegrationTestComponent.builder().build(); component.inject(this); diff --git a/briar-android/build.gradle b/briar-android/build.gradle index ef9427921..9a905fa10 100644 --- a/briar-android/build.gradle +++ b/briar-android/build.gradle @@ -184,8 +184,3 @@ task verifyTranslations { project.afterEvaluate { preBuild.dependsOn.add(verifyTranslations) } - -tasks.withType(Test) { - // Use entropy-gathering device specified on command line, if any - systemProperty 'java.security.egd', System.getProperty('java.security.egd') -} diff --git a/briar-api/build.gradle b/briar-api/build.gradle index e5f288e55..6331e5edd 100644 --- a/briar-api/build.gradle +++ b/briar-api/build.gradle @@ -11,8 +11,3 @@ dependencies { signature 'org.codehaus.mojo.signature:java16:1.1@signature' } - -tasks.withType(Test) { - // Use entropy-gathering device specified on command line, if any - systemProperty 'java.security.egd', System.getProperty('java.security.egd') -} diff --git a/briar-core/build.gradle b/briar-core/build.gradle index 6fb4231dc..f3fad0cba 100644 --- a/briar-core/build.gradle +++ b/briar-core/build.gradle @@ -32,8 +32,3 @@ dependencies { signature 'org.codehaus.mojo.signature:java16:1.1@signature' } - -tasks.withType(Test) { - // Use entropy-gathering device specified on command line, if any - systemProperty 'java.security.egd', System.getProperty('java.security.egd') -} diff --git a/build.gradle b/build.gradle index 90076707c..b3a53aa51 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,14 @@ allprojects { mavenLocal() google() } + afterEvaluate { + tasks.withType(Test) { + // Allow tests to be re-run if any optional tests are enabled + outputs.upToDateWhen { System.getenv("OPTIONAL_TESTS") == null } + // Use entropy-gathering device specified on command line, if any + systemProperty 'java.security.egd', System.getProperty('java.security.egd') + } + } } buildscript {