mirror of
https://github.com/google/nomulus
synced 2026-07-28 02:52:45 +00:00
Restore original System Properties after tests
Many registry tools tests modify system properties but do not restore them to original state. These tests must be isolated from each other and cannot share the same test execution process. This has a huge impact on test performance under Gradle, which seems to have higher process startup overhead. Current Gradle test config has to set 'forEvery' to 1, i.e., every test class must be run in a freshly started process. This change significantly reduces the number of tests that need isolation, making it easier to optimize test config for the remaining tests. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=221350284
This commit is contained in:
@@ -47,11 +47,25 @@ public enum RegistryEnvironment {
|
||||
*/
|
||||
UNITTEST;
|
||||
|
||||
/** Sets this enum as the name of the registry environment. */
|
||||
public RegistryEnvironment setup() {
|
||||
return setup(SystemPropertySetter.PRODUCTION_IMPL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this enum as the name of the registry environment using specified {@link
|
||||
* SystemPropertySetter}.
|
||||
*/
|
||||
public RegistryEnvironment setup(SystemPropertySetter systemPropertySetter) {
|
||||
systemPropertySetter.setProperty(PROPERTY, name());
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Returns environment configured by system property {@value #PROPERTY}. */
|
||||
public static RegistryEnvironment get() {
|
||||
return valueOf(Ascii.toUpperCase(System.getProperty(PROPERTY, UNITTEST.name())));
|
||||
}
|
||||
|
||||
/** System property for configuring which environment we should use. */
|
||||
public static final String PROPERTY = "google.registry.environment";
|
||||
private static final String PROPERTY = "google.registry.environment";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user