From 4afcd874022affaf0e48efc97d18afae0ba56adc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 8 Sep 2020 15:14:37 +0000 Subject: Let's try to run GUI testcases on X11 (Xenial/Bionic/Focal/MacOS) --- .travis.yml | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 95c0727..d478d61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ addons: - gcc-multilib - tcl-dev - libx11-dev + - xvfb homebrew: packages: - tcl-tk @@ -25,6 +26,10 @@ jobs: compiler: gcc env: - BUILD_DIR=unix + script: &x11gui + - make binaries libraries tktest + - make install + - xvfb-run make test - name: "Linux/GCC/Shared/no-xft" os: linux dist: focal @@ -32,6 +37,21 @@ jobs: env: - BUILD_DIR=unix - CFGOPT="--disable-xft" + script: *x11gui + - name: "Linux/GCC/Shared/bionic" + os: linux + dist: bionic + compiler: gcc + env: + - BUILD_DIR=unix + script: *x11gui + - name: "Linux/GCC/Shared/xenial" + os: linux + dist: xenial + compiler: gcc + env: + - BUILD_DIR=unix + script: *x11gui - name: "Linux/GCC/Static" os: linux dist: focal @@ -112,7 +132,7 @@ jobs: - BUILD_DIR=unix - CFGOPT="--enable-symbols" # Testing on Mac, various styles - - name: "macOS/Clang/Xcode 11.6/Shared" + - name: "macOS/Clang/Xcode 11.7/Shared" os: osx osx_image: xcode11.7 env: @@ -122,7 +142,7 @@ jobs: - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) script: &mactest - make binaries libraries tktest - - name: "macOS/Clang/Xcode 11.6/Static" + - name: "macOS/Clang/Xcode 11.7/Static" os: osx osx_image: xcode11.7 env: @@ -131,7 +151,7 @@ jobs: install: - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) script: *mactest - - name: "macOS/Clang/Xcode 11.6/Debug" + - name: "macOS/Clang/Xcode 11.7/Debug" os: osx osx_image: xcode11.7 env: @@ -140,7 +160,7 @@ jobs: install: - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) script: *mactest - - name: "macOS/Clang/Xcode 11.6/Shared/XQuartz" + - name: "macOS/Clang/Xcode 11.7/Shared/XQuartz" os: osx osx_image: xcode11.7 env: @@ -148,7 +168,9 @@ jobs: - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --disable-corefoundation --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib CFLAGS=-I/usr/local/opt/tcl-tk/include" install: - ./configure ${CFGOPT} "--prefix=$HOME" || (cat config.log && exit 1) - script: *mactest + script: + - make binaries libraries tktest + - Xvfb :1337 & make test DISPLAY=:1337 # Older MacOS versions - name: "macOS/Clang/Xcode 11/Shared" os: osx -- cgit v0.12 From 23f8f1f53c2ab0960a3389b9342637f928e27e2b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 10 Sep 2020 12:38:56 +0000 Subject: Add helper xvfb-run script --- unix/xvfb-run | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100755 unix/xvfb-run diff --git a/unix/xvfb-run b/unix/xvfb-run new file mode 100755 index 0000000..62388fd --- /dev/null +++ b/unix/xvfb-run @@ -0,0 +1,191 @@ +#!/bin/sh + +# This script starts an instance of Xvfb, the "fake" X server, runs a command +# with that server available, and kills the X server when done. The return +# value of the command becomes the return value of this script. +# +# If anyone is using this to build a Debian package, make sure the package +# Build-Depends on xvfb and xauth. + +set -e + +PROGNAME=xvfb-run +SERVERNUM=99 +AUTHFILE= +ERRORFILE=/dev/null +XVFBARGS="-screen 0 1280x1024x24" +LISTENTCP="-nolisten tcp" +XAUTHPROTO=. + +# Query the terminal to establish a default number of columns to use for +# displaying messages to the user. This is used only as a fallback in the event +# the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the +# script is running, and this cannot, only being calculated once.) +DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true +case "$DEFCOLUMNS" in + *[!0-9]*|'') DEFCOLUMNS=80 ;; +esac + +# Display a message, wrapping lines at the terminal width. +message () { + echo "$PROGNAME: $*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} +} + +# Display an error message. +error () { + message "error: $*" >&2 +} + +# Display a usage message. +usage () { + if [ -n "$*" ]; then + message "usage error: $*" + fi + cat <>"$ERRORFILE" 2>&1 + fi + if [ -n "$XVFB_RUN_TMPDIR" ]; then + if ! rm -r "$XVFB_RUN_TMPDIR"; then + error "problem while cleaning up temporary directory" + exit 5 + fi + fi + if [ -n "$XVFBPID" ]; then + kill "$XVFBPID" >>"$ERRORFILE" 2>&1 + fi +} + +# Parse the command line. +ARGS=$(getopt --options +ae:f:hn:lp:s:w: \ + --long auto-servernum,error-file:,auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait: \ + --name "$PROGNAME" -- "$@") +GETOPT_STATUS=$? + +if [ $GETOPT_STATUS -ne 0 ]; then + error "internal error; getopt exited with status $GETOPT_STATUS" + exit 6 +fi + +eval set -- "$ARGS" + +while :; do + case "$1" in + -a|--auto-servernum) SERVERNUM=$(find_free_servernum); AUTONUM="yes" ;; + -e|--error-file) ERRORFILE="$2"; shift ;; + -f|--auth-file) AUTHFILE="$2"; shift ;; + -h|--help) SHOWHELP="yes" ;; + -n|--server-num) SERVERNUM="$2"; shift ;; + -l|--listen-tcp) LISTENTCP="" ;; + -p|--xauth-protocol) XAUTHPROTO="$2"; shift ;; + -s|--server-args) XVFBARGS="$2"; shift ;; + -w|--wait) shift ;; + --) shift; break ;; + *) error "internal error; getopt permitted \"$1\" unexpectedly" + exit 6 + ;; + esac + shift +done + +if [ "$SHOWHELP" ]; then + usage + exit 0 +fi + +if [ -z "$*" ]; then + usage "need a command to run" >&2 + exit 2 +fi + +if ! command -v xauth >/dev/null; then + error "xauth command not found" + exit 3 +fi + +# tidy up after ourselves +trap clean_up EXIT + +# If the user did not specify an X authorization file to use, set up a temporary +# directory to house one. +if [ -z "$AUTHFILE" ]; then + XVFB_RUN_TMPDIR="$(mktemp -d -t $PROGNAME.XXXXXX)" + AUTHFILE="$XVFB_RUN_TMPDIR/Xauthority" + # Create empty file to avoid xauth warning + touch "$AUTHFILE" +fi + +# Start Xvfb. +MCOOKIE=$(mcookie) +tries=10 +while [ $tries -gt 0 ]; do + tries=$(( $tries - 1 )) + XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1 +add :$SERVERNUM $XAUTHPROTO $MCOOKIE +EOF + # handle SIGUSR1 so Xvfb knows to send a signal when it's ready to accept + # connections + trap : USR1 + (trap '' USR1; exec Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP -auth $AUTHFILE >>"$ERRORFILE" 2>&1) & + XVFBPID=$! + + wait || : + if kill -0 $XVFBPID 2>/dev/null; then + break + elif [ -n "$AUTONUM" ]; then + # The display is in use so try another one (if '-a' was specified). + SERVERNUM=$((SERVERNUM + 1)) + SERVERNUM=$(find_free_servernum) + continue + fi + error "Xvfb failed to start" >&2 + XVFBPID= + exit 1 +done + +# Start the command and save its exit status. +set +e +DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1 +RETVAL=$? +set -e + +# Return the executed command's exit status. +exit $RETVAL + +# vim:set ai et sts=4 sw=4 tw=80: -- cgit v0.12 From 01d74802c021f72a1e0a64326659150bef5dc665 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 11 Sep 2020 07:45:51 +0000 Subject: In xvfb-run, don't try to query the terminal width, because we don't have one --- unix/xvfb-run | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/unix/xvfb-run b/unix/xvfb-run index 5eb77ac..b7a9d3d 100755 --- a/unix/xvfb-run +++ b/unix/xvfb-run @@ -17,18 +17,9 @@ XVFBARGS="-screen 0 1280x1024x24" LISTENTCP="-nolisten tcp" XAUTHPROTO=. -# Query the terminal to establish a default number of columns to use for -# displaying messages to the user. This is used only as a fallback in the event -# the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the -# script is running, and this cannot, only being calculated once.) -DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true -case "$DEFCOLUMNS" in - *[!0-9]*|'') DEFCOLUMNS=80 ;; -esac - -# Display a message, wrapping lines at the terminal width. +# Display a message. message () { - echo "$PROGNAME: $*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} + echo "$PROGNAME: $*" } # Display an error message. -- cgit v0.12