diff options
-rw-r--r-- | lib/spack/spack/package.py | 7 | ||||
-rw-r--r-- | lib/spack/spack/test/__init__.py | 3 | ||||
-rw-r--r-- | lib/spack/spack/test/url_extrapolate.py | 90 | ||||
-rw-r--r-- | lib/spack/spack/test/url_parse.py | 7 | ||||
-rw-r--r-- | var/spack/mock_packages/dyninst/package.py | 11 |
5 files changed, 109 insertions, 9 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index e462562e85..f1a16fdea1 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -440,9 +440,10 @@ class Package(object): version_urls = self.version_urls() if version in version_urls: return version_urls[version] - else: - return url.substitute_version(self.nearest_url(version), - self.url_version(version)) + + # If we have no idea, try to substitute the version. + return url.substitute_version(self.nearest_url(version), + self.url_version(version)) @property diff --git a/lib/spack/spack/test/__init__.py b/lib/spack/spack/test/__init__.py index be9ac5a560..aa986662bf 100644 --- a/lib/spack/spack/test/__init__.py +++ b/lib/spack/spack/test/__init__.py @@ -51,7 +51,8 @@ test_names = ['versions', 'git_fetch', 'svn_fetch', 'hg_fetch', - 'mirror'] + 'mirror', + 'url_extrapolate'] def list_tests(): diff --git a/lib/spack/spack/test/url_extrapolate.py b/lib/spack/spack/test/url_extrapolate.py new file mode 100644 index 0000000000..514d119deb --- /dev/null +++ b/lib/spack/spack/test/url_extrapolate.py @@ -0,0 +1,90 @@ +############################################################################## +# Copyright (c) 2013, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://scalability-llnl.github.io/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License (as published by +# the Free Software Foundation) version 2.1 dated February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## +"""\ +Tests ability of spack to extrapolate URL versions from existing versions. +""" +import spack +import spack.url as url +from spack.spec import Spec +from spack.version import ver +from spack.test.mock_packages_test import * + + +class UrlExtrapolateTest(MockPackagesTest): + + def test_known_version(self): + d = spack.db.get('dyninst') + + self.assertEqual( + d.url_for_version('8.2'), 'http://www.paradyn.org/release8.2/DyninstAPI-8.2.tgz') + self.assertEqual( + d.url_for_version('8.1.2'), 'http://www.paradyn.org/release8.1.2/DyninstAPI-8.1.2.tgz') + self.assertEqual( + d.url_for_version('8.1.1'), 'http://www.paradyn.org/release8.1/DyninstAPI-8.1.1.tgz') + + + def test_extrapolate_version(self): + d = spack.db.get('dyninst') + + # Nearest URL for 8.1.1.5 is 8.1.1, and the URL there is + # release8.1/DyninstAPI-8.1.1.tgz. Only the last part matches + # the version, so only extrapolate the last part. Obviously + # dyninst has ambiguous URL versions, but we want to make sure + # extrapolation works in a well-defined way. + self.assertEqual( + d.url_for_version('8.1.1.5'), 'http://www.paradyn.org/release8.1/DyninstAPI-8.1.1.5.tgz') + + # 8.2 matches both the release8.2 component and the DyninstAPI-8.2 component. + # Extrapolation should replace both with the new version. + self.assertEqual( + d.url_for_version('8.2.3'), 'http://www.paradyn.org/release8.2.3/DyninstAPI-8.2.3.tgz') + + + def test_with_package(self): + d = spack.db.get('dyninst@8.2') + self.assertEqual(d.fetcher.url, 'http://www.paradyn.org/release8.2/DyninstAPI-8.2.tgz') + + d = spack.db.get('dyninst@8.1.2') + self.assertEqual(d.fetcher.url, 'http://www.paradyn.org/release8.1.2/DyninstAPI-8.1.2.tgz') + + d = spack.db.get('dyninst@8.1.1') + self.assertEqual(d.fetcher.url, 'http://www.paradyn.org/release8.1/DyninstAPI-8.1.1.tgz') + + + def test_concrete_package(self): + s = Spec('dyninst@8.2') + s.concretize() + d = spack.db.get(s) + self.assertEqual(d.fetcher.url, 'http://www.paradyn.org/release8.2/DyninstAPI-8.2.tgz') + + s = Spec('dyninst@8.1.2') + s.concretize() + d = spack.db.get(s) + self.assertEqual(d.fetcher.url, 'http://www.paradyn.org/release8.1.2/DyninstAPI-8.1.2.tgz') + + s = Spec('dyninst@8.1.1') + s.concretize() + d = spack.db.get(s) + self.assertEqual(d.fetcher.url, 'http://www.paradyn.org/release8.1/DyninstAPI-8.1.1.tgz') diff --git a/lib/spack/spack/test/url_parse.py b/lib/spack/spack/test/url_parse.py index a03d6098f1..7a4d201d90 100644 --- a/lib/spack/spack/test/url_parse.py +++ b/lib/spack/spack/test/url_parse.py @@ -281,11 +281,16 @@ class UrlParseTest(unittest.TestCase): 'synergy', '1.3.6p2', 'http://synergy.googlecode.com/files/synergy-1.3.6p2-MacOSX-Universal.zip') - def test_mvapich2_version(self): + def test_mvapich2_19_version(self): self.check( 'mvapich2', '1.9', 'http://mvapich.cse.ohio-state.edu/download/mvapich2/mv2/mvapich2-1.9.tgz') + def test_mvapich2_19_version(self): + self.check( + 'mvapich2', '2.0', + 'http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.0.tar.gz') + def test_hdf5_version(self): self.check( 'hdf5', '1.8.13', diff --git a/var/spack/mock_packages/dyninst/package.py b/var/spack/mock_packages/dyninst/package.py index 7657e2c33f..7998578da1 100644 --- a/var/spack/mock_packages/dyninst/package.py +++ b/var/spack/mock_packages/dyninst/package.py @@ -26,11 +26,14 @@ from spack import * class Dyninst(Package): homepage = "https://paradyn.org" - url = "http://www.dyninst.org/sites/default/files/downloads/dyninst/8.1.2/DyninstAPI-8.1.2.tgz" - list_url = "http://www.dyninst.org/downloads/dyninst-8.x" + url = "http://www.paradyn.org/release8.1/DyninstAPI-8.1.1.tgz" - version('8.1.2', 'bf03b33375afa66fe0efa46ce3f4b17a') - version('8.1.1', '1f8743e3a5662b25ce64a7edf647e77d') + version('8.2', 'cxyzab', + url='http://www.paradyn.org/release8.2/DyninstAPI-8.2.tgz') + version('8.1.2', 'bcxyza', + url='http://www.paradyn.org/release8.1.2/DyninstAPI-8.1.2.tgz') + version('8.1.1', 'abcxyz', + url='http://www.paradyn.org/release8.1/DyninstAPI-8.1.1.tgz') depends_on("libelf") depends_on("libdwarf") |