test: run-all.sh, hide i3bar for compare

This commit is contained in:
Mitchell Hashimoto
2022-07-21 21:00:40 -07:00
parent 6812f3f54a
commit 578679fb35
10 changed files with 51 additions and 9 deletions

1
.gitignore vendored
View File

@ -3,5 +3,6 @@ zig-cache/
zig-out/ zig-out/
/result* /result*
test/ghostty test/ghostty
test/cases/**/*.actual.png
glad.zip glad.zip

View File

@ -46,4 +46,6 @@ COPY --from=alacritty /tmp/alacritty/target/release/alacritty /usr/bin/alacritty
COPY ./run.sh /entrypoint.sh COPY ./run.sh /entrypoint.sh
COPY ./ghostty /usr/bin/ghostty
ENTRYPOINT ["/bin/bash"] ENTRYPOINT ["/bin/bash"]

View File

@ -36,6 +36,6 @@ the full test suite against only a single terminal emulator.
## Modifying the `ghostty` Binary ## Modifying the `ghostty` Binary
This test suite expects the `ghostty` binary to be in _this directory_. This test suite expects the `ghostty` binary to be in _this directory_.
You can manually copy it into place. By default, if the binary doesn't exist, You can manually copy it into place. Each time you modify the binary, you
the various host-side shell scripts will try to copy from must rebuild the Docker image.
`../zig-out/bin/ghostty` (resulting from `zig build`).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

25
test/run-all.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
#
# Run all of the test cases. All test cases are found by traversing
# the "cases" directory, finding all shell files, and executing the
# "./run-host.sh" command for each.
DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
# We always copy the bin in case it was rebuilt
cp ${DIR}/../zig-out/bin/ghostty ${DIR}/
# Build our image once
IMAGE=$(docker build --file ${DIR}/Dockerfile -q ${DIR})
# Unix shortcut to just execute ./run-host for each one. We can do
# this less esoterically if we ever wanted.
find ${DIR}/cases \
-type f \
-name '*.sh' \
-exec \
${DIR}/run-host.sh \
--case '{}' \
--rewrite-abs-path \
$@ \
';'

View File

@ -3,14 +3,13 @@
# This runs a single test case from the host (not from Docker itself). The # This runs a single test case from the host (not from Docker itself). The
# arguments are the same as run.sh but this wraps it in docker. # arguments are the same as run.sh but this wraps it in docker.
if [ ! -f "ghostty" ]; then DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
cp ../zig-out/bin/ghostty . IMAGE=$(docker build --file ${DIR}/Dockerfile -q ${DIR})
fi
docker run \ docker run \
--init \ --init \
--rm \ --rm \
-v $(pwd):/src \ -v ${DIR}:/src \
--entrypoint "xvfb-run" \ --entrypoint "xvfb-run" \
$(docker build -q .) \ $IMAGE \
/entrypoint.sh $@ /entrypoint.sh $@

View File

@ -19,21 +19,30 @@ function has_func() {
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# Flag parsing # Flag parsing
ARG_REWRITE=0
ARG_UPDATE=0 ARG_UPDATE=0
ARG_OUT="/tmp/test.png"
while [[ "$#" -gt 0 ]]; do while [[ "$#" -gt 0 ]]; do
case $1 in case $1 in
-e|--exec) ARG_EXEC="$2"; shift ;; -e|--exec) ARG_EXEC="$2"; shift ;;
-c|--case) ARG_CASE="$2"; shift ;; -c|--case) ARG_CASE="$2"; shift ;;
-o|--output) ARG_OUT="$2"; shift ;; -o|--output) ARG_OUT="$2"; shift ;;
-u|--update) ARG_UPDATE=1 ;; -u|--update) ARG_UPDATE=1 ;;
--rewrite-abs-path) ARG_REWRITE=1 ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;; *) echo "Unknown parameter passed: $1"; exit 1 ;;
esac esac
shift shift
done done
# Rewrite the path to be valid for us. This regex can be fooled in many ways
# but its good enough for my PC (mitchellh) and CI. Contributors feel free
# to harden it.
if [ "$ARG_REWRITE" -eq 1 ]; then
ARG_CASE=$(echo $ARG_CASE | sed -e 's/.*cases/\/src\/cases/')
fi
# If we're updating, then just update the file in-place # If we're updating, then just update the file in-place
GOLDEN_OUT="${ARG_CASE}.${ARG_EXEC}.png" GOLDEN_OUT="${ARG_CASE}.${ARG_EXEC}.png"
ARG_OUT="${ARG_CASE}.${ARG_EXEC}.actual.png"
if [ "$ARG_UPDATE" -eq 1 ]; then ARG_OUT=$GOLDEN_OUT; fi if [ "$ARG_UPDATE" -eq 1 ]; then ARG_OUT=$GOLDEN_OUT; fi
bad=0 bad=0
@ -75,7 +84,13 @@ chmod 0700 $XDG_RUNTIME_DIR
# Configure i3 # Configure i3
cat <<EOF >${XDG_BASE_DIR}/i3.cfg cat <<EOF >${XDG_BASE_DIR}/i3.cfg
# i3 config file (v4)
exec ${ARG_EXEC} exec ${ARG_EXEC}
bar {
mode invisible
}
EOF EOF
#-------------------------------------------------------------------- #--------------------------------------------------------------------