From: Brian Warner Date: Wed, 19 Sep 2007 08:50:27 +0000 (-0700) Subject: startstop_node.py: improve test coverage a little bit X-Git-Tag: allmydata-tahoe-0.6.0~64 X-Git-Url: https://git.rkrishnan.org/listings/index.php?a=commitdiff_plain;h=e2f19825d9204008af6608c22d9a6a5301d7899b;p=tahoe-lafs%2Ftahoe-lafs.git startstop_node.py: improve test coverage a little bit --- diff --git a/src/allmydata/scripts/startstop_node.py b/src/allmydata/scripts/startstop_node.py index 51a59403..d6420fff 100644 --- a/src/allmydata/scripts/startstop_node.py +++ b/src/allmydata/scripts/startstop_node.py @@ -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"] diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py index 60afc8ce..d9c261c9 100644 --- a/src/allmydata/test/test_runner.py +++ b/src/allmydata/test/test_runner.py @@ -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()) +