/** * Append a single VM option. */ @Override public ReproduceErrorMessageBuilder appendOpt(String sysPropName, String value) { if (sysPropName.equals(SYSPROP_ITERATIONS())) { // we don't want the iters to be in there! return this; } if (sysPropName.equals(SYSPROP_TESTMETHOD())) { //don't print out the test method, we print it ourselves in appendAllOpts //without filtering out the parameters (needed for REST tests) return this; } if (sysPropName.equals(SYSPROP_PREFIX())) { // we always use the default prefix return this; } if (!Strings.isBlank(value)) { if (value.indexOf(' ') >= 0) { return super.appendOpt(sysPropName, '"' + value + '"'); } return super.appendOpt(sysPropName, value); } return this; }
public ReproduceErrorMessageBuilder appendRunnerProperties() { appendOpt(SYSPROP_PREFIX(), CURRENT_PREFIX()); for (String sysPropName : Arrays.asList( SYSPROP_STACKFILTERING(), SYSPROP_ITERATIONS(), SYSPROP_KILLATTEMPTS(), SYSPROP_KILLWAIT(), SYSPROP_TIMEOUT())) { if (System.getProperty(sysPropName) != null) { appendOpt(sysPropName, System.getProperty(sysPropName)); } } return this; }
/** * Validate arguments and state. */ private void validate() { if (propertyName == null) { propertyName = SysGlobals.SYSPROP_RANDOM_SEED(); } } }
appendSeedParameter = RandomizedTest.systemPropertyAsBoolean(SYSPROP_APPEND_SEED(), false); if (RandomizedTest.systemPropertyAsBoolean(SYSPROP_STACKFILTERING(), true)) { this.traces = new TraceFormatting(DEFAULT_STACK_FILTERS); } else { final String globalSeed = emptyToNull(System.getProperty(SYSPROP_RANDOM_SEED())); final long initialSeed; if (globalSeed != null) { if (seedChain.length == 0 || seedChain.length > 2) { throw new IllegalArgumentException("Invalid system property " + SYSPROP_RANDOM_SEED() + " specification: " + globalSeed); if (emptyToNull(System.getProperty(SYSPROP_ITERATIONS())) != null) { this.iterationsOverride = RandomizedTest.systemPropertyAsInt(SYSPROP_ITERATIONS(), 0); if (iterationsOverride < 1) throw new IllegalArgumentException( "System property " + SYSPROP_ITERATIONS() + " must be >= 1: " + iterationsOverride); } else { this.iterationsOverride = null; if (emptyToNull(System.getProperty(SYSPROP_TESTMETHOD())) != null) { filter(new MethodGlobFilter(System.getProperty(SYSPROP_TESTMETHOD()))); if (emptyToNull(System.getProperty(SYSPROP_TESTCLASS())) != null) { Filter suiteFilter = new ClassGlobFilter(System.getProperty(SYSPROP_TESTCLASS())); if (!suiteFilter.shouldRun(suiteDescription)) { suiteDescription.getChildren().clear();
Strings.emptyToNull(getProject().getProperty(SYSPROP_RANDOM_SEED())), SeedUtils.formatSeed(new Random().nextLong())); createJvmarg().setValue("-D" + SYSPROP_PREFIX() + "=" + CURRENT_PREFIX()); createJvmarg().setValue("-D" + SYSPROP_RANDOM_SEED() + "=" + random); String testMethodFilter = Strings.emptyToNull(getProject().getProperty(SYSPROP_TESTMETHOD())); if (testMethodFilter != null) { Environment.Variable v = new Environment.Variable(); v.setKey(SYSPROP_TESTMETHOD()); v.setValue(testMethodFilter); getCommandline().addSysproperty(v); if (SysGlobals.SYSPROP_TESTFILTER().equals(v.getKey())) { try { Node root = new FilterExpressionParser().parse(v.getValue());
/** * Append all JVM options that may help in reproducing the error. Options are * appended to the provided StringBuilder in the "command-line" syntax of: * <pre> * -Doption="value" * </pre> * * @param description Suite or test description. */ public ReproduceErrorMessageBuilder appendAllOpts(Description description) { RandomizedContext ctx = null; try { ctx = RandomizedContext.current(); appendOpt(SYSPROP_RANDOM_SEED(), ctx.getRunnerSeedAsString()); } catch (IllegalStateException e) { logger.warning("No context available when dumping reproduce options?"); } if (description.getClassName() != null) { appendOpt(SYSPROP_TESTCLASS(), description.getClassName()); } if (description.getMethodName() != null) { appendOpt(SYSPROP_TESTMETHOD(), methodName(description)); } appendRunnerProperties(); appendTestGroupOptions(ctx); appendEnvironmentSettings(); return this; }
/** * Initializes custom prefix for all junit4 properties. This must be consistent * across all junit4 invocations if done from the same classpath. Use only when REALLY needed. */ public void setPrefix(String prefix) { if (!Strings.isNullOrEmpty(getProject().getUserProperty(SYSPROP_PREFIX()))) { log("Ignoring prefix attribute because it is overridden by user properties.", Project.MSG_WARN); } else { SysGlobals.initializeWith(prefix); } }
@Override public ReproduceErrorMessageBuilder appendAllOpts(Description description) { super.appendAllOpts(description); if (description.getMethodName() != null) { //prints out the raw method description instead of methodName(description) which filters out the parameters super.appendOpt(SYSPROP_TESTMETHOD(), "\"" + description.getMethodName() + "\""); } List<String> properties = new ArrayList<>(); scanProperties(description.getTestClass(), properties); appendProperties(properties.toArray(new String[properties.size()])); return appendESProperties(); }
GroupEvaluator(List<TestCandidate> testCandidates) { testGroups = collectGroups(testCandidates); filterExpression = System.getProperty(SysGlobals.SYSPROP_TESTFILTER()); if (filterExpression != null && filterExpression.trim().isEmpty()) { filterExpression = null; } filter = filterExpression != null ? new FilterExpressionParser().parse(filterExpression) : null; }
/** */ private static SysGlobals singleton() { synchronized (lock) { if (singleton == null) { String prefix = System.getProperty(SYSPROP_PREFIX); if (prefix == null) { prefix = DEFAULT_PREFIX; } initializeWith(prefix); } return singleton; } }
String testClassFilter = Strings.emptyToNull(getProject().getProperty(SYSPROP_TESTCLASS())); if (testClassFilter != null) { ClassGlobFilter filter = new ClassGlobFilter(testClassFilter);
appendSeedParameter = RandomizedTest.systemPropertyAsBoolean(SYSPROP_APPEND_SEED(), false); if (RandomizedTest.systemPropertyAsBoolean(SYSPROP_STACKFILTERING(), true)) { this.traces = new TraceFormatting(DEFAULT_STACK_FILTERS); } else { final String globalSeed = emptyToNull(System.getProperty(SYSPROP_RANDOM_SEED())); final long initialSeed; if (globalSeed != null) { if (seedChain.length == 0 || seedChain.length > 2) { throw new IllegalArgumentException("Invalid system property " + SYSPROP_RANDOM_SEED() + " specification: " + globalSeed); if (emptyToNull(System.getProperty(SYSPROP_ITERATIONS())) != null) { this.iterationsOverride = RandomizedTest.systemPropertyAsInt(SYSPROP_ITERATIONS(), 0); if (iterationsOverride < 1) throw new IllegalArgumentException( "System property " + SYSPROP_ITERATIONS() + " must be >= 1: " + iterationsOverride); } else { this.iterationsOverride = null; if (emptyToNull(System.getProperty(SYSPROP_TESTMETHOD())) != null) { filter(new MethodGlobFilter(System.getProperty(SYSPROP_TESTMETHOD()))); if (emptyToNull(System.getProperty(SYSPROP_TESTCLASS())) != null) { Filter suiteFilter = new ClassGlobFilter(System.getProperty(SYSPROP_TESTCLASS())); if (!suiteFilter.shouldRun(suiteDescription)) { suiteDescription.getChildren().clear();
/** * Append all JVM options that may help in reproducing the error. Options are * appended to the provided StringBuilder in the "command-line" syntax of: * <pre> * -Doption="value" * </pre> * * @param description Suite or test description. */ public ReproduceErrorMessageBuilder appendAllOpts(Description description) { RandomizedContext ctx = null; try { ctx = RandomizedContext.current(); appendOpt(SYSPROP_RANDOM_SEED(), ctx.getRunnerSeedAsString()); } catch (IllegalStateException e) { logger.warning("No context available when dumping reproduce options?"); } if (description.getClassName() != null) { appendOpt(SYSPROP_TESTCLASS(), description.getClassName()); } if (description.getMethodName() != null) { appendOpt(SYSPROP_TESTMETHOD(), methodName(description)); } appendRunnerProperties(); appendTestGroupOptions(ctx); appendEnvironmentSettings(); return this; }
@Override public ReproduceErrorMessageBuilder appendAllOpts(Description description) { super.appendAllOpts(description); if (description.getMethodName() != null) { //prints out the raw method description instead of methodName(description) which filters out the parameters super.appendOpt(SYSPROP_TESTMETHOD(), "\"" + description.getMethodName() + "\""); } List<String> properties = new ArrayList<>(); scanProperties(description.getTestClass(), properties); appendProperties(properties.toArray(new String[properties.size()])); return appendESProperties(); }
GroupEvaluator(List<TestCandidate> testCandidates) { testGroups = collectGroups(testCandidates); filterExpression = System.getProperty(SysGlobals.SYSPROP_TESTFILTER()); if (filterExpression != null && filterExpression.trim().isEmpty()) { filterExpression = null; } filter = filterExpression != null ? new FilterExpressionParser().parse(filterExpression) : null; }
/** */ private static SysGlobals singleton() { synchronized (lock) { if (singleton == null) { String prefix = System.getProperty(SYSPROP_PREFIX); if (prefix == null) { prefix = DEFAULT_PREFIX; } initializeWith(prefix); } return singleton; } }
/** * Append a single VM option. */ @Override public ReproduceErrorMessageBuilder appendOpt(String sysPropName, String value) { if (sysPropName.equals(SYSPROP_ITERATIONS())) { // we don't want the iters to be in there! return this; } if (sysPropName.equals(SYSPROP_TESTMETHOD())) { //don't print out the test method, we print it ourselves in appendAllOpts //without filtering out the parameters (needed for REST tests) return this; } if (sysPropName.equals(SYSPROP_PREFIX())) { // we always use the default prefix return this; } if (Strings.hasLength(value)) { return super.appendOpt(sysPropName, value); } return this; }
public ReproduceErrorMessageBuilder appendRunnerProperties() { appendOpt(SYSPROP_PREFIX(), CURRENT_PREFIX()); for (String sysPropName : Arrays.asList( SYSPROP_STACKFILTERING(), SYSPROP_ITERATIONS(), SYSPROP_KILLATTEMPTS(), SYSPROP_KILLWAIT(), SYSPROP_TIMEOUT())) { if (System.getProperty(sysPropName) != null) { appendOpt(sysPropName, System.getProperty(sysPropName)); } } return this; }
@Override public ReproduceErrorMessageBuilder appendAllOpts(Description description) { super.appendAllOpts(description); if (description.getMethodName() != null) { //prints out the raw method description instead of methodName(description) which filters out the parameters super.appendOpt(SYSPROP_TESTMETHOD(), "\"" + description.getMethodName() + "\""); } return appendESProperties(); }
void appendGroupFilteringOptions(ReproduceErrorMessageBuilder builder) { for (TestGroupInfo info : testGroups.values()) { if (System.getProperty(info.sysProperty) != null) { builder.appendOpt(info.sysProperty, System.getProperty(info.sysProperty)); } } if (hasFilteringExpression()) { builder.appendOpt(SysGlobals.SYSPROP_TESTFILTER(), filterExpression); } }