summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohn W. Parent <45471568+johnwparent@users.noreply.github.com>2022-04-15 18:44:44 -0400
committerGitHub <noreply@github.com>2022-04-15 22:44:44 +0000
commit0f80a5a9d5e91e2b303804709564bdf3b35b4c13 (patch)
tree53694d3201efcfcbb9d0a18e1a34f08b4b748f54 /lib
parentc8f85ebea3c904ae5d5588b1a37b0d3aba6548d8 (diff)
downloadspack-0f80a5a9d5e91e2b303804709564bdf3b35b4c13.tar.gz
spack-0f80a5a9d5e91e2b303804709564bdf3b35b4c13.tar.bz2
spack-0f80a5a9d5e91e2b303804709564bdf3b35b4c13.tar.xz
spack-0f80a5a9d5e91e2b303804709564bdf3b35b4c13.zip
Remove assert in favor of error message (#29797)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/create.py2
-rw-r--r--lib/spack/spack/test/cmd/create.py36
-rw-r--r--lib/spack/spack/util/url.py3
3 files changed, 21 insertions, 20 deletions
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index 14463127d3..1e3e89760b 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -800,7 +800,7 @@ def get_versions(args, name):
spack.util.url.require_url_format(args.url)
if args.url.startswith('file://'):
valid_url = False # No point in spidering these
- except AssertionError:
+ except ValueError:
valid_url = False
if args.url is not None and args.template != 'bundle' and valid_url:
diff --git a/lib/spack/spack/test/cmd/create.py b/lib/spack/spack/test/cmd/create.py
index 0ea357e72d..e7d8d7f8e9 100644
--- a/lib/spack/spack/test/cmd/create.py
+++ b/lib/spack/spack/test/cmd/create.py
@@ -26,7 +26,7 @@ def parser():
@pytest.mark.parametrize('args,name,expected', [
# Basic package cases
- (['test-package'], 'test-package',
+ (['/test-package'], 'test-package',
[r'TestPackage(Package)', r'def install(self']),
(['-n', 'test-named-package', 'file://example.tar.gz'],
'test-named-package',
@@ -35,44 +35,44 @@ def parser():
[r'Example(Package)', r'def install(self']),
# Template-specific cases
- (['-t', 'autoreconf', 'test-autoreconf'], 'test-autoreconf',
+ (['-t', 'autoreconf', '/test-autoreconf'], 'test-autoreconf',
[r'TestAutoreconf(AutotoolsPackage)', r"depends_on('autoconf",
r'def autoreconf(self', r'def configure_args(self']),
- (['-t', 'autotools', 'test-autotools'], 'test-autotools',
+ (['-t', 'autotools', '/test-autotools'], 'test-autotools',
[r'TestAutotools(AutotoolsPackage)', r'def configure_args(self']),
- (['-t', 'bazel', 'test-bazel'], 'test-bazel',
+ (['-t', 'bazel', '/test-bazel'], 'test-bazel',
[r'TestBazel(Package)', r"depends_on('bazel", r'bazel()']),
- (['-t', 'bundle', 'test-bundle'], 'test-bundle',
+ (['-t', 'bundle', '/test-bundle'], 'test-bundle',
[r'TestBundle(BundlePackage)']),
- (['-t', 'cmake', 'test-cmake'], 'test-cmake',
+ (['-t', 'cmake', '/test-cmake'], 'test-cmake',
[r'TestCmake(CMakePackage)', r'def cmake_args(self']),
- (['-t', 'intel', 'test-intel'], 'test-intel',
+ (['-t', 'intel', '/test-intel'], 'test-intel',
[r'TestIntel(IntelPackage)', r'setup_environment']),
- (['-t', 'makefile', 'test-makefile'], 'test-makefile',
+ (['-t', 'makefile', '/test-makefile'], 'test-makefile',
[r'TestMakefile(MakefilePackage)', r'def edit(self', r'makefile']),
- (['-t', 'meson', 'test-meson'], 'test-meson',
+ (['-t', 'meson', '/test-meson'], 'test-meson',
[r'TestMeson(MesonPackage)', r'def meson_args(self']),
- (['-t', 'octave', 'test-octave'], 'octave-test-octave',
+ (['-t', 'octave', '/test-octave'], 'octave-test-octave',
[r'OctaveTestOctave(OctavePackage)', r"extends('octave",
r"depends_on('octave"]),
- (['-t', 'perlbuild', 'test-perlbuild'], 'perl-test-perlbuild',
+ (['-t', 'perlbuild', '/test-perlbuild'], 'perl-test-perlbuild',
[r'PerlTestPerlbuild(PerlPackage)', r"depends_on('perl-module-build",
r'def configure_args(self']),
- (['-t', 'perlmake', 'test-perlmake'], 'perl-test-perlmake',
+ (['-t', 'perlmake', '/test-perlmake'], 'perl-test-perlmake',
[r'PerlTestPerlmake(PerlPackage)', r"depends_on('perl-",
r'def configure_args(self']),
- (['-t', 'python', 'test-python'], 'py-test-python',
+ (['-t', 'python', '/test-python'], 'py-test-python',
[r'PyTestPython(PythonPackage)', r"depends_on('py-",
r'def global_options(self', r'def install_options(self']),
- (['-t', 'qmake', 'test-qmake'], 'test-qmake',
+ (['-t', 'qmake', '/test-qmake'], 'test-qmake',
[r'TestQmake(QMakePackage)', r'def qmake_args(self']),
- (['-t', 'r', 'test-r'], 'r-test-r',
+ (['-t', 'r', '/test-r'], 'r-test-r',
[r'RTestR(RPackage)', r"depends_on('r-", r'def configure_args(self']),
- (['-t', 'scons', 'test-scons'], 'test-scons',
+ (['-t', 'scons', '/test-scons'], 'test-scons',
[r'TestScons(SConsPackage)', r'def build_args(self']),
- (['-t', 'sip', 'test-sip'], 'py-test-sip',
+ (['-t', 'sip', '/test-sip'], 'py-test-sip',
[r'PyTestSip(SIPPackage)', r'def configure_args(self']),
- (['-t', 'waf', 'test-waf'], 'test-waf',
+ (['-t', 'waf', '/test-waf'], 'test-waf',
[r'TestWaf(WafPackage)', r'configure_args()'])
])
def test_create_template(parser, mock_test_repo, args, name, expected):
diff --git a/lib/spack/spack/util/url.py b/lib/spack/spack/util/url.py
index 340268c6cc..824b5fed57 100644
--- a/lib/spack/spack/util/url.py
+++ b/lib/spack/spack/util/url.py
@@ -344,7 +344,8 @@ def parse_git_url(url):
def require_url_format(url):
ut = re.search(r'^(file://|http://|https://|ftp://|s3://|gs://|ssh://|git://|/)', url)
- assert ut is not None
+ if not ut:
+ raise ValueError('Invalid url format from url: %s' % url)
def escape_file_url(url):