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
8878c11c
Commit
8878c11c
authored
4 years ago
by
Tamara Dahlgren
Browse files
Options
Downloads
Patches
Plain Diff
Added test results filter and log display support
parent
3f4dd14f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/spack/spack/cmd/test.py
+60
-25
60 additions, 25 deletions
lib/spack/spack/cmd/test.py
with
60 additions
and
25 deletions
lib/spack/spack/cmd/test.py
+
60
−
25
View file @
8878c11c
...
...
@@ -101,8 +101,13 @@ def setup_parser(subparser):
# Results
results_parser
=
sp
.
add_parser
(
'
results
'
,
help
=
test_results
.
__doc__
)
results_parser
.
add_argument
(
'
names
'
,
nargs
=
argparse
.
REMAINDER
,
help
=
"
Test suites for which to print results
"
)
'
-l
'
,
'
--logs
'
,
action
=
'
store_true
'
,
help
=
"
print the test log for each matching package
"
)
results_parser
.
add_argument
(
'
-f
'
,
'
--failed
'
,
action
=
'
store_true
'
,
help
=
"
only show results for failed tests
"
)
arguments
.
add_common_arguments
(
results_parser
,
[
'
constraint
'
])
# Remove
remove_parser
=
sp
.
add_parser
(
'
remove
'
,
help
=
test_remove
.
__doc__
)
...
...
@@ -240,37 +245,67 @@ def test_status(args):
tty
.
msg
(
"
Test suite %s completed
"
%
test_suite
.
name
)
def
_report_suite_results
(
test_suite
,
args
):
"""
Report the relevant test suite results.
"""
# TODO: Make this handle capability tests too
# The results file may turn out to be a placeholder for future work
specs
=
args
.
specs
()
test_specs
=
{
test_suite
.
test_pkg_id
(
s
):
s
for
s
in
test_suite
.
specs
if
s
in
specs
}
if
not
test_specs
:
return
if
os
.
path
.
exists
(
test_suite
.
results_file
):
results_desc
=
'
Failing results
'
if
args
.
failed
else
'
Results
'
matching
=
"
, spec matching
'
{0}
'"
.
format
(
'
'
.
join
(
args
.
constraint
))
\
if
args
.
constraint
else
''
tty
.
msg
(
"
{0} for test suite
'
{1}
'
{2}:
"
.
format
(
results_desc
,
test_suite
.
name
,
matching
))
results
=
{}
with
open
(
test_suite
.
results_file
,
'
r
'
)
as
f
:
for
line
in
f
:
pkg_id
,
status
=
line
.
split
()
results
[
pkg_id
]
=
status
for
pkg_id
in
test_specs
:
if
pkg_id
in
results
:
status
=
results
[
pkg_id
]
if
args
.
failed
and
status
!=
'
FAILED
'
:
continue
msg
=
"
{0} {1}
"
.
format
(
pkg_id
,
status
)
if
args
.
logs
:
spec
=
test_specs
[
pkg_id
]
log_file
=
test_suite
.
log_file_for_spec
(
spec
)
if
os
.
path
.
isfile
(
log_file
):
with
open
(
log_file
,
'
r
'
)
as
f
:
msg
+=
'
\n
{0}
'
.
format
(
''
.
join
(
f
.
readlines
()))
tty
.
msg
(
msg
)
else
:
msg
=
"
Test %s has no results.
\n
"
%
test_suite
.
name
msg
+=
"
Check if it is running with
"
msg
+=
"
`spack test status %s`
"
%
test_suite
.
name
tty
.
msg
(
msg
)
def
test_results
(
args
):
"""
Get the results from Spack test suites (default all).
"""
if
args
.
names
:
test_suites
=
[]
for
name
in
args
.
names
:
test_suite
=
spack
.
install_test
.
get_test_suite
(
name
)
if
test_suit
e
:
test_suites
.
append
(
test_suite
)
else
:
tty
.
msg
(
"
No test suite
%s
found in test stage
"
%
name
)
name
=
''
if
args
.
constraint
and
'
:
'
in
args
.
constraint
[
0
]:
name
,
args
.
constraint
[
0
]
=
args
.
constraint
[
0
].
split
(
'
:
'
)
if
nam
e
:
test_suites
=
[
spack
.
install_test
.
get_
test_suite
(
name
)]
if
not
test_suites
:
tty
.
msg
(
"
No test suite
{0}
found in test stage
"
.
format
(
name
)
)
else
:
test_suites
=
spack
.
install_test
.
get_all_test_suites
()
if
not
test_suites
:
tty
.
msg
(
"
No test suites with results to report
"
)
# TODO: Make this handle capability tests too
# The results file may turn out to be a placeholder for future work
for
test_suite
in
test_suites
:
results_file
=
test_suite
.
results_file
if
os
.
path
.
exists
(
results_file
):
msg
=
"
Results for test suite %s:
\n
"
%
test_suite
.
name
with
open
(
results_file
,
'
r
'
)
as
f
:
lines
=
f
.
readlines
()
for
line
in
lines
:
msg
+=
"
%s
"
%
line
tty
.
msg
(
msg
)
else
:
msg
=
"
Test %s has no results.
\n
"
%
test_suite
.
name
msg
+=
"
Check if it is running with
"
msg
+=
"
`spack test status %s`
"
%
test_suite
.
name
tty
.
msg
(
msg
)
_report_suite_results
(
test_suite
,
args
)
def
test_remove
(
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