minecraft-pi-reborn/scripts/test.sh

37 lines
748 B
Bash
Raw Normal View History

2021-06-17 21:32:24 +00:00
#!/bin/sh
set -e
2024-02-12 05:44:38 +00:00
# Change Directory
cd "$(dirname "$0")/../"
2023-12-26 22:29:45 +00:00
# Variables
MODE="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
2024-02-04 02:07:53 +00:00
ARCH='host'
2022-03-09 23:47:31 +00:00
2023-12-26 22:29:45 +00:00
# Build
2024-02-04 02:07:53 +00:00
./scripts/build.mjs none "${MODE}" "${ARCH}" -DMCPI_HEADLESS_MODE=ON
2023-12-26 22:29:45 +00:00
# Add To PATH
2024-02-04 02:07:53 +00:00
export PATH="$(pwd)/out/${MODE}/${ARCH}/usr/bin:${PATH}"
2021-06-17 21:32:24 +00:00
2023-12-26 22:29:45 +00:00
# Make Test Directory
2024-02-04 05:43:25 +00:00
TEST_WORKING_DIR="$(pwd)/.testing-tmp"
rm -rf "${TEST_WORKING_DIR}"
mkdir -p "${TEST_WORKING_DIR}"
2021-06-17 21:32:24 +00:00
2023-12-26 22:29:45 +00:00
# Run
if [ "${MODE}" = "server" ]; then
# Server Test
2024-02-04 05:43:25 +00:00
cd "${TEST_WORKING_DIR}"
2023-12-26 22:29:45 +00:00
minecraft-pi-reborn-server --only-generate
else
# Client Test
export _MCPI_SKIP_ROOT_CHECK=1
2024-02-04 05:43:25 +00:00
export HOME="${TEST_WORKING_DIR}"
2023-12-26 22:29:45 +00:00
minecraft-pi-reborn-client --default --no-cache --benchmark
fi
2024-02-04 05:43:25 +00:00
# Clean Up
rm -rf "${TEST_WORKING_DIR}"