Skip to content
Snippets Groups Projects
Commit a6ea923c authored by Damian Johnson's avatar Damian Johnson
Browse files

Test for 'python setup.py install'

This has been a hole in our tests for quite some time, biting us from time to
time during releas time...

  https://trac.torproject.org/projects/tor/ticket/15258

Just a simple test for now. Might expand this in the future with more
assertions.
parent f2eca8fe
Branches
Tags
No related merge requests found
......@@ -957,7 +957,7 @@ def call(command, default = UNDEFINED, ignore_exit_status = False):
results. This is not actually ran in a shell so pipes and other shell syntax
are not permitted.
:param str command: command to be issued
:param str,list command: command to be issued
:param object default: response if the query fails
:param bool ignore_exit_status: reports failure if our command's exit status
was non-zero
......@@ -967,11 +967,16 @@ def call(command, default = UNDEFINED, ignore_exit_status = False):
:raises: **OSError** if this fails and no default was provided
"""
if isinstance(command, str):
command_list = command.split(' ')
else:
command_list = command
try:
is_shell_command = command.split(' ')[0] in SHELL_COMMANDS
is_shell_command = command_list[0] in SHELL_COMMANDS
start_time = time.time()
process = subprocess.Popen(command.split(), stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = is_shell_command)
process = subprocess.Popen(command_list, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = is_shell_command)
stdout, stderr = process.communicate()
stdout, stderr = stdout.strip(), stderr.strip()
......
import glob
import os
import shutil
import unittest
import stem
import stem.util.system
import test.runner
class TestInstallation(unittest.TestCase):
def test_installing_stem(self):
base_directory = os.path.sep.join(__file__.split(os.path.sep)[:-3])
if not os.path.exists(os.path.sep.join([base_directory, 'setup.py'])):
test.runner.skip(self, "(only for git checkout)")
original_cwd = os.getcwd()
try:
os.chdir(base_directory)
stem.util.system.call('python setup.py install --prefix /tmp/stem_test')
site_packages_paths = glob.glob('/tmp/stem_test/lib/*/site-packages')
if len(site_packages_paths) != 1:
self.fail("We should only have a single site-packages directory, but instead had: %s" % site_packages_paths)
self.assertEqual(stem.__version__, stem.util.system.call(['python', '-c', "import sys;sys.path.insert(0, '%s');import stem;print stem.__version__" % site_packages_paths[0]])[0])
finally:
shutil.rmtree('/tmp/stem_test')
os.chdir(original_cwd)
......@@ -201,6 +201,7 @@ test.integ_tests
|test.integ.util.connection.TestConnection
|test.integ.util.proc.TestProc
|test.integ.util.system.TestSystem
|test.integ.installation.TestInstallation
|test.integ.descriptor.remote.TestDescriptorDownloader
|test.integ.descriptor.server_descriptor.TestServerDescriptor
|test.integ.descriptor.extrainfo_descriptor.TestExtraInfoDescriptor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment