Skip to content

Commit

Permalink
multiplatforming testsuite (#4)
Browse files Browse the repository at this point in the history
ensuring that the testsuite runs on both windows and macos as well
  • Loading branch information
andrlos authored Nov 27, 2023
1 parent f218afe commit 7d5dd7a
Show file tree
Hide file tree
Showing 2 changed files with 274 additions and 20 deletions.
227 changes: 219 additions & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ env:
WORKSPACE: /home/runner/workspace

jobs:
test-temurin-sdk:
name: "Temurin jdk"
test-linux-sdk:
name: "Linux jdk"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
Expand Down Expand Up @@ -44,16 +44,16 @@ jobs:
- name: Pack results
if: ${{ always() }}
run: |
tar -cf "results-jdk${{ matrix.jdkver || env.jdkver_latest }}.tar.gz" $WORKSPACE/testHeadlessComponent.log $WORKSPACE/testHeadlessComponent.jtr.xml
tar -cf "results-linux-jdk${{ matrix.jdkver || env.jdkver_latest }}.tar.gz" $WORKSPACE/testHeadlessComponent.log $WORKSPACE/testHeadlessComponent.jtr.xml
- name: Upload results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
path: "results-jdk${{ matrix.jdkver || env.jdkver_latest }}.tar.gz"
path: "results-linux-jdk${{ matrix.jdkver || env.jdkver_latest }}.tar.gz"
continue-on-error: true

test-temurin-jre:
name: "Temurin jre"
test-linux-jre:
name: "Linux jre"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
Expand Down Expand Up @@ -84,11 +84,222 @@ jobs:
- name: Pack results
if: ${{ always() }}
run: |
tar -cf "results-jre${{ matrix.jdkver || env.jdkver_latest }}.tar.gz" $WORKSPACE/testHeadlessComponent.log $WORKSPACE/testHeadlessComponent.jtr.xml
tar -cf "results-linux-jre${{ matrix.jdkver || env.jdkver_latest }}.tar.gz" $WORKSPACE/testHeadlessComponent.log $WORKSPACE/testHeadlessComponent.jtr.xml
- name: Upload results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
path: "results-jre${{ matrix.jdkver || env.jdkver_latest }}.tar.gz"
path: "results-linux-jre${{ matrix.jdkver || env.jdkver_latest }}.tar.gz"
continue-on-error: true

test-windows-jre:
name: "Windows-jre"
runs-on: "windows-latest"
strategy:
fail-fast: false
matrix:
jdkconf:
- JDK 8
- JDK 11
- JDK 17
- JDK Latest
include:
- jdkconf: JDK 8
jdkver: "8"
- jdkconf: JDK 11
jdkver: "11"
- jdkconf: JDK 17
jdkver: "17"
steps:
- uses: actions/checkout@v3
- uses: msys2/setup-msys2@v2
with:
update: true
install: wget tar git unzip

- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.jdkver || env.jdkver_latest }}
- name: Run
shell: msys2 {0}
run: |
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JRESDK="jre"
./testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
shell: msys2 {0}
run: |
tar -cf "results-windows-jre${{ matrix.jdkver || env.jdkver_latest }}.tar.gz" $WORKSPACE/testHeadlessComponent.log $WORKSPACE/testHeadlessComponent.jtr.xml
- name: Upload results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
path: "results-windows-jre${{ matrix.jdkver || env.jdkver_latest }}.tar.gz"
continue-on-error: true

test-windows-jdk:
name: "Windows-jdk"
runs-on: "windows-latest"
strategy:
fail-fast: false
matrix:
jdkconf:
- JDK 8
- JDK 11
- JDK 17
- JDK Latest
include:
- jdkconf: JDK 8
jdkver: "8"
- jdkconf: JDK 11
jdkver: "11"
- jdkconf: JDK 17
jdkver: "17"
steps:
- uses: actions/checkout@v3
- uses: msys2/setup-msys2@v2
with:
update: true
install: wget tar git unzip

- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.jdkver || env.jdkver_latest }}
- name: Run
shell: msys2 {0}
run: |
export OJDK_VERSION_NUMBER=${{ matrix.jdkver || env.jdkver_latest }} BOOTJDK_DIR=~/bootjdk JRESDK="jre"
./testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
shell: msys2 {0}
run: |
tar -cf "results-windows-jdk${{ matrix.jdkver || env.jdkver_latest }}.tar.gz" $WORKSPACE/testHeadlessComponent.log $WORKSPACE/testHeadlessComponent.jtr.xml
- name: Upload results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
path: "results-windows-jdk${{ matrix.jdkver || env.jdkver_latest }}.tar.gz"
continue-on-error: true

