Created
May 20, 2021 19:11
-
-
Save Schneegans/147e08eeee8c746637153a407d738cad to your computer and use it in GitHub Desktop.
Simple example script for automatic GNOME Shell extension testing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a rough attempt on quick testing of GNOME Shell extensions which are awaiting a | |
# review. It installs a given extension in a podman container, enables it and tries to | |
# open the preferences dialog. | |
# Use it like this: | |
# ./test.sh 24550 3.36 | |
# The first number is the review ID from the URL: (e.g. extensions.gnome.org/review/24550) | |
# The second is the GNOME Shell version: 3.36, 3.38 and 40.0 are currently supported. | |
# The review ID must be given as first paramter. | |
REVIEW_ID=$1 | |
if [ -z $REVIEW_ID ]; then | |
echo "Please specify the extension review ID as first parameter!"; | |
exit 1 | |
fi | |
# The GNOME Shell version can be supplied as second parameter. 3.38 is used per default. | |
VERSION="${2:-3.38}" | |
# Download the extension. | |
DOWNLOAD_FILE="review-extension.zip" | |
wget -O $DOWNLOAD_FILE https://extensions.gnome.org/review/download/"$REVIEW_ID".shell-extension.zip | |
# Extract the UUID from the metadata.json and rename the zip accordingly. | |
UUID=`unzip -p review-extension.zip metadata.json | grep '"uuid"' | cut -d\" -f4` | |
mv $DOWNLOAD_FILE "$UUID".zip | |
# Run the container in detached mode. | |
podman pull ghcr.io/schneegans/gnome-shell:"$VERSION" | |
POD_ID=$(podman run --rm -td ghcr.io/schneegans/gnome-shell:"$VERSION") | |
# Wait some time to make sure that GNOME Shell has been started. | |
echo -n "Booting the container..." | |
sleep 3 | |
echo " Done." | |
# Copy the extension to the container. | |
echo -n "Copy Extension to the container..." | |
podman cp "$UUID".zip "$POD_ID":/home/gnomeshell/ | |
echo " Done." | |
# Execute the install script. This installs the extension, restarts GNOME Shell and | |
# finally enables the extension. | |
echo -n "Installing The extension..." | |
podman exec --user gnomeshell "$POD_ID" /home/gnomeshell/set-env.sh /home/gnomeshell/enable-extension.sh "$UUID" | |
sleep 3 | |
# Check for errors. I think GJS errors are always preceeded with an ERROR, but maybe this | |
# could be more sophisticated... | |
ERRORS=$(podman exec "$POD_ID" journalctl | grep ERROR) | |
if [ -n "$ERRORS" ]; then | |
echo " Failed!" | |
echo "$ERRORS" | |
exit 1 | |
else | |
echo " Done." | |
fi | |
# Now try to open the preferences dialog. | |
echo -n "Opening the preferences dialog..." | |
podman exec --user gnomeshell "$POD_ID" /home/gnomeshell/set-env.sh gnome-extensions prefs "$UUID" | |
sleep 2 | |
# Check for erros once more. The GNOME Shell version in the container is patched to print | |
# an error if this fails. The log message can be identified easily. | |
ERRORS=$(podman exec "$POD_ID" journalctl | grep "Failed to open preferences") | |
if [ -n "$ERRORS" ]; then | |
echo " Failed!" | |
echo "$ERRORS" | |
exit 1 | |
else | |
echo " Done." | |
fi | |
# Finally stop the container... | |
echo -n "Stopping the container..." | |
podman stop "$POD_ID" > /dev/null | |
echo " Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment