From e61f1e90e408c53332ce96f95c4def88f0bb9044 Mon Sep 17 00:00:00 2001 From: Mark Seaborn Date: Tue, 28 Oct 2008 22:29:24 +0000 Subject: [PATCH] Add an almost end-to-end test which checks the output of a command --- tests/basetest.py | 32 +++++++++++++------------ tests/testendtoend.py | 55 +++++++++++++++++++++++++++++++++++++++++++ zeroinstall/injector/fetch.py | 5 +++- 3 files changed, 76 insertions(+), 16 deletions(-) create mode 100644 tests/testendtoend.py diff --git a/tests/basetest.py b/tests/basetest.py index 0ba8a31..e994343 100755 --- a/tests/basetest.py +++ b/tests/basetest.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2.4 -import sys, tempfile, os, shutil, StringIO +import sys, tempfile, os, StringIO import unittest import logging import warnings @@ -26,10 +26,12 @@ empty_feed = qdom.parse(StringIO.StringIO(""" + Test + Placeholder + + + + + + +""" % {"dir": os.path.abspath(os.path.dirname(__file__))}) + policy = autopolicy.AutoPolicy( + feed_file, download_only=True, dry_run=False) + policy.download_and_execute([]) + root_impl = policy.get_implementation( + iface_cache.get_interface(policy.root)) + cmd_path = os.path.join(run._get_implementation_path(root_impl.id), + root_impl.main) + proc = subprocess.Popen([cmd_path], stdout=subprocess.PIPE) + stdout, stderr = proc.communicate() + self.assertEquals(proc.wait(), 0) + self.assertEquals(stdout, "Hello World\n") + + +suite = unittest.makeSuite(TestEndToEnd) +if __name__ == '__main__': + sys.argv.append('-v') + unittest.main() diff --git a/zeroinstall/injector/fetch.py b/zeroinstall/injector/fetch.py index c067901..aacdb7e 100644 --- a/zeroinstall/injector/fetch.py +++ b/zeroinstall/injector/fetch.py @@ -268,7 +268,10 @@ class Fetcher(object): from zeroinstall.zerostore import unpack url = download_source.url - if not (url.startswith('http:') or url.startswith('https:') or url.startswith('ftp:')): + if not (url.startswith('http:') or + url.startswith('https:') or + url.startswith('ftp:') or + url.startswith('/')): raise SafeException("Unknown scheme in download URL '%s'" % url) mime_type = download_source.type -- 2.11.4.GIT