Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Alan Weaver committed Oct 17, 2015
1 parent 2c48447 commit 6251663
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion py/desiutil/install/git_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def git_version(git='git'):
myversion = '0.0.1.dev'
try:
p = Popen([git, "describe", "--tags", "--dirty", "--always"], stdout=PIPE)
except EnvironmentError:
except OSError:
return myversion
out = p.communicate()[0]
if p.returncode != 0:
Expand Down
43 changes: 42 additions & 1 deletion py/desiutil/test/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
from argparse import Namespace
from subprocess import Popen, PIPE
from shutil import rmtree
from ..install import dependencies, desiInstall_options, get_product_version, set_build_type, svn_version
from ..install import (dependencies, desiInstall_options, get_product_version,
get_svn_devstr, git_version,
most_recent_svn_tag, set_build_type, svn_version)
#
#
#
Expand Down Expand Up @@ -165,6 +167,45 @@ def test_get_product_version(self):
out = get_product_version(pv)
self.assertEqual(out, (u'desihub/desispec', 'desispec', '2.0.0'))

def test_get_svn_devstr(self):
"""Test svn revision number determination.
"""
n = get_svn_devstr('frobulate')
self.assertEqual(n,'0')
if self.has_subversion:
if 'FROBULATE' in os.environ:
old_frob = os.environ['FROBULATE']
else:
old_frob = None
os.environ['FROBULATE'] = self.data_dir
n = get_svn_devstr('frobulate')
self.assertEqual(n,'0')
if old_frob is None:
del os.environ['FROBULATE']
else:
os.environ['FROBULATE'] = old_frob

def test_git_version(self):
"""Test automated determination of git version.
"""
v = git_version('/no/such/executable')
self.assertEqual(v,'0.0.1.dev')
v = git_version('false')
self.assertEqual(v,'0.0.1.dev')
v = git_version('echo')
self.assertEqual(v,'describe --tags --dirty --always')

def test_most_recent_svn_tag(self):
"""Test the processing of svn tag lists.
"""
if self.has_subversion:
tag = most_recent_svn_tag(self.svn_url+'/tags')
self.assertEqual(tag,'0.2.1')
tag = most_recent_svn_tag(self.svn_url+'/tags',username=os.environ['USER'])
self.assertEqual(tag,'0.2.1')
tag = most_recent_svn_tag(self.svn_url+'/branches')
self.assertEqual(tag,'0.0.0')

def test_set_build_type(self):
"""Test the determination of the build type.
"""
Expand Down

0 comments on commit 6251663

Please sign in to comment.