From ba5998f74ec7399b429008cf8f2bb2f4a0bfb652 Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Wed, 5 Feb 2014 23:08:41 +0000 Subject: [PATCH] Making GhostDriver test "quiet-er" (and parallel) Also, trying to get the exit status of those tests reported, in case they fail. Related to #11952. --- .gitignore | 1 + .travis.yml | 4 ++-- src/ghostdriver/lastupdate | 11 ++++----- test/ghostdriver-test/java/build.gradle | 7 +++--- .../java/ghostdriver/ElementMethodsTest.java | 21 ----------------- .../java/ghostdriver/ScriptExecutionTest.java | 1 + .../server/GetFixtureHttpRequestCallback.java | 23 +++++++++++-------- .../run-tests-ghostdriver.sh | 6 ++++- 8 files changed, 30 insertions(+), 44 deletions(-) rename test-ghostdriver.sh => test/run-tests-ghostdriver.sh (70%) diff --git a/.gitignore b/.gitignore index 82ee57e0..2f671637 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,4 @@ tools/dump_syms.app/ bin/ *.class build/ +.gradle/ diff --git a/.travis.yml b/.travis.yml index 34b1c199..5715c3fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ install: - sudo apt-get -yq install build-essential chrpath libssl-dev libfontconfig1-dev #< Build Dependencies before_script: - chmod +x ./build.sh - - chmod +x ./test-ghostdriver.sh + - chmod +x ./test/run-tests-ghostdriver.sh script: - ./build.sh --confirm --silent #< Build - - ./test-ghostdriver.sh #< Test (GhostDriver / PhantomJSDriver) + - ./test/run-tests-ghostdriver.sh #< Test (GhostDriver / PhantomJSDriver) diff --git a/src/ghostdriver/lastupdate b/src/ghostdriver/lastupdate index f60c9bd9..5c6de618 100644 --- a/src/ghostdriver/lastupdate +++ b/src/ghostdriver/lastupdate @@ -1,10 +1,7 @@ -2014-02-04 23:18:11 +2014-02-12 23:42:59 -commit c85f27f06cf23d8ef783c6c9afe54b2975f59249 (HEAD, refs/heads/master) +commit 2af7099a9f5cf683ff565617be38b70318c9203f (HEAD, refs/remotes/origin/master, refs/remotes/origin/HEAD, refs/heads/master) Author: Ivan De Marino -Date: Tue Feb 4 22:27:45 2014 +0000 +Date: Wed Feb 12 23:42:43 2014 +0000 - Moving "test fixtures" into "fixtures" directory. - - Also, removing Python tests: never used and extremely limited. - The Selenium PhantomJSDriver maintainer for Python has its own tests. + Removing flaky (and pointless) test diff --git a/test/ghostdriver-test/java/build.gradle b/test/ghostdriver-test/java/build.gradle index 8adc989d..be11c3d9 100644 --- a/test/ghostdriver-test/java/build.gradle +++ b/test/ghostdriver-test/java/build.gradle @@ -35,8 +35,9 @@ tasks.withType(JavaExec) { } test { - // Listening to test execution events - beforeTest { descriptor -> - logger.lifecycle("Running " + descriptor) + maxParallelForks = 3 + + afterTest { descriptor, result -> + logger.quiet(result.toString() + " for " + descriptor + " in " + descriptor.getParent()) } } diff --git a/test/ghostdriver-test/java/src/test/java/ghostdriver/ElementMethodsTest.java b/test/ghostdriver-test/java/src/test/java/ghostdriver/ElementMethodsTest.java index cbb8cb94..5908881b 100644 --- a/test/ghostdriver-test/java/src/test/java/ghostdriver/ElementMethodsTest.java +++ b/test/ghostdriver-test/java/src/test/java/ghostdriver/ElementMethodsTest.java @@ -38,7 +38,6 @@ import org.openqa.selenium.support.ui.WebDriverWait; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -241,24 +240,4 @@ public class ElementMethodsTest extends BaseTestWithServer { assertTrue(d.getTitle().contains(inputString)); } - - @Test - public void shouldUsePageTimeoutToWaitForPageLoadOnInput_negativeCase() throws InterruptedException { - WebDriver d = getDriver(); - String inputString = "clicking"; - - d.get("http://www.duckduckgo.com"); - WebElement textInput = d.findElement(By.cssSelector("#search_form_input_homepage")); - - assertFalse(d.getTitle().contains(inputString)); - textInput.click(); - assertFalse(d.getTitle().contains(inputString)); - - // Set Implicit Timeout to 0: this will force Driver to NOT wait - d.manage().timeouts().pageLoadTimeout(0, TimeUnit.MILLISECONDS); - // This input will ALSO submit the search form, causing a Page Load - textInput.sendKeys(inputString + "\n"); - - assertFalse(d.getTitle().contains(inputString)); - } } diff --git a/test/ghostdriver-test/java/src/test/java/ghostdriver/ScriptExecutionTest.java b/test/ghostdriver-test/java/src/test/java/ghostdriver/ScriptExecutionTest.java index fe38cbbd..2ecd30ba 100644 --- a/test/ghostdriver-test/java/src/test/java/ghostdriver/ScriptExecutionTest.java +++ b/test/ghostdriver-test/java/src/test/java/ghostdriver/ScriptExecutionTest.java @@ -89,6 +89,7 @@ public class ScriptExecutionTest extends BaseTest { assertEquals("abc", stringResult); } + @Ignore("Known issue #140 - see https://github.com/detro/ghostdriver/issues/140)") @Test public void shouldBeAbleToExecuteMultipleAsyncScriptsSequentiallyWithNavigation() { // NOTE: This test is supposed to fail! diff --git a/test/ghostdriver-test/java/src/test/java/ghostdriver/server/GetFixtureHttpRequestCallback.java b/test/ghostdriver-test/java/src/test/java/ghostdriver/server/GetFixtureHttpRequestCallback.java index 17121caf..29cc9f4f 100644 --- a/test/ghostdriver-test/java/src/test/java/ghostdriver/server/GetFixtureHttpRequestCallback.java +++ b/test/ghostdriver-test/java/src/test/java/ghostdriver/server/GetFixtureHttpRequestCallback.java @@ -7,35 +7,38 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; +import java.util.logging.Logger; public class GetFixtureHttpRequestCallback implements HttpRequestCallback { - private static final String FIXTURE_PATH = "fixtures"; + private static final Logger LOG = Logger.getLogger(GetFixtureHttpRequestCallback.class.getName()); + + private static final String FIXTURE_PATH = "../fixtures"; @Override public void call(HttpServletRequest req, HttpServletResponse res) throws IOException { - String path = req.getPathInfo(); + // Construct path to the file + Path filePath = FileSystems.getDefault().getPath(FIXTURE_PATH, req.getPathInfo()); - if (null != path) { + // If the file exists + if (filePath.toFile().exists()) { try { - // Construct path to the file - Path filePath = FileSystems.getDefault().getPath(FIXTURE_PATH, path); // Set Content Type res.setContentType(filePathToMimeType(filePath.toString())); // Read and write to response Files.copy(filePath, res.getOutputStream()); return; - } catch (RuntimeException re) { - // Not Found. Handled below. } catch (NoSuchFileException nsfe) { - // Not Found. Handled below. + LOG.warning(nsfe.getClass().getName()); } catch (IOException ioe) { - // Not Found. Handled below. + LOG.warning(ioe.getClass().getName()); + } catch (RuntimeException re) { + LOG.warning(re.getClass().getName()); } } - System.out.println("Fixture NOT FOUND"); + LOG.warning("Fixture NOT FOUND: "+filePath); res.sendError(404); //< Not Found } diff --git a/test-ghostdriver.sh b/test/run-tests-ghostdriver.sh similarity index 70% rename from test-ghostdriver.sh rename to test/run-tests-ghostdriver.sh index cc6dd7d8..8b4a937a 100755 --- a/test-ghostdriver.sh +++ b/test/run-tests-ghostdriver.sh @@ -7,7 +7,11 @@ pushd ./test/ghostdriver-test/java chmod +x ./gradlew # Run tests -./gradlew test +./gradlew test -q +# Grab exit status +TEST_EXIT_STATUS=$? # Return to starting directory popd + +exit $TEST_EXIT_STATUS