Skip to content

Commit

Permalink
Substantially modernize Helium
Browse files Browse the repository at this point in the history
 * Migrate to Python 3.
 * Fix broken Firefox support.
 * Migrate to Java 1.8.
 * Make the build more cross-platform.
 * Update to the latest web drivers.
  • Loading branch information
mherrmann committed Dec 11, 2019
1 parent 51bfeeb commit ebb1a65
Show file tree
Hide file tree
Showing 147 changed files with 1,145 additions and 6,024 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
target/
.metadata/
.idea/
.DS_Store
.DS_Store
venv/
643 changes: 643 additions & 0 deletions NOTICE.txt

Large diffs are not rendered by default.

57 changes: 0 additions & 57 deletions README.md

This file was deleted.

54 changes: 4 additions & 50 deletions helium-java/build.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,18 @@
from build_impl import unzip_replacing_top_lvl_dir, generate_helium_ini
from glob import glob
from helium.util.path import ensure_exists
from build_impl import unzip_replacing_top_lvl_dir
from helium.util.system import get_canonical_os_name as get_platform, \
is_windows
from os import chmod, listdir
from os.path import join, dirname, splitext, basename
from os import chmod
from os.path import join, dirname
import sys

def generate_resources(project_version, build_type):
_generate_example_run_scripts()
filter_path = '../src/main/filters/filter-%s.properties' % build_type
generate_helium_ini(
project_version, filter_path, _get_target_path('dist-base/runtime')
)

def _generate_example_run_scripts():
examples_dir = _get_proj_path('src/main/resources/base/examples')
for example in listdir(examples_dir):
java_file_path, = glob(_get_proj_path(examples_dir, example, '*.java'))
java_file_name = basename(java_file_path)
dest_dir_win = _get_target_path('dist-win/examples/' + example)
_generate_run_bat(java_file_name, dest_dir_win)
dest_dir_linux = _get_target_path('dist-linux/examples/' + example)
_generate_run_sh(java_file_name, dest_dir_linux)
dest_dir_macosx = _get_target_path('dist-macosx/examples/' + example)
_generate_run_sh(java_file_name, dest_dir_macosx)

def _generate_run_bat(java_file, dest_dir):
ensure_exists(dest_dir)
with open(join(dest_dir, 'run.bat'), 'wb') as run_bat:
run_bat.write(
'javac -cp ".;../../heliumlib/*" %s\r\n'
'java -cp ".;../../heliumlib/*" %s\r\n'
'pause' % (java_file, splitext(java_file)[0])
)

def _generate_run_sh(java_file, dest_dir):
ensure_exists(dest_dir)
with open(join(dest_dir, 'run.sh'), 'wb') as run_sh:
run_sh.write(
'#!/bin/sh\n'
'javac -cp ".:../../heliumlib/*" %s\n'
'java -cp ".:../../heliumlib/*" %s\n'
'read -p "Press Enter to continue..." prompt' % (
java_file, splitext(java_file)[0]
)
)

def pre_integration_test(project_version, artifactFinalName):
zip_file = _get_target_path(
'%s-%s.zip' % (artifactFinalName, get_platform())
)
unzip_replacing_top_lvl_dir(zip_file, _get_target_path('test-dist'))
# we need to change the execution rights to make this work on OSX
if not is_windows():
chmod(_get_target_path('test-dist/webdrivers/chromedriver'), 0755)
filter_path = '../src/systemtest/filters/filter-systemtest.properties'
generate_helium_ini(
project_version, filter_path, _get_target_path('test-dist/runtime')
)
chmod(_get_target_path('test-dist/webdrivers/chromedriver'), 0o755)

