Skip to content

Commit

Permalink
Refine slot matchers; fix README version updater (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbabcoc authored Sep 30, 2024
1 parent a61215d commit d9e9eca
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ test {

scmVersion {
hooks {
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(<version>)\d+\.\d+\.\d+(-s[23]<\/version>)/}, replacement: {v, p -> "\$1$v\$2"}]
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(selenium-foundation:)\d+\.\d+\.\d+(-s[23])/}, replacement: {v, p -> "\$1$v\$2"}]
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(<version>)\d+\.\d+\.\d+(-s[34]<\/version>)/}, replacement: {v, p -> "\$1$v\$2"}]
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(selenium-foundation:)\d+\.\d+\.\d+(-s[34])/}, replacement: {v, p -> "\$1$v\$2"}]
pre 'commit'
post 'push'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ public Boolean apply(Map<String, Object> providedCapabilities, Map<String, Objec
}
}

class BrowserVersionValidator implements Validator {
@Override
public Boolean apply(Map<String, Object> providedCapabilities, Map<String, Object> requestedCapabilities) {
if ("htmlunit".equals(requestedCapabilities.get(BROWSER_NAME))) {
return true;
}

Object requested = Optional.ofNullable(requestedCapabilities.get(CapabilityType.BROWSER_VERSION))
.orElse(requestedCapabilities.get(CapabilityType.VERSION));
if (anything(requested)) {
return true;
}
Object provided = Optional.ofNullable(providedCapabilities.get(CapabilityType.BROWSER_VERSION))
.orElse(providedCapabilities.get(CapabilityType.VERSION));
Platform requestedPlatform = extractPlatform(requested);
if (requestedPlatform != null) {
Platform providedPlatform = extractPlatform(provided);
return providedPlatform != null && providedPlatform.is(requestedPlatform);
}

return provided != null && Objects.equals(requested.toString(), provided.toString());
}
}

class SimplePropertyValidator implements Validator {
private List<String> toConsider;

Expand Down Expand Up @@ -168,9 +192,8 @@ private boolean getUseTechnologyPreview(Map<String, Object> capabilities) {
private final List<Validator> validators = new ArrayList<>();
{
validators.addAll(Arrays.asList(new PlatformValidator(), new AliasedPropertyValidator(BROWSER_NAME, "browser"),
new AliasedPropertyValidator(CapabilityType.BROWSER_VERSION, CapabilityType.VERSION),
new SimplePropertyValidator(CapabilityType.APPLICATION_NAME), new FirefoxSpecificValidator(),
new SafariSpecificValidator()));
new BrowserVersionValidator(), new SimplePropertyValidator(CapabilityType.APPLICATION_NAME),
new FirefoxSpecificValidator(), new SafariSpecificValidator()));
}

public void addToConsider(String capabilityName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public boolean matches(Capabilities stereotype, Capabilities capabilities) {
|| capabilities.getBrowserVersion().isEmpty()
|| Objects.equals(capabilities.getBrowserVersion(), "stable")
|| Objects.equals(stereotype.getBrowserVersion(), capabilities.getBrowserVersion());
boolean platformNameMatch = Browser.HTMLUNIT.is(capabilities)
|| capabilities.getPlatformName() == null
boolean platformNameMatch = capabilities.getPlatformName() == null
|| Objects.equals(stereotype.getPlatformName(), capabilities.getPlatformName())
|| (stereotype.getPlatformName() != null
&& stereotype.getPlatformName().is(capabilities.getPlatformName()));
Expand Down

0 comments on commit d9e9eca

Please sign in to comment.