test-macos-jre:
name: "MacOS-jre"
runs-on: "macos-latest"
strategy:
fail-fast: false
matrix:
jdkconf:
- JDK 8
- JDK 11
- JDK 17
- JDK Latest
include:
- jdkconf: JDK 8
jdkver: "8"
- jdkconf: JDK 11
jdkver: "11"
- jdkconf: JDK 17
jdkver: "17"
steps:
- uses: actions/checkout@v3
- name: Install Homebrew
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval $(/usr/local/bin/brew shellenv)' >> $HOME/.zprofile
eval $(/usr/local/bin/brew shellenv)
- name: Install Bash with Homebrew
run: brew install bash

- name: Update Shell Configuration
run: echo 'export PATH="/usr/local/bin:$PATH"' >> $HOME/.zprofile && exec -l $SHELL

- name: Verify Bash Version
run: /usr/local/bin/bash --version

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
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
/usr/local/bin/bash testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
run: |
export WORKSPACE=/Users/runner/workspace
tar -cf "results-macos-jre${{ matrix.jdkver || env.jdkver_latest }}.tar.gz" $WORKSPACE/testHeadlessComponent.log $WORKSPACE/testHeadlessComponent.jtr.xml
- name: Upload results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
path: "results-macos-jre${{ matrix.jdkver || env.jdkver_latest }}.tar.gz"
continue-on-error: true

test-macos-jdk:
name: "MacOS-jdk"
runs-on: "macos-latest"
env:
WORKSPACE: /home/runner/workspace
strategy:
fail-fast: false
matrix:
jdkconf:
- JDK 8
- JDK 11
- JDK 17
- JDK Latest
include:
- jdkconf: JDK 8
jdkver: "8"
- jdkconf: JDK 11
jdkver: "11"
- jdkconf: JDK 17
jdkver: "17"
steps:
- uses: actions/checkout@v3
- name: Install Homebrew
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval $(/usr/local/bin/brew shellenv)' >> $HOME/.zprofile
eval $(/usr/local/bin/brew shellenv)
- name: Install Bash with Homebrew
run: brew install bash

- name: Update Shell Configuration
run: echo 'export PATH="/usr/local/bin:$PATH"' >> $HOME/.zprofile && exec -l $SHELL

- name: Verify Bash Version
run: /usr/local/bin/bash --version

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
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
/usr/local/bin/bash testHeadlessComponents.sh
- name: Pack results
if: ${{ always() }}
run: |
export WORKSPACE=/Users/runner/workspace
tar -cf "results-macos-jdk${{ matrix.jdkver || env.jdkver_latest }}.tar.gz" $WORKSPACE/testHeadlessComponent.log $WORKSPACE/testHeadlessComponent.jtr.xml
- name: Upload results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
path: "results-macos-jdk${{ matrix.jdkver || env.jdkver_latest }}.tar.gz"
continue-on-error: true


67 changes: 55 additions & 12 deletions testHeadlessComponents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,44 @@ while [ -h "$SCRIPT_SOURCE" ]; do # resolve $SOURCE until the file is no longer
done
readonly SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"

# detecting platform
platform="$(uname)"
if [ "$platform" == "Linux" ]; then
# Linux-specific code
OS="linux"
JAVA=$JAVA_HOME/bin/java
elif [ "$platform" == "Darwin" ]; then
# Mac-specific code
OS="mac"
JAVA=$JAVA_HOME/bin/java
#JAVA=java
elif [ "${platform#"MINGW64_NT"}" != "$platform" ]; then
# Windows (Cygwin) specific code
OS="windows"
JAVA=$JAVA_HOME/bin/java
else
echo "Unsupported platform"
exit 1
fi

