[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dmd] 01/03: dmd: Don't create configuration file when '-c' is passed.
From: |
Ludovic Courtès |
Subject: |
[dmd] 01/03: dmd: Don't create configuration file when '-c' is passed. |
Date: |
Fri, 04 Jul 2014 16:59:48 +0000 |
civodul pushed a commit to branch master
in repository dmd.
commit b4ee8fceaa9fbbf597ebb291e05b0cf847e51381
Author: Ludovic Courtès <address@hidden>
Date: Fri Jul 4 11:26:03 2014 +0200
dmd: Don't create configuration file when '-c' is passed.
Fixes a bug where 'dmd' would fail in 'default-config-file' when $HOME
is not writable, even if '-c' was passed.
* modules/dmd.scm (main): Delay call to 'default-config-file'.
* tests/no-home.sh: New file.
* Makefile.am (TESTS): Add it.
---
.gitignore | 2 ++
Makefile.am | 2 +-
modules/dmd.scm | 4 ++--
tests/no-home.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5482135..5686016 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,3 +44,5 @@ Makefile
/tests/basic.trs
/tests/respawn.log
/tests/respawn.trs
+/tests/no-home.log
+/tests/no-home.trs
diff --git a/Makefile.am b/Makefile.am
index 9f783ef..5e6ff05 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -121,7 +121,7 @@ modules/dmd/config.scm: modules/dmd/config.scm.in Makefile
SUFFIXES = .go
-TESTS = tests/basic.sh tests/respawn.sh
+TESTS = tests/basic.sh tests/respawn.sh tests/no-home.sh
TEST_EXTENSIONS = .sh
EXTRA_DIST += $(TESTS)
diff --git a/modules/dmd.scm b/modules/dmd.scm
index 9350552..dee5f1e 100644
--- a/modules/dmd.scm
+++ b/modules/dmd.scm
@@ -53,7 +53,7 @@
(define (main . args)
(false-if-exception (setlocale LC_ALL ""))
- (let ((config-file (default-config-file))
+ (let ((config-file #f)
(socket-file default-socket-file)
(pid-file #f)
(insecure #f)
@@ -149,7 +149,7 @@
;; `caught-error' does not do this yet.)
(catch #t
(lambda ()
- (load-in-user-module config-file))
+ (load-in-user-module (or config-file (default-config-file))))
(lambda (key . args)
(caught-error key args)
(quit 1)))
diff --git a/tests/no-home.sh b/tests/no-home.sh
new file mode 100644
index 0000000..c58acd3
--- /dev/null
+++ b/tests/no-home.sh
@@ -0,0 +1,52 @@
+# GNU dmd --- Make sure dmd doesn't fail when $HOME is not writable.
+# Copyright © 2014 Ludovic Courtès <address@hidden>
+#
+# This file is part of GNU dmd.
+#
+# GNU dmd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU dmd is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU dmd. If not, see <http://www.gnu.org/licenses/>.
+
+dmd --version
+
+HOME=/nowhere
+export HOME
+
+if test -w "$HOME"
+then
+ # We cannot run this test.
+ exit 77
+fi
+
+socket="t-socket-$$"
+pid="t-pid-$$"
+
+deco="deco -s $socket"
+
+trap "rm -f $socket $pid;
+ test -f $pid && kill \`cat $pid\` || true" EXIT
+
+# Make sure 'dmd' starts even though $HOME is not writable.
+dmd -I -s "$socket" -c /dev/null -l /dev/null --pid="$pid" &
+dmd_pid="$!"
+
+# Wait until it's ready, or until it terminates.
+while ! test -f "$pid" ; do kill -0 "$dmd_pid" ; done
+
+kill -0 `cat "$pid"`
+$deco status dmd
+$deco stop dmd
+
+if kill `cat "$pid"`
+then
+ exit 1
+fi