xsession: Make xsession script testable.

A few minor related changes are included. E.g. we actually want to pass
along blank lines, so remove that check (which didn't work anyways as \n
was still present).

We replace that with a simple filter in the template installation
process to allow there to be source lines in the base template that
don't get passed to the installed result. This allows for shell script
that prevents running the full command suite in the base without
affecting the installed script.

It is required to be able to actually run the base script as the "set
-u" check for unset variables doesn't work when "set -n" (syntax check)
is in use. These set commands can be passed directly to /bin/sh to have
them in effect when the script starts (and are both part of POSIX and
seem to work even with busybox sh).

Additionally, the path_add function needs to actually check for unset
variables now. Luckily there is existing Bourne shell syntax for that.

The observant reviewer will note that the testsuite does not currently
pass because there is a mispeled lib_suffix in the base, that will be
fixed in the next commit.
wilder
Michael Pyne 14 years ago
parent 9cae4ceacf
commit 59428065c2
  1. 3
      kdesrc-build
  2. 9
      kdesrc-build-test.pl
  3. 11
      sample-xsession.sh

@ -6457,7 +6457,8 @@ sub installTemplatedFile
unlink($destinationPath);
}
next unless $line; # Skip blank lines
# Some lines should only be present in the source as they aid with testing.
next if $line =~ /kdesrc-build: filter/;
$line =~
s {

@ -516,9 +516,16 @@ SKIP: {
like ($newQMakePossibility, qr/^qmake/, 'qmake looks like an executable even in scalar context.');
}
is(system('/bin/sh', '-n', "$RealBin/sample-xsession.sh"), 0, 'xsession pre-install syntax check');
$ENV{KDESRC_BUILD_TESTING} = 1; # Tell sample-xsession.sh not to run.
is(system('/bin/sh', '-u', "$RealBin/sample-xsession.sh"), 0, 'xsession unset variable check');
# Ensure this function can run without throwing exception.
ok(installTemplatedFile("$RealBin/sample-xsession.sh", "$testSourceDirName/xsession.sh", $ctx) || 1,
'installing-template');
'xsession template installation');
is(system('/bin/sh', '-n', "$testSourceDirName/xsession.sh"), 0, 'xsession post-install syntax check');
done_testing();
### TESTS GO ABOVE THIS LINE

@ -14,12 +14,19 @@
# === User-modifiable variables. Should be set automatically by kdesrc-build.
# kdesrc-build: filter | The KDESRC_BUILD_TESTING stuff is to allow the script to
# kdesrc-build: filter | be executable by testsuite. It is filtered from destination.
if ! test -n "$KDESRC_BUILD_TESTING"; then # kdesrc-build: filter
# Where KDE libraries and applications are installed to.
kde_prefix="<% kdedir %>" # E.g. "$HOME/kde-4"
# Where Qt is installed to. If using the system Qt, leave blank or set to
# 'auto' and this script will try to auto-detect.
qt_prefix="<% qtdir %>" # E.g. "$HOME/qt4" or "/usr" on many systems.
else # kdesrc-build: filter
kde_prefix="$HOME/kde" # kdesrc-build: filter
qt_prefix="$HOME/qt4" # kdesrc-build: filter
fi # kdesrc-build: filter
# Directory to use for KDE configuration and other user customizations.
KDEHOME="$HOME/.kde4-self" # Or perhaps "$HOME/.kde-selfmade", etc.
@ -67,7 +74,7 @@ fi
# Can't use function keyword in Busybox-sh
path_add()
{
eval curVal=\$'{'$1'}'
eval curVal=\$'{'$1'-}'
if [ -n "$curVal" ]; then
eval "$1"="$2:$curVal";
@ -130,6 +137,7 @@ export XDG_CONFIG_DIRS
export MANPATH
export KDEHOME
if ! test -n "$KDESRC_BUILD_TESTING"; then # kdesrc-build: filter
# Read in user-specific customizations
if test -f "$HOME/.xsession-local"; then
source "$HOME/.xsession-local"
@ -148,3 +156,4 @@ fi
if test -f "$HOME/.xsession-logout"; then
source "$HOME/.xsession-logout"
fi
fi # kdesrc-build: filter

Loading…
Cancel
Save