]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
startstop_node.py: improve test coverage a little bit
authorBrian Warner <warner@lothar.com>
Wed, 19 Sep 2007 08:50:27 +0000 (01:50 -0700)
committerBrian Warner <warner@lothar.com>
Wed, 19 Sep 2007 08:50:27 +0000 (01:50 -0700)
src/allmydata/scripts/startstop_node.py
src/allmydata/test/test_runner.py

index 51a59403581da8aba07bcd8674cf831217bc359c..d6420fffb503d97d61e397e2a863564030b99a5f 100644 (file)
@@ -69,7 +69,7 @@ def do_start(basedir, config, out=sys.stdout, err=sys.stderr):
         print >>err, "%s does not look like a node directory" % basedir
         if not os.path.isdir(basedir):
             print >>err, " in fact, it doesn't look like a directory at all!"
-        sys.exit(1)
+        return 1
     twistd = find_twistd()
     fileutil.make_dirs(os.path.join(basedir, "logs"))
     cmd = ["python", twistd, "-y", tac, "--logfile", "logs/twistd.log"]
index 60afc8ce10b01b5f3ba9e26db67b1da3fe03d1fa..d9c261c9667c937d11c96f2f9a13ce5400bbc51b 100644 (file)
@@ -184,4 +184,29 @@ class RunNode(unittest.TestCase, testutil.PollMixin):
         d.addCallback(_stop)
         return d
 
+    def test_baddir(self):
+        basedir = self.workdir("test_baddir")
+        fileutil.make_dirs(basedir)
+        argv = ["--quiet", "start", "--basedir", basedir]
+        out,err = StringIO(), StringIO()
+        rc = runner.runner(argv, stdout=out, stderr=err)
+        self.failUnlessEqual(rc, 1)
+        self.failUnless("does not look like a node directory" in err.getvalue())
+
+        argv = ["--quiet", "stop", "--basedir", basedir]
+        out,err = StringIO(), StringIO()
+        rc = runner.runner(argv, stdout=out, stderr=err)
+        self.failUnlessEqual(rc, 2)
+        self.failUnless("does not look like a running node directory"
+                        in err.getvalue())
+
+        not_a_dir = os.path.join(basedir, "bogus")
+        argv = ["--quiet", "start", "--basedir", not_a_dir]
+        out,err = StringIO(), StringIO()
+        rc = runner.runner(argv, stdout=out, stderr=err)
+        self.failUnlessEqual(rc, 1)
+        self.failUnless("does not look like a node directory" in err.getvalue())
+        self.failUnless("doesn't look like a directory at all"
+                        in err.getvalue())
+