Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
285646bb
Commit
285646bb
authored
9 years ago
by
Todd Gamblin
Browse files
Options
Downloads
Plain Diff
Merge pull request #981 from epfl-scitas/tests/unit_test_for_968
find : add unit tests
parents
2f18a344
7303c387
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/spack/spack/cmd/find.py
+24
-16
24 additions, 16 deletions
lib/spack/spack/cmd/find.py
lib/spack/spack/test/__init__.py
+1
-1
1 addition, 1 deletion
lib/spack/spack/test/__init__.py
lib/spack/spack/test/cmd/find.py
+60
-0
60 additions, 0 deletions
lib/spack/spack/test/cmd/find.py
with
85 additions
and
17 deletions
lib/spack/spack/cmd/find.py
+
24
−
16
View file @
285646bb
...
...
@@ -180,6 +180,29 @@ def fmt(s):
"
deps, short).
"
%
mode
)
# NOQA: ignore=E501
def
query_arguments
(
args
):
# Check arguments
if
args
.
explicit
and
args
.
implicit
:
tty
.
error
(
'
You can
\'
t pass -E and -e options simultaneously.
'
)
raise
SystemExit
(
1
)
# Set up query arguments.
installed
,
known
=
True
,
any
if
args
.
only_missing
:
installed
=
False
elif
args
.
missing
:
installed
=
any
if
args
.
unknown
:
known
=
False
explicit
=
any
if
args
.
explicit
:
explicit
=
True
if
args
.
implicit
:
explicit
=
False
q_args
=
{
'
installed
'
:
installed
,
'
known
'
:
known
,
"
explicit
"
:
explicit
}
return
q_args
def
find
(
parser
,
args
):
# Filter out specs that don't exist.
query_specs
=
spack
.
cmd
.
parse_specs
(
args
.
query_specs
)
...
...
@@ -194,22 +217,7 @@ def find(parser, args):
if
not
query_specs
:
return
# Set up query arguments.
installed
,
known
=
True
,
any
if
args
.
only_missing
:
installed
=
False
elif
args
.
missing
:
installed
=
any
if
args
.
unknown
:
known
=
False
explicit
=
any
if
args
.
explicit
:
explicit
=
False
if
args
.
implicit
:
explicit
=
True
q_args
=
{
'
installed
'
:
installed
,
'
known
'
:
known
,
"
explicit
"
:
explicit
}
q_args
=
query_arguments
(
args
)
# Get all the specs the user asked for
if
not
query_specs
:
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/test/__init__.py
+
1
−
1
View file @
285646bb
...
...
@@ -38,7 +38,7 @@
'
svn_fetch
'
,
'
hg_fetch
'
,
'
mirror
'
,
'
modules
'
,
'
url_extrapolate
'
,
'
cc
'
,
'
link_tree
'
,
'
spec_yaml
'
,
'
optional_deps
'
,
'
make_executable
'
,
'
configure_guess
'
,
'
lock
'
,
'
database
'
,
'
namespace_trie
'
,
'
yaml
'
,
'
sbang
'
,
'
environment
'
,
'
namespace_trie
'
,
'
yaml
'
,
'
sbang
'
,
'
environment
'
,
'
cmd.find
'
,
'
cmd.uninstall
'
,
'
cmd.test_install
'
]
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/test/cmd/find.py
0 → 100644
+
60
−
0
View file @
285646bb
##############################################################################
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/llnl/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 Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, 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 Lesser 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
##############################################################################
import
spack.cmd.find
import
unittest
class
Bunch
(
object
):
def
__init__
(
self
,
**
kwargs
):
self
.
__dict__
.
update
(
kwargs
)
class
FindTest
(
unittest
.
TestCase
):
def
test_query_arguments
(
self
):
query_arguments
=
spack
.
cmd
.
find
.
query_arguments
# Default arguments
args
=
Bunch
(
only_missing
=
False
,
missing
=
False
,
unknown
=
False
,
explicit
=
False
,
implicit
=
False
)
q_args
=
query_arguments
(
args
)
self
.
assertTrue
(
'
installed
'
in
q_args
)
self
.
assertTrue
(
'
known
'
in
q_args
)
self
.
assertTrue
(
'
explicit
'
in
q_args
)
self
.
assertEqual
(
q_args
[
'
installed
'
],
True
)
self
.
assertEqual
(
q_args
[
'
known
'
],
any
)
self
.
assertEqual
(
q_args
[
'
explicit
'
],
any
)
# Check that explicit works correctly
args
.
explicit
=
True
q_args
=
query_arguments
(
args
)
self
.
assertEqual
(
q_args
[
'
explicit
'
],
True
)
args
.
explicit
=
False
args
.
implicit
=
True
q_args
=
query_arguments
(
args
)
self
.
assertEqual
(
q_args
[
'
explicit
'
],
False
)
args
.
explicit
=
True
self
.
assertRaises
(
SystemExit
,
query_arguments
,
args
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment