From 89a4c5d609d15f7cac71616ce678fee47f1968ec Mon Sep 17 00:00:00 2001 From: project-repo Date: Tue, 14 Feb 2023 20:22:31 +0100 Subject: [PATCH] Add env var tests --- meson.build | 1 + test/environment-variables | 33 ++++++++++++++++++++++ test/testing-configurations/env-var-config | 2 ++ 3 files changed, 36 insertions(+) create mode 100644 test/environment-variables create mode 100644 test/testing-configurations/env-var-config diff --git a/meson.build b/meson.build index 95583a8..b77048e 100644 --- a/meson.build +++ b/meson.build @@ -315,3 +315,4 @@ test('Build without xwayland', find_program('test/build-w-o-xwayland'), env : [ test('Clang-format formatting check', find_program('test/clang-format'), args : [ cagebreak_main_file + cagebreak_source_strings + cagebreak_header_strings ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'basic') test('Arguments', find_program('test/arguments'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'basic') test('Scan-build static analysis', find_program('test/scan-build'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release') +test('Environment Variables', find_program('test/environment-variables'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'basic') diff --git a/test/environment-variables b/test/environment-variables new file mode 100644 index 0000000..8a4b313 --- /dev/null +++ b/test/environment-variables @@ -0,0 +1,33 @@ +#!/bin/bash + +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}" + + + diff --git a/test/testing-configurations/env-var-config b/test/testing-configurations/env-var-config new file mode 100644 index 0000000..d6c7b48 --- /dev/null +++ b/test/testing-configurations/env-var-config @@ -0,0 +1,2 @@ +exec (echo "SUCCESS" > CONFIGPATH ) +quit