#-*-python-*-
+#
+# This file is part of DisOrder.
+# Copyright (C) 2007 Richard Kettlewell
+#
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+#
"""Utility module used by tests"""
-import os,os.path,subprocess,sys
+import os,os.path,subprocess,sys,disorder
def copyfile(a,b):
"""copyfile(A, B)
"""maketrack(S)
Make track with relative path S exist"""
- trackpath = "%s/%s" % (testroot, s)
+ trackpath = "%s/tracks/%s" % (testroot, s)
trackdir = os.path.dirname(trackpath)
if not os.path.exists(trackdir):
os.makedirs(trackdir)
"--foreground",
"--config", "%s/config" % testroot],
stderr=errs)
+ disorder._configfile = "%s/config" % testroot
+ disorder._userconf = False
def stop():
"""stop()
global daemon
rc = daemon.poll()
if rc == None:
+ print " stopping daemon"
os.kill(daemon.pid, 15)
rc = daemon.wait()
print " daemon has stopped"
setup()
start(name)
try:
- test()
- except AssertionError, e:
- global failures
- failures += 1
- print e
-
- stop()
+ try:
+ test()
+ except AssertionError, e:
+ global failures
+ failures += 1
+ print e
+ finally:
+ stop()
if report:
if failures:
print " FAILED"
topsrcdir = os.path.abspath(os.getenv("topsrcdir"))
remove_dir(testroot)
os.mkdir(testroot)
-open("%s/config" % testroot, "w").write("""
-player *.ogg shell 'echo "$TRACK" >> %s/played.log'
+open("%s/config" % testroot, "w").write(
+"""player *.ogg shell 'echo "$TRACK" >> %s/played.log'
home %s
collection fs ASCII %s/tracks
scratch %s/scratch.ogg
stopword 11 12 13 14 15 16 17 18 19 20
stopword 21 22 23 24 25 26 27 28 29 30
stopword the a an and to too in on of we i am as im for is
+username fred
+password fredpass
+allow fred fredpass
+plugins ../plugins
+player *.mp3 execraw disorder-decode
+player *.ogg execraw disorder-decode
+player *.wav execraw disorder-decode
+player *.flac execraw disorder-decode
+tracklength *.mp3 disorder-tracklength
+tracklength *.ogg disorder-tracklength
+tracklength *.wav disorder-tracklength
+tracklength *.flac disorder-tracklength
""" % (testroot, testroot, testroot, testroot))
copyfile("%s/sounds/scratch.ogg" % topsrcdir,
"%s/scratch.ogg" % testroot)