Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Use xvfb for ncurses test #434

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ jobs:
run: |
sudo apt-get install -y \
python3-pip \
python3-setuptools
python3-setuptools \
xvfb # for test
sudo -H python3 -m pip install meson ninja

- if: ${{ contains(matrix.build.name, 'without-nls') && matrix.build.container == null }}
Expand Down
27 changes: 26 additions & 1 deletion test/test_restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,33 @@ done
cmp_substr "$(${RMW_TEST_CMD_STRING} -z ${PRIMARY_WASTE_DIR}/files/. && exit 1)" \
"refusing to process"

if [ -n "${TERM}" ] && [ "${TERM}" != "dumb" ]; then
# I don't want to force anyone to install Xvfb for this single test
# so I'll only run it if it's already installed
if [ -n "$(command -v Xvfb)" ]; then
# Start Xvfb on display :99
Xvfb :99 &
XVFB_PID=$!

# Save the current DISPLAY value and set it to use the virtual display
OLD_DISPLAY="$DISPLAY"
export DISPLAY=:99

# This may be needed to prevent a failure on OpenBSD:
# Error opening terminal: unknown.
export TERM=xterm

# No visual test here, but when used with llvm sanitize or valgrind,
# the chances of spotting any memory leaks are pretty good.
echo q | ${RMW_TEST_CMD_STRING} -s

kill $XVFB_PID

# Restore the original DISPLAY value if it was set
if [ -n "$OLD_DISPLAY" ]; then
export DISPLAY="$OLD_DISPLAY"
else
unset DISPLAY
fi
fi

# This test will only work on Andy's workstation.
Expand Down