Skip to content

Commit 795d9bc

Browse files
authored
Add test that launches Oolite, creates a snapshot and closes it (#591)
* Add JS quit command and related Obj-C plumbing * Make AddOns folder in oolite.app not build * Add Python test that launches Oolite, takes a snapshot and quits * Add to test_builds workflow * Add Windows test build * Update OOlite.nsi to exclude AddOns in oolite.app folder as it is already one level up * Install mesa for Windows CI * Gallium driver env var * Fix appimage (old Ubuntu doesn't have Wayland) * Update README.md to show how to run test * Check png size * Move quitGame into ifndef NDEBUG * Better comments
1 parent 8d82f67 commit 795d9bc

18 files changed

Lines changed: 427 additions & 33 deletions

File tree

.github/workflows/build-all.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
---
2-
name: build-all
3-
1+
name: Build Oolite package for various platforms
42
on:
53
workflow_dispatch:
64
push:
@@ -35,7 +33,7 @@ jobs:
3533
3634
- name: Install packages
3735
run: |
38-
sudo oolite/ShellScripts/Linux/install_deps_root.sh
36+
sudo oolite/ShellScripts/Linux/install_deps_root.sh --skip-wayland
3937
4038
- name: Build Oolite
4139
run: |

.github/workflows/test_builds.yaml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Oolite package on various platforms
1+
name: Test Oolite package on various platforms
22
on:
33
push:
44
pull_request:
@@ -23,7 +23,7 @@ jobs:
2323
sudo ShellScripts/Linux/install_deps_root.sh
2424
- name: Build Oolite
2525
run: |
26-
ShellScripts/common/build_oolite.sh pkg-appimage
26+
ShellScripts/common/build_oolite.sh test
2727
2828
fedora:
2929
runs-on: ubuntu-latest
@@ -38,10 +38,15 @@ jobs:
3838
run: |
3939
dnf -y update
4040
dnf -y install git
41-
- name: Checkout Oolite
41+
- name: Pre-setup ownership
4242
run: |
43+
# This must run before the checkout action if the action tries to do git commands
44+
mkdir -p "$GITHUB_WORKSPACE"
4345
git config --global --add safe.directory "$GITHUB_WORKSPACE"
44-
git clone --recursive https://github.com/${{ github.repository }} .
46+
- uses: actions/checkout@v6
47+
with:
48+
fetch-depth: 0
49+
submodules: true
4550
- name: Checkout dependencies
4651
run: |
4752
ShellScripts/Linux/checkout_deps.sh
@@ -50,7 +55,7 @@ jobs:
5055
ShellScripts/Linux/install_deps_root.sh
5156
- name: Build Oolite
5257
run: |
53-
ShellScripts/common/build_oolite.sh pkg-appimage
58+
ShellScripts/common/build_oolite.sh test
5459
5560
arch:
5661
runs-on: ubuntu-latest
@@ -65,10 +70,15 @@ jobs:
6570
run: |
6671
pacman -Syu --noconfirm
6772
pacman -S --noconfirm --needed git
68-
- name: Checkout Oolite
73+
- name: Pre-setup ownership
6974
run: |
75+
# This must run before the checkout action if the action tries to do git commands
76+
mkdir -p "$GITHUB_WORKSPACE"
7077
git config --global --add safe.directory "$GITHUB_WORKSPACE"
71-
git clone --recursive https://github.com/${{ github.repository }} .
78+
- uses: actions/checkout@v6
79+
with:
80+
fetch-depth: 0
81+
submodules: true
7282
- name: Checkout dependencies
7383
run: |
7484
ShellScripts/Linux/checkout_deps.sh
@@ -77,4 +87,39 @@ jobs:
7787
ShellScripts/Linux/install_deps_root.sh
7888
- name: Build Oolite
7989
run: |
80-
ShellScripts/common/build_oolite.sh pkg-appimage
90+
ShellScripts/common/build_oolite.sh test
91+
92+
windows:
93+
runs-on: windows-latest
94+
steps:
95+
- name: Set up MSYS2
96+
uses: msys2/setup-msys2@v2
97+
with:
98+
update: true
99+
100+
- uses: actions/checkout@v6
101+
with:
102+
fetch-depth: 0
103+
submodules: true
104+
105+
- name: Download latest release assets
106+
uses: robinraju/release-downloader@v1
107+
with:
108+
repository: OoliteProject/oolite_windeps_build
109+
latest: true
110+
fileName: "*"
111+
out-file-path: build/packages
112+
113+
- name: Install packages
114+
shell: msys2 {0}
115+
env:
116+
msystem: UCRT64
117+
run: |
118+
ShellScripts/Windows/install_deps.sh clang
119+
120+
- name: Build Oolite
121+
shell: msys2 {0}
122+
env:
123+
msystem: UCRT64
124+
run: |
125+
ShellScripts/common/build_oolite.sh test

DebugOXP/Debug.oxp/Scripts/oolite-debug-console.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,16 @@ this.evaluate = function evaluate(command, PARAM)
858858
}
859859
}
860860

