diff options
author | 2016-08-05 17:04:59 +0000 | |
---|---|---|
committer | 2016-08-08 08:07:17 +0000 | |
commit | e1fee21a8d949f3a090603baeec425c19ba05b47 (patch) | |
tree | f9c524e82d52398a2d65fdb2db84813fd0170271 /src/java_tools | |
parent | ea381f0c8a103936e00a07b79a6ca8f8c81f2819 (diff) |
Allow test targets to completely disable the test security manager via
a property without installing a different security manager.
This is required to run JUnit's tests in Blaze.
RELNOTES: Test targets can disable the JUnit4 test security manager via a property.
--
MOS_MIGRATED_REVID=129453237
Diffstat (limited to 'src/java_tools')
-rw-r--r-- | src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java index 9f76bd89bb..362b5fbd29 100644 --- a/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java +++ b/src/java_tools/junitrunner/java/com/google/testing/junit/runner/junit4/JUnit4Config.java @@ -29,6 +29,10 @@ class JUnit4Config { @VisibleForTesting static final String JUNIT_API_VERSION_PROPERTY = "com.google.testing.junit.runner.apiVersion"; + @VisibleForTesting + static final String SHOULD_INSTALL_SECURITY_MANAGER_PROPERTY + = "com.google.testing.junit.runner.shouldInstallTestSecurityManager"; + private final String testIncludeFilterRegexp; private final String testExcludeFilterRegexp; private final Optional<Path> xmlOutputPath; @@ -58,7 +62,16 @@ class JUnit4Config { this.testExcludeFilterRegexp = testExcludeFilterRegexp; this.xmlOutputPath = xmlOutputPath; junitApiVersion = systemProperties.getProperty(JUNIT_API_VERSION_PROPERTY, "1").trim(); - shouldInstallSecurityManager = systemProperties.getProperty("java.security.manager") == null; + shouldInstallSecurityManager = installSecurityManager(systemProperties); + } + + private static boolean installSecurityManager(Properties systemProperties) { + String securityManager = systemProperties.getProperty("java.security.manager"); + if (securityManager != null) { + return false; // Don't install over the specified security manager + } + return Boolean.valueOf( + systemProperties.getProperty(SHOULD_INSTALL_SECURITY_MANAGER_PROPERTY, "true")); } /** |