Skip to content

Commit

Permalink
Implementing ability to link tests to github issues. The test is igno…
Browse files Browse the repository at this point in the history
…red while the issue is open.
  • Loading branch information
barancev committed Apr 6, 2017
1 parent a0f75c2 commit 238621b
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 9 deletions.
11 changes: 11 additions & 0 deletions .idea/libraries/github.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions java/client/client.iml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<orderEntry type="library" name="commons-httpclient" level="project" />
<orderEntry type="library" scope="TEST" name="websocket" level="project" />
<orderEntry type="library" scope="TEST" name="jetty-util" level="project" />
<orderEntry type="library" scope="TEST" name="github" level="project" />
</component>
<component name="sonarModuleSettings">
<option name="alternativeWorkingDirPath" value="" />
Expand Down
2 changes: 1 addition & 1 deletion java/client/test/org/openqa/selenium/AlertsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void testShouldAllowAUserToSetTheValueOfAPrompt() {
@JavascriptEnabled
@Test
@Ignore(CHROME)
@Ignore(value = MARIONETTE, reason = "https://github.com/mozilla/geckodriver/issues/274")
@Ignore(value = MARIONETTE, issue = "https://github.com/mozilla/geckodriver/issues/274")
public void testSettingTheValueOfAnAlertThrows() {
driver.findElement(By.id("alert")).click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public void testCookieEqualityAfterSetAndGet() {
}

@Test
@Ignore(value = MARIONETTE, reason = "https://github.com/mozilla/geckodriver/issues/463")
@Ignore(value = MARIONETTE, issue = "https://github.com/mozilla/geckodriver/issues/463")
public void testRetainsCookieExpiry() {
Cookie addedCookie =
new Cookie.Builder("fish", "cod")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void testElementsShouldBeDisabledIfTheyAreDisabledUsingRandomDisabledStri
}

@Test
@Ignore(value = MARIONETTE, reason = "sendKeys does not determine whether the element is disabled")
@Ignore(value = MARIONETTE, issue = "https://github.com/mozilla/geckodriver/issues/579")
public void testShouldThrowExceptionIfSendingKeysToElementDisabledUsingRandomDisabledStrings() {
driver.get(pages.formPage);
WebElement disabledTextElement1 = driver.findElement(By.id("disabledTextElement1"));
Expand Down
4 changes: 2 additions & 2 deletions java/client/test/org/openqa/selenium/VisibilityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void testHiddenInputElementsAreNeverVisible() {
}

@Test
@Ignore(value = MARIONETTE, reason = "https://github.com/mozilla/geckodriver/issues/579")
@Ignore(value = MARIONETTE, issue = "https://github.com/mozilla/geckodriver/issues/579")
public void testShouldNotBeAbleToClickOnAnElementThatIsNotDisplayed() {
driver.get(pages.javascriptPage);
WebElement element = driver.findElement(By.id("unclickable"));
Expand All @@ -112,7 +112,7 @@ public void testShouldNotBeAbleToClickOnAnElementThatIsNotDisplayed() {
}

@Test
@Ignore(value = MARIONETTE, reason = "https://github.com/mozilla/geckodriver/issues/579")
@Ignore(value = MARIONETTE, issue = "https://github.com/mozilla/geckodriver/issues/579")
public void testShouldNotBeAbleToTypeToAnElementThatIsNotDisplayed() {
driver.get(pages.javascriptPage);
WebElement element = driver.findElement(By.id("unclickable"));
Expand Down
1 change: 1 addition & 0 deletions java/client/test/org/openqa/selenium/testing/drivers/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ java_library(name = 'drivers',
'//java/client/test/org/openqa/selenium/testing:annotations',
'//java/client/test/org/openqa/selenium/testing:helpers',
'//java/server/src/org/openqa/grid/selenium:selenium',
'//third_party/java/github:github',
'//third_party/java/guava:guava',
'//third_party/java/junit:junit',
'//third_party/java/phantomjs-driver:phantomjs-driver',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@

import com.google.common.collect.Sets;

import org.eclipse.egit.github.core.Issue;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.client.GitHubClient;
import org.eclipse.egit.github.core.service.IssueService;
import org.eclipse.egit.github.core.service.RepositoryService;
import org.openqa.selenium.Platform;
import org.openqa.selenium.testing.Driver;
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.IgnoreList;

import java.io.IOException;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class IgnoreComparator {
Expand All @@ -51,12 +59,44 @@ public boolean shouldIgnore(Ignore ignore) {
}

private boolean shouldIgnore(Stream<Ignore> ignoreList) {
return ignoreList.anyMatch(
driver -> (ignored.contains(driver.value()) || driver.value() == Driver.ALL)
&& (driver.travis() && isOnTravis()));
return ignoreList.anyMatch(driver ->
(ignored.contains(driver.value()) || driver.value() == Driver.ALL)
&& (!driver.travis() || isOnTravis())
&& isOpen(driver.issue()));
}

private boolean isOnTravis() {
return Boolean.valueOf(System.getenv().getOrDefault("TRAVIS", "false"));
}

private boolean isOpen(String issue) {
if ("".equals(issue)) {
return true; // unknown issue, suppose it's open
}
Matcher m = Pattern.compile("#?(\\d+)").matcher(issue);
if (m.matches()) {
return isOpenGitHubIssue("SeleniumHQ", "selenium", m.group(1));
}
m = Pattern.compile("https?://github.com/(\\w+)/(\\w+)/issues/(\\d+)").matcher(issue);
if (m.matches()) {
return isOpenGitHubIssue(m.group(1), m.group(2), m.group(3));
}
return true; // unknown issue, suppose it's open
}

private boolean isOpenGitHubIssue(String owner, String repo, String issueId) {
String gitHubToken = System.getenv("GITHUB_TOKEN");
if (gitHubToken == null) {
return true;
}
IssueService service = new IssueService();
service.getClient().setOAuth2Token(gitHubToken);
try {
Issue issue = service.getIssue(owner, repo, issueId);
return "open".equals(issue.getState());
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
}
2 changes: 1 addition & 1 deletion java/server/server.iml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/production" />
<output-test url="file://$MODULE_DIR$/build/test" />
<exclude-output />
Expand Down
13 changes: 13 additions & 0 deletions third_party/java/github/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
prebuilt_jar(
name = 'github',
maven_coords = 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5',
binary_jar = 'org.eclipse.egit.github.core-2.1.5.jar',
source_jar = 'org.eclipse.egit.github.core-2.1.5-sources.jar',
deps = [
'//third_party/java/gson:gson',
],
visibility = [
'//java/client/test/...',
'//java/server/test/...',
],
)
Binary file not shown.
Binary file not shown.

0 comments on commit 238621b

Please sign in to comment.