861+
this.quit = function() {
862+
log("debugConsole.automation", "Triggering global quitGame bridge...");
863+
864+
// This calls the native function in OOJSGlobal.m, which in turn calls [Universe quitGame]
865+
if (typeof quitGame === "function") {
866+
quitGame();
867+
} else {
868+
log("debugConsole.automation", "Error: quitGame() global function not found. Did you recompile?");
869+
}
870+
};
861871

862872
// Identify the location of the eval() command above for the debug location formatter.
863873
this.markConsoleEntryPoint = special.markConsoleEntryPoint;

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ help:
3333
.PHONY: release
3434
release:
3535
$(MAKE) -f GNUmakefile debug=no strip=yes lto=yes
36-
mkdir -p build/AddOns && rm -rf build/AddOns/Basic-debug.oxp && cp -rf DebugOXP/Debug.oxp build/AddOns/Basic-debug.oxp
36+
mkdir -p oolite.app/AddOns && rm -rf oolite.app/AddOns/Basic-debug.oxp && cp -rf DebugOXP/Debug.oxp oolite.app/AddOns/Basic-debug.oxp
3737

3838
.PHONY: release-deployment
3939
release-deployment:
@@ -42,18 +42,21 @@ release-deployment:
4242
.PHONY: release-snapshot
4343
release-snapshot:
4444
$(MAKE) -f GNUmakefile SNAPSHOT_BUILD=yes debug=no
45-
mkdir -p build/AddOns && rm -rf build/AddOns/Basic-debug.oxp && cp -rf DebugOXP/Debug.oxp build/AddOns/Basic-debug.oxp
45+
mkdir -p oolite.app/AddOns && rm -rf oolite.app/AddOns/Basic-debug.oxp && cp -rf DebugOXP/Debug.oxp oolite.app/AddOns/Basic-debug.oxp
4646

4747
.PHONY: debug
4848
debug:
4949
$(MAKE) -f GNUmakefile debug=yes strip=no
50-
mkdir -p build/AddOns && rm -rf build/AddOns/Basic-debug.oxp && cp -rf DebugOXP/Debug.oxp build/AddOns/Basic-debug.oxp
50+
mkdir -p oolite.app/AddOns && rm -rf oolite.app/AddOns/Basic-debug.oxp && cp -rf DebugOXP/Debug.oxp oolite.app/AddOns/Basic-debug.oxp
51+
52+
.PHONY: test
53+
test: release-snapshot
54+
tests/run_test.sh
5155

5256
.PHONY: clean
5357
clean:
5458
$(MAKE) -f GNUmakefile clean
5559
$(RM) -rf oolite.app
56-
$(RM) -rf build/AddOns
5760

5861
.PHONY: all
5962
all: release release-deployment release-snapshot debug

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ sudo ShellScripts/Linux/install_deps_root.sh
101101

102102
### Building Oolite
103103

104-
Next run this in your bash or MSYS2 prompt to build Oolite:
104+
Next run this in your Bash or MSYS2 prompt to build Oolite:
105105

106106
```bash
107107
ShellScripts/common/build_oolite.sh release
108108
```
109109

110-
The completed build (executable and games files) can be found in the Oolite.app directory.
110+
The completed build (executable and games files) can be found in the oolite.app directory.
111111

112112
Subsequently, you can clean and build as follows:
113113

