cagebreak/test/environment-variables
2023-02-14 21:58:29 +01:00

35 lines
1.2 KiB
Bash

#!/bin/bash
# Copyright 2023, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
testdir=$(mktemp -d)
mkdir "${testdir}/cagebreak"
RESULT=0
# CAGEBREAK_SOCKET (duplicate of arguments test)
## Check without socket
cp $MESONCURRENTCONFIGDIR/test/testing-configurations/config $testdir
readonly oldsocket=$CAGEBREAK_SOCKET
sed -i "s|CONFIGPATH|$testdir\/socket|g" $testdir/config
$(WLR_BACKENDS=headless ./cagebreak -c $testdir/config)
[[ $(cat $testdir/socket) = $oldsocket ]] || RESULT=1
## Check with socket
cp $MESONCURRENTCONFIGDIR/test/testing-configurations/config $testdir
sed -i "s|CONFIGPATH|$testdir\/socket|g" $testdir/config
$(WLR_BACKENDS=headless ./cagebreak -e -c $testdir/config)
[[ ! $(cat $testdir/socket) = $oldsocket ]] || RESULT=1
# XDG_CONFIG_HOME
cp "${MESONCURRENTCONFIGDIR}/test/testing-configurations/env-var-config" "${testdir}/cagebreak/config"
sed -i "s|CONFIGPATH|${testdir}\/result|g" "${testdir}/cagebreak/config"
XDG_CONFIG_HOME="${testdir}/" WLR_BACKENDS=headless ./cagebreak
[[ $(cat "${testdir}/result") = "SUCCESS" ]] || RESULT=1
# The XKB_DEFAULT_* family of variables is not found in the source code
# of Cagebreak but necessary to configure software for use with Cagebreak.
exit "${RESULT}"