def _get_proj_path(*rel_path):
rel_path = '/'.join(rel_path)
Expand Down
89 changes: 4 additions & 85 deletions helium-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
</siteOutputDirectory>
<parentBasedir>${basedir}/..</parentBasedir>
<maven-failsafe-plugin.version>2.16</maven-failsafe-plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<profiles>
<profile>
Expand Down Expand Up @@ -164,10 +166,6 @@
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
</exclusion>
<exclusion>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
Expand Down Expand Up @@ -202,11 +200,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -229,7 +222,7 @@
<!-- Required for our custom HeliumAPIDoclet. -->
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6.0</version>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
Expand Down Expand Up @@ -311,7 +304,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.8.1</version>
<executions>
<execution>
<id>default-testCompile</id>
Expand Down Expand Up @@ -366,26 +359,6 @@
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>generate-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>python</executable>
<workingDirectory>${basedir}</workingDirectory>
<arguments>
<argument>build.py</argument>
<argument>generate_resources</argument>
<argument>${project.version}</argument>
<argument>${buildType}</argument>
</arguments>
<environmentVariables>
<PYTHONPATH>${buildPythonpath}</PYTHONPATH>
</environmentVariables>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
Expand Down Expand Up @@ -437,9 +410,6 @@
${basedir}/src/main/assembly/linux.xml
</descriptor>
</descriptors>
<filters>
<filter>${parentBasedir}/src/main/filters/filter-${buildType}.properties</filter>
</filters>
<outputDirectory>
${project.build.directory}
</outputDirectory>
Expand All @@ -448,57 +418,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<delimiters>
<delimiter>${*}</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
<filters>
<filter>
${parentBasedir}/src/main/filters/filter-${buildType}.properties
</filter>
</filters>
</configuration>
<executions>
<execution>
<id>copy-systest-config</id>
<phase>pre-integration-test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/test-dist
</outputDirectory>
<resources>
<resource>
<directory>${parentBasedir}/src/systemtest/resources</directory>
<includes>
<include>Helium_unreachable_server.ini</include>
<include>Helium_future_build.ini</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>${parentBasedir}/src/systemtest/resources</directory>
<includes>
<include>license.key</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<filters>
<filter>
${parentBasedir}/src/systemtest/filters/filter-systemtest.properties
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ else if (testBrowserName.equals("ie")) {
return startIE(url);
} else {
assert testBrowserName.equals("firefox");
return startFirefox(url);
return startFirefox(url, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assume.assumeThat;

/**
* This test fails when run from PyCharm. The reason for this is that
* silent-chromedriver.exe assigns its subprocess chromedriver.exe to a Job
* Object via AssignProcessToJobObject in silent-chromedriver.cpp. This fails
* with error code 5 (access denied) when we run from PyCharm. On the command
* line (`mvn verify`) however, it works. It seems to be common that
* AssignProcessToJobObject fails depending on the process' environment. See:
* http://stackoverflow.com/questions/89588/assignprocesstojobobject-fails-
* with-access-denied-error-when-running-under-the
*/
@Ignore("Fails on recent versions of Chrome")
public class KillServiceAtExitChromeIT extends KillServiceAtExitAT {

Expand All @@ -34,7 +24,7 @@ public void testKillServiceAtExit() throws IOException,

protected List<String> getServiceProcessNames() {
if (isWindows())
return asList("silent-chromedriver.exe", "chromedriver.exe");
return asList("chromedriver.exe");
return asList("chromedriver");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void testWaitUntilTextExists() {
long startTime = System.currentTimeMillis();
waitUntil(Text("Success!").exists);
long endTime = System.currentTimeMillis();
assertThat(endTime - startTime, is(greaterThan(900L)));
assertThat(endTime - startTime, is(greaterThan(800L)));
}

@Test
Expand All @@ -35,7 +35,7 @@ public void testWaitUntilPresenceOfElementLocated() {
long startTime = System.currentTimeMillis();
waitUntil(presenceOfElementLocated(By.id("result")));
long endTime = System.currentTimeMillis();
assertThat(endTime - startTime, is(greaterThan(900L)));
assertThat(endTime - startTime, is(greaterThan(800L)));
}

@Test(expected = TimeoutException.class)
Expand Down
37 changes: 0 additions & 37 deletions helium-java/src/main/assembly/linux.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,7 @@
<format>zip</format>
</formats>
<baseDirectory>${project.artifactId}-${project.version}</baseDirectory>
<files>
<file>
<source>${basedir}/src/main/resources/base/license.txt</source>
<outputDirectory>.</outputDirectory>
<filtered>true</filtered>
</file>
</files>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/resources/base</directory>
<excludes>
<exclude>license.txt</exclude>
</excludes>
<outputDirectory>.</outputDirectory>
</fileSet>
<fileSet>
<directory>${basedir}/src/main/resources/linux</directory>
<includes>
<include>**/*.sh</include>
</includes>
<outputDirectory>.</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>${parentBasedir}/src/main/resources/linux</directory>
<includes>
Expand All @@ -39,25 +17,10 @@
<outputDirectory>.</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}/dist-linux</directory>
<outputDirectory>.</outputDirectory>
<includes>
<include>**/*.sh</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}/dist-base</directory>
<outputDirectory>.</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.directory}/dist-linux</directory>
<outputDirectory>.</outputDirectory>
<excludes>
<exclude>**/*.sh</exclude>
</excludes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
Expand Down
Loading

0 comments on commit ebb1a65

Please sign in to comment.