@@ -116,6 +116,12 @@ make -f Makefile clean
116116
make -f Makefile release -j$(nproc)
117117
```
118118

119+
You can run a test from your Bash or MSYS2 prompt as follows:
120+
121+
```bash
122+
make -f Makefile test
123+
```
124+
119125
On Linux, you will need to run this beforehand: `source /usr/local/share/GNUstep/Makefiles/GNUstep.sh`
120126

121127
On Windows, this is set up be default in the shell: `source $MINGW_PREFIX/share/GNUstep/Makefiles/GNUstep.sh`

ShellScripts/Linux/install_deps_root.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55

66
run_script() {
7+
local skip_wayland=false
8+
9+
# Parse arguments
10+
while [[ "$#" -gt 0 ]]; do
11+
case $1 in
12+
-s|--skip-wayland) skip_wayland=true; shift ;;
13+
*) shift ;;
14+
esac
15+
done
16+
717
# If current user ID is NOT 0 (root)
818
if [[ $EUID -ne 0 ]]; then
919
echo "This script requires root to install dependencies. Rerun and escalate privileges (eg. sudo ...)"
@@ -30,6 +40,17 @@ run_script() {
3040
if ! install_package gnutls-dev; then
3141
return 1
3242
fi
43+
# Check Python
44+
if ! python3 --version >/dev/null 2>&1; then
45+
if ! install_package python; then
46+
return 1
47+
fi
48+
fi
49+
if [[ $skip_wayland == false ]]; then
50+
if ! install_package xwfb-run; then
51+
return 1
52+
fi
53+
fi
3354
if ! install_package icu-dev; then
3455
return 1
3556
fi

ShellScripts/Linux/install_freedesktop_fn.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ install_freedesktop() {
55
# $1: app folder (destination)
66
# $2: appdata or metainfo
77

8-
local err_msg="❌ Error: Failed to install "
8+
local err_msg="❌ Error: Failed to"
99

1010
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
1111
pushd "$SCRIPT_DIR"
@@ -19,13 +19,19 @@ install_freedesktop() {
1919
APPSHR="$1/share"
2020

2121
# Install binaries and scripts
22-
install -D "$PROGDIR/oolite" "$APPBIN/oolite" || { echo "$err_msg oolite binary" >&2; return 1; }
23-
install -D "$PROGDIR/run_oolite.sh" "$APPBIN/run_oolite.sh" || { echo "$err_msg run_oolite.sh" >&2; return 1; }
24-
install -D "$PROGDIR/splash-launcher" "$APPBIN/splash-launcher" || { echo "$err_msg splash-launcher" >&2; return 1; }
22+
install -D "$PROGDIR/oolite" "$APPBIN/oolite" || { echo "$err_msg install oolite binary" >&2; return 1; }
23+
install -D "$PROGDIR/run_oolite.sh" "$APPBIN/run_oolite.sh" || { echo "$err_msg install run_oolite.sh" >&2; return 1; }
24+
install -D "$PROGDIR/splash-launcher" "$APPBIN/splash-launcher" || { echo "$err_msg install splash-launcher" >&2; return 1; }
2525

2626
# Resources copy
2727
mkdir -p "$APPBIN/Resources"
28-
cp -rf "$PROGDIR/Resources/." "$APPBIN/Resources/" || { echo "$err_msg Copying Resources folder" >&2; return 1; }
28+
cp -rf "$PROGDIR/Resources/." "$APPBIN/Resources/" || { echo "$err_msg copy Resources folder" >&2; return 1; }
29+
30+
# AddOns copy if folder exists in oolite.app
31+
if [ -d "$PROGDIR/AddOns" ]; then
32+
mkdir -p "$APPBIN/AddOns"
33+
cp -rf "$PROGDIR/AddOns/." "$APPBIN/AddOns/" || { echo "$err_msg copy AddOns folder" >&2; return 1; }
34+
fi
2935

3036
install -D "GNUstep.conf.template" "$APPBIN/Resources/GNUstep.conf.template" || { echo "$err_msg GNUstep template" >&2; return 1; }
3137

ShellScripts/Linux/install_package_fn.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ install_package() {
3737
arch) PKG_NAME="gnutls" ;;
3838
esac ;;
3939

40+
"python")
41+
case "$CURRENT_DISTRO" in
42+
debian) PKG_NAME="python3-pip" ;;
43+
redhat) PKG_NAME="python3-pip" ;;
44+
arch) PKG_NAME="python-pip" ;;
45+
esac ;;
46+
47+
"xwfb-run") PKG_NAME="xwayland-run weston" ;;
48+
4049
"icu-dev")
4150
case "$CURRENT_DISTRO" in
4251
debian) PKG_NAME="libicu-dev" ;;

ShellScripts/Windows/install_deps.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ run_script() {
3939
pacman -S pactoys --noconfirm
4040
pacboy -S binutils --noconfirm
4141
pacboy -S uutils-coreutils --noconfirm
42+
pacboy -S python-pip --noconfirm
43+
pacboy -S mesa --noconfirm
4244

4345
source ../common/checkout_submodules_fn.sh
4446
checkout_submodules

ShellScripts/common/post_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ run_script() {
4444
for resdir in "${RESOURCE_DIRS[@]}"; do
4545
cp -rfu "$resdir" "$PROGDIR/Resources"
4646
done
47-
47+
4848
cp -fu Resources/README.TXT "$PROGDIR/Resources"
4949
cp -fu Resources/InfoPlist.strings "$PROGDIR/Resources"
5050
cp -fu src/Cocoa/Info-Oolite.plist "$PROGDIR/Resources/Info-gnustep.plist"

0 commit comments

Comments
 (0)