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
5fda7daf
Commit
5fda7daf
authored
9 years ago
by
Gregory Becker
Committed by
Todd Gamblin
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
an ordered database test
parent
d0e22b22
Branches
zdc_sipmontile_ai
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/spack/spack/test/__init__.py
+2
-1
2 additions, 1 deletion
lib/spack/spack/test/__init__.py
lib/spack/spack/test/database.py
+104
-0
104 additions, 0 deletions
lib/spack/spack/test/database.py
with
106 additions
and
1 deletion
lib/spack/spack/test/__init__.py
+
2
−
1
View file @
5fda7daf
...
...
@@ -56,7 +56,8 @@
'
spec_yaml
'
,
'
optional_deps
'
,
'
make_executable
'
,
'
configure_guess
'
]
'
configure_guess
'
,
'
database
'
]
def
list_tests
():
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/test/database.py
0 → 100644
+
104
−
0
View file @
5fda7daf
##############################################################################
# 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
##############################################################################
"""
These tests check the database is functioning properly,
both in memory and in its file
"""
import
unittest
from
llnl.util.lock
import
*
from
llnl.util.filesystem
import
join_path
import
spack
from
spack.database
import
Database
class
DatabaseTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
original_db
=
spack
.
installed_db
spack
.
installed_db
=
Database
(
self
.
original_db
.
_root
,
"
_test_index.yaml
"
)
self
.
file_path
=
join_path
(
self
.
original_db
.
_root
,
"
_test_index.yaml
"
)
if
os
.
path
.
exists
(
self
.
file_path
):
os
.
remove
(
self
.
file_path
)
def
tearDown
(
self
):
spack
.
installed_db
=
self
.
original_db
os
.
remove
(
self
.
file_path
)
def
_test_read_from_install_tree
(
self
):
specs
=
spack
.
install_layout
.
all_specs
()
spack
.
installed_db
.
read_database
()
spack
.
installed_db
.
write
()
for
sph
in
spack
.
installed_db
.
_data
:
self
.
assertTrue
(
sph
[
'
spec
'
]
in
specs
)
self
.
assertEqual
(
len
(
specs
),
len
(
spack
.
installed_db
.
_data
))
def
_test_remove_and_add
(
self
):
specs
=
spack
.
install_layout
.
all_specs
()
spack
.
installed_db
.
remove
(
specs
[
len
(
specs
)
-
1
])
for
sph
in
spack
.
installed_db
.
_data
:
self
.
assertTrue
(
sph
[
'
spec
'
]
in
specs
[:
len
(
specs
)
-
1
])
self
.
assertEqual
(
len
(
specs
)
-
1
,
len
(
spack
.
installed_db
.
_data
))
spack
.
installed_db
.
add
(
specs
[
len
(
specs
)
-
1
],
""
)
for
sph
in
spack
.
installed_db
.
_data
:
self
.
assertTrue
(
sph
[
'
spec
'
]
in
specs
)
self
.
assertEqual
(
len
(
specs
),
len
(
spack
.
installed_db
.
_data
))
def
_test_read_from_file
(
self
):
spack
.
installed_db
.
read_database
()
size
=
len
(
spack
.
installed_db
.
_data
)
spack
.
installed_db
.
_data
=
spack
.
installed_db
.
_data
[
1
:]
os
.
utime
(
spack
.
installed_db
.
_file_path
,
None
)
spack
.
installed_db
.
read_database
()
self
.
assertEqual
(
size
,
len
(
spack
.
installed_db
.
_data
))
specs
=
spack
.
install_layout
.
all_specs
()
self
.
assertEqual
(
size
,
len
(
specs
))
for
sph
in
spack
.
installed_db
.
_data
:
self
.
assertTrue
(
sph
[
'
spec
'
]
in
specs
)
def
_test_write_to_file
(
self
):
spack
.
installed_db
.
read_database
()
size
=
len
(
spack
.
installed_db
.
_data
)
real_data
=
spack
.
installed_db
.
_data
spack
.
installed_db
.
_data
=
real_data
[:
size
-
1
]
spack
.
installed_db
.
write
()
spack
.
installed_db
.
_data
=
real_data
os
.
utime
(
spack
.
installed_db
.
_file_path
,
None
)
spack
.
installed_db
.
read_database
()
self
.
assertEqual
(
size
-
1
,
len
(
spack
.
installed_db
.
_data
))
specs
=
spack
.
install_layout
.
all_specs
()
self
.
assertEqual
(
size
,
len
(
specs
))
for
sph
in
spack
.
installed_db
.
_data
:
self
.
assertTrue
(
sph
[
'
spec
'
]
in
specs
[:
size
-
1
])
def
test_ordered_test
(
self
):
self
.
_test_read_from_install_tree
()
self
.
_test_remove_and_add
()
self
.
_test_read_from_file
()
self
.
_test_write_to_file
()
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