43 lines
994 B
Bash
Raw Normal View History

2021-06-17 17:32:24 -04:00
#!/bin/sh
set -e
2024-02-12 00:44:38 -05:00
# Change Directory
cd "$(dirname "$0")/../"
2023-12-26 17:29:45 -05:00
# Variables
MODE="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
2024-06-15 08:52:15 -04:00
ARCH="$(echo "$2" | tr '[:upper:]' '[:lower:]')"
APPIMAGE="$(pwd)/out/minecraft-pi-reborn-$(cat VERSION)-${ARCH}.AppImage"
2022-03-09 18:47:31 -05:00
2024-06-15 08:52:15 -04:00
# Check If File Exists
if [ ! -f "${APPIMAGE}" ]; then
echo 'Missing AppImage!' > /dev/stderr
exit 1
fi
2021-06-17 17:32:24 -04:00
2023-12-26 17:29:45 -05:00
# Make Test Directory
2024-02-04 00:43:25 -05:00
TEST_WORKING_DIR="$(pwd)/.testing-tmp"
rm -rf "${TEST_WORKING_DIR}"
mkdir -p "${TEST_WORKING_DIR}"
2024-06-15 08:52:15 -04:00
ROOT="$(pwd)"
cd "${TEST_WORKING_DIR}"
# Prepare AppImage For Docker
cp "${APPIMAGE}" tmp.AppImage
"${ROOT}/scripts/fix-appimage-for-docker.sh" tmp.AppImage
chmod +x tmp.AppImage
2021-06-17 17:32:24 -04:00
2023-12-26 17:29:45 -05:00
# Run
if [ "${MODE}" = "server" ]; then
# Server Test
2024-06-15 08:52:15 -04:00
./tmp.AppImage --appimage-extract-and-run --server --only-generate
2023-12-26 17:29:45 -05:00
else
# Client Test
2024-02-04 00:43:25 -05:00
export HOME="${TEST_WORKING_DIR}"
2024-06-15 08:52:15 -04:00
./tmp.AppImage --appimage-extract-and-run --default --no-cache --benchmark --force-headless
2023-12-26 17:29:45 -05:00
fi
2024-02-04 00:43:25 -05:00
# Clean Up
rm -rf "${TEST_WORKING_DIR}"