diff --git a/.gitignore b/.gitignore index e6a5267e6..0135036b0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ zig-cache/ zig-out/ /result* test/ghostty +test/cases/**/*.actual.png glad.zip diff --git a/test/Dockerfile b/test/Dockerfile index d35b74fa3..bc1e5095f 100644 --- a/test/Dockerfile +++ b/test/Dockerfile @@ -46,4 +46,6 @@ COPY --from=alacritty /tmp/alacritty/target/release/alacritty /usr/bin/alacritty COPY ./run.sh /entrypoint.sh +COPY ./ghostty /usr/bin/ghostty + ENTRYPOINT ["/bin/bash"] diff --git a/test/README.md b/test/README.md index 81358f62f..ef59fb12e 100644 --- a/test/README.md +++ b/test/README.md @@ -36,6 +36,6 @@ the full test suite against only a single terminal emulator. ## Modifying the `ghostty` Binary 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, -the various host-side shell scripts will try to copy from -`../zig-out/bin/ghostty` (resulting from `zig build`). +You can manually copy it into place. Each time you modify the binary, you +must rebuild the Docker image. + diff --git a/test/cases/vttest/1_1.sh.alacritty.png b/test/cases/vttest/1_1.sh.alacritty.png index 030912052..5ffcbef9d 100644 Binary files a/test/cases/vttest/1_1.sh.alacritty.png and b/test/cases/vttest/1_1.sh.alacritty.png differ diff --git a/test/cases/vttest/1_1.sh.ghostty.png b/test/cases/vttest/1_1.sh.ghostty.png index 6a24c4aed..dbc04ed91 100644 Binary files a/test/cases/vttest/1_1.sh.ghostty.png and b/test/cases/vttest/1_1.sh.ghostty.png differ diff --git a/test/cases/vttest/launch.sh.alacritty.png b/test/cases/vttest/launch.sh.alacritty.png index 740f8faf8..305212889 100644 Binary files a/test/cases/vttest/launch.sh.alacritty.png and b/test/cases/vttest/launch.sh.alacritty.png differ diff --git a/test/cases/vttest/launch.sh.ghostty.png b/test/cases/vttest/launch.sh.ghostty.png new file mode 100644 index 000000000..c307ab7e2 Binary files /dev/null and b/test/cases/vttest/launch.sh.ghostty.png differ diff --git a/test/run-all.sh b/test/run-all.sh new file mode 100755 index 000000000..5bfbee8c3 --- /dev/null +++ b/test/run-all.sh @@ -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 \ + $@ \ + ';' diff --git a/test/run-host.sh b/test/run-host.sh index 15d7d2a1f..017c86f62 100755 --- a/test/run-host.sh +++ b/test/run-host.sh @@ -3,14 +3,13 @@ # 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. -if [ ! -f "ghostty" ]; then - cp ../zig-out/bin/ghostty . -fi +DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +IMAGE=$(docker build --file ${DIR}/Dockerfile -q ${DIR}) docker run \ --init \ --rm \ - -v $(pwd):/src \ + -v ${DIR}:/src \ --entrypoint "xvfb-run" \ - $(docker build -q .) \ + $IMAGE \ /entrypoint.sh $@ diff --git a/test/run.sh b/test/run.sh index 09d7249a2..c504b658c 100755 --- a/test/run.sh +++ b/test/run.sh @@ -19,21 +19,30 @@ function has_func() { #-------------------------------------------------------------------- # Flag parsing +ARG_REWRITE=0 ARG_UPDATE=0 -ARG_OUT="/tmp/test.png" while [[ "$#" -gt 0 ]]; do case $1 in -e|--exec) ARG_EXEC="$2"; shift ;; -c|--case) ARG_CASE="$2"; shift ;; -o|--output) ARG_OUT="$2"; shift ;; -u|--update) ARG_UPDATE=1 ;; + --rewrite-abs-path) ARG_REWRITE=1 ;; *) echo "Unknown parameter passed: $1"; exit 1 ;; esac shift 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 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 bad=0 @@ -75,7 +84,13 @@ chmod 0700 $XDG_RUNTIME_DIR # Configure i3 cat <${XDG_BASE_DIR}/i3.cfg +# i3 config file (v4) + exec ${ARG_EXEC} + +bar { + mode invisible +} EOF #--------------------------------------------------------------------