Skip to content

Commit

Permalink
Legacy trashing (#5)
Browse files Browse the repository at this point in the history
* trashing some of the legacy code, extending readme and overall polishing

* moving mkdir outside of if statements in case the user want to use a folder that does not exist yet (adoptium)

* JRESDK -> JREJDK change in yaml file

---------

Co-authored-by: jandrlik <[email protected]>
  • Loading branch information
andrlos and jandrlik authored Feb 21, 2024
1 parent 7d5dd7a commit 236937b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 46 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
java-version: ${{ matrix.jdkver || env.jdkver_latest }}
- name: Run
run: |
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JRESDK="jdk"
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JREJDK="jdk"
./testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
java-version: ${{ matrix.jdkver || env.jdkver_latest }}
- name: Run
run: |
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JRESDK="jre"
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JREJDK="jre"
./testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
- name: Run
shell: msys2 {0}
run: |
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JRESDK="jre"
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JREJDK="jre"
./testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
- name: Run
shell: msys2 {0}
run: |
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JRESDK="jre"
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JREJDK="jre"
./testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
Expand Down Expand Up @@ -230,7 +230,7 @@ jobs:
java-version: ${{ matrix.jdkver || env.jdkver_latest }}
- name: Run
run: |
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JRESDK="jre" WORKSPACE=/Users/runner/workspace
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JREJDK="jre" WORKSPACE=/Users/runner/workspace
/usr/local/bin/bash testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
Expand Down Expand Up @@ -288,7 +288,7 @@ jobs:
java-version: ${{ matrix.jdkver || env.jdkver_latest }}
- name: Run
run: |
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JRESDK="jdk" WORKSPACE=/Users/runner/workspace
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JREJDK="jdk" WORKSPACE=/Users/runner/workspace
/usr/local/bin/bash testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# TestHeadlessComponents
Test of correct behavior of swing components in a headless jre environment.

## Running TestHeadlessComponents locally

### Setting up the environment:
Nothing special is required, just install the java package or unpack the portable you want the test.

### ENV variables:
The test utilizes *JAVA_HOME variable, so if it is not set it will not work correctly! In case of testing portable packages please set it up first.
BOOTJDK_DIR - directory to store bootjdk which is used to compile the code in case we are testing jre only installation. Uses ~/bootjdk by default and uses Adoptium latest build of relevant jdk for this purpose.
BOOTJDK_ARCHIVE_DIR - In case the user wants to use arbitrary jdk build, he can provide path to its archive's dir and it will be used in jre execution.. Creates and downloads to $WORKSPACE/bootjdkarchive if unset.
WORKSPACE - directory where the testsuite is going to execute all the tests. ~/workspace by default
TMPRESULTS - this is a location where the logfiles will be after the testsuite finishes. Same as WORKSPACE by default.
*JREJDK - This tells the testsuite whether we are testing jre or jdk.
ARCH - architecture of our system. The suite detects this automatically if left blank.
*OJDK_VERSION_NUMBER - number of jdk we are testing - this is used for downloading corresponding JDK from adoptium site.

Variables marked with "*" are mandatory and the testsuite wont run without them.

### Executing the testsuite

Now it is as simple as running bash script testHeadlessComponents.sh.
27 changes: 0 additions & 27 deletions genericRunner.sh

This file was deleted.

22 changes: 9 additions & 13 deletions testHeadlessComponents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ function installAlternativeJDK() {
if [ "x$BOOTJDK_DIR" == "x" ]; then
BOOTJDK_DIR=~/bootjdk
fi
if [ ! "x$ALTERNATE_BOOT_JDK" == "x" ] ; then
ALTERNATIVE_JDK_DIR=$ALTERNATE_BOOT_JDK
return 0
fi
if [ "x$BOOTJDK_ARCHIVE_DIR" == "x" ]; then
BOOTJDK_ARCHIVE_DIR=$WORKSPACE/bootjdkarchive
mkdir -p $BOOTJDK_ARCHIVE_DIR
Expand All @@ -84,7 +80,7 @@ function installAlternativeJDK() {

function run_java_with_headless {
COMPONENTS_TO_TEST=$2
$JAVA -cp $cp -Djava.awt.headless=$1 MainRunner -test=$COMPONENTS_TO_TEST -jreSdkHeadless=$JRESDK -displayValue=$DISPLAY
$JAVA -cp $cp -Djava.awt.headless=$1 MainRunner -test=$COMPONENTS_TO_TEST -jreSdkHeadless=$JREJDK -displayValue=$DISPLAY
}

function run_swing_component_test_unset {
Expand Down Expand Up @@ -153,14 +149,16 @@ source ${RFaT}/jtreg-shell-xml.sh

if [[ -z "${WORKSPACE}" ]]; then
WORKSPACE=~/workspace
mkdir -p $WORKSPACE
fi

mkdir -p $WORKSPACE

if [ "x$TMPRESULTS" == "x" ]; then
TMPRESULTS=$WORKSPACE
mkdir -p $TMPRESULTS
fi

mkdir -p $TMPRESULTS

touch $TMPRESULTS/testHeadlessComponent.txt


Expand Down Expand Up @@ -189,26 +187,24 @@ $JAVAC_BINARY `find . -type f -name "*.java"` -d $cp
declare -A resArray
set +e

if [[ -z "${OTOOL_ARCH}" ]] ; then
if [[ -z "${ARCH}" ]] ; then
RUN_ARCH=$(uname -m)
else
RUN_ARCH=$OTOOL_ARCH
fi

for testOption in compatible incompatible; do
for headless in true false; do
if [[ "$JRESDK" == "jre" || "$JRESDK" == "jdk" && (("${testOption}${headless}" == "compatibletrue") || ("${testOption}${headless}" == "incompatiblefalse")) ]] ; then
if [[ "$JREJDK" == "jre" || "$JREJDK" == "jdk" && (("${testOption}${headless}" == "compatibletrue") || ("${testOption}${headless}" == "incompatiblefalse")) ]] ; then
run_swing_component_test_unset ${testOption} ${headless} >> $LOGFILE 2>&1
resArray["jre_headless_${testOption}_${headless}_display_unset"]=$?
fi

if [[ "x$XDISPLAY" == *x* ]] ; then
if [[ "x$XDISPLAY" == "x" ]] ; then
echo "skipping tests with display set, as the default display was not defined"
else
run_swing_component_test_set ${testOption} ${headless} >> $LOGFILE 2>&1
resArray["jre_headless_${testOption}_${headless}_display_set"]=$?
fi
if [[ "$JRESDK" == "jre" || "$JRESDK" == "jdk" && (("${testOption}${headless}" == "compatibletrue") || ("${testOption}${headless}" == "incompatiblefalse")) ]] ; then
if [[ "$JREJDK" == "jre" || "$JREJDK" == "jdk" && (("${testOption}${headless}" == "compatibletrue") || ("${testOption}${headless}" == "incompatiblefalse")) ]] ; then
run_swing_component_test_fake ${testOption} ${headless} >> $LOGFILE 2>&1
resArray["jre_headless_${testOption}_${headless}_display_fake"]=$?
fi
Expand Down

0 comments on commit 236937b

Please sign in to comment.