function unwrap_file_to_location() {
if [ "$OS" == "mac" -o "$OS" == "linux" ]; then
tar --strip-components=1 -xf $1 -C $2
elif [ "$OS" == "windows" ]; then
unzip $1 -d $2
# Get the name of the extracted folder (assuming only one folder is present)
ls $2
extracted_folder_name=$(ls $2)

# Ensure only one folder is found
if [ "$(ls $2 | wc -l)" -eq 1 ]; then
# Move the contents to the desired destination without creating a new directory
mv "$2/$extracted_folder_name"/* "$2"
else
echo "Error: More than one directory found in $2."
fi
fi
}

function installAlternativeJDK() {
ARCH=$( uname -m )
Expand All @@ -32,21 +70,21 @@ function installAlternativeJDK() {
BOOTJDK_ARCHIVE_DIR=$WORKSPACE/bootjdkarchive
mkdir -p $BOOTJDK_ARCHIVE_DIR
cd $BOOTJDK_ARCHIVE_DIR
curl -OLJks "https://api.adoptopenjdk.net/v3/binary/latest/$OJDK_VERSION_NUMBER/ga/linux/$ARCH/jdk/hotspot/normal/adoptopenjdk"
curl -OLJks "https://api.adoptopenjdk.net/v3/binary/latest/$OJDK_VERSION_NUMBER/ga/$OS/$ARCH/jdk/hotspot/normal/adoptopenjdk"
rm -rf ${BOOTJDK_DIR}
mkdir -p ${BOOTJDK_DIR}
tar --strip-components=1 -xf ${BOOTJDK_ARCHIVE_DIR}/*.tar.gz -C ${BOOTJDK_DIR}
unwrap_file_to_location ${BOOTJDK_ARCHIVE_DIR}/* ${BOOTJDK_DIR}
else
rm -rf ${BOOTJDK_DIR}
mkdir -p ${BOOTJDK_DIR}
ls ${BOOTJDK_ARCHIVE_DIR}
tar --strip-components=1 -xf ${BOOTJDK_ARCHIVE_DIR}/*${ARCH}.tarxz -C ${BOOTJDK_DIR}
unwrap_file_to_location ${BOOTJDK_ARCHIVE_DIR}/*${ARCH}.tarxz ${BOOTJDK_DIR}
fi
}

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=$JRESDK -displayValue=$DISPLAY
}

function run_swing_component_test_unset {
Expand Down Expand Up @@ -88,15 +126,13 @@ function processResults {

if [ $1 -eq 0 ]; then
let "PASSED+=1"
TEST=$(printXmlTest "tps" "$2" "0")
BODY+="$TEST
" # new line to improve clarity, also is used in TPS/tesultsToJtregs.sh
TEST=$(printXmlTest "thc" "$2" "0")
BODY+="$TEST"
echo "$2 PASSED\n"
else
let "FAILED+=1"
TEST=$(printXmlTest "tps" "$2" "0" "$LOGFILE" "$LOGFILE")
BODY+="$TEST
" # new line to improve clarity, also is used in TPS/tesultsToJtregs.sh
TEST=$(printXmlTest "thc" "$2" "0" "$LOGFILE" "$LOGFILE")
BODY+="$TEST"
echo "$2 FAILED\n"
fi

Expand Down Expand Up @@ -137,14 +173,18 @@ LOGFILE=$TMPRESULTS/testHeadlessComponent.log
installAlternativeJDK

JAVAC_BINARY="${BOOTJDK_DIR}/bin/javac"
if [ "$OS" == "mac" ]; then
JAVAC_BINARY="${BOOTJDK_DIR}/Contents/Home/bin/javac"
fi

#use bootjdk javac
#other classes depend on this one, so we might as well just compile the main class
cp -r $SCRIPT_DIR/testHeadlessComponents/ $WORKSPACE
cp -r $SCRIPT_DIR/testHeadlessComponents $WORKSPACE
ls $WORKSPACE
pushd $WORKSPACE/testHeadlessComponents/jreTestingSwingComponents/src

cp=`mktemp -d`
$JAVAC_BINARY `find -type f | grep .java` -d $cp
$JAVAC_BINARY `find . -type f -name "*.java"` -d $cp

declare -A resArray
set +e
Expand Down Expand Up @@ -189,6 +229,9 @@ XMLREPORT=$TMPRESULTS/testHeadlessComponent.jtr.xml
printXmlHeader $PASSED $FAILED $TESTS $IGNORED "testHeadlessComponent" > $XMLREPORT
echo "$BODY" >> $XMLREPORT
printXmlFooter >> $XMLREPORT
ls -la $XMLREPORT

ls

for val in ${resArray[@]}; do
if [[ "$val" -ne "0" ]]; then
Expand Down

0 comments on commit 7d5dd7a

Please sign in to comment.