refactor
This commit is contained in:
committed by
Tamara Dahlgren
parent
749ab2e79d
commit
99364b9c3f
@@ -6,12 +6,13 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import collections
|
||||||
|
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
import llnl.util.filesystem as fs
|
import llnl.util.filesystem as fs
|
||||||
|
|
||||||
import spack.caches
|
import spack.caches
|
||||||
import spack.cmd
|
import spack.cmd.test
|
||||||
import spack.cmd.common.arguments as arguments
|
import spack.cmd.common.arguments as arguments
|
||||||
import spack.repo
|
import spack.repo
|
||||||
import spack.stage
|
import spack.stage
|
||||||
@@ -89,7 +90,8 @@ def clean(parser, args):
|
|||||||
|
|
||||||
if args.test_stage:
|
if args.test_stage:
|
||||||
tty.msg("Removing files in test stage")
|
tty.msg("Removing files in test stage")
|
||||||
spack.cmd.test.test_remove(NamedTuple({'name': None}))
|
test_remove_args = collections.namedtuple('args', ['name'])(None)
|
||||||
|
spack.cmd.test.test_remove(test_remove_args)
|
||||||
|
|
||||||
if args.python_cache:
|
if args.python_cache:
|
||||||
tty.msg('Removing python cache files')
|
tty.msg('Removing python cache files')
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ def test_run(args):
|
|||||||
reporter.specs = specs_to_test
|
reporter.specs = specs_to_test
|
||||||
|
|
||||||
# test_stage_dir
|
# test_stage_dir
|
||||||
stage = _get_stage(test_name)
|
stage = get_stage(test_name)
|
||||||
fs.mkdirp(stage)
|
fs.mkdirp(stage)
|
||||||
|
|
||||||
with reporter('test', stage):
|
with reporter('test', stage):
|
||||||
@@ -170,7 +170,7 @@ def test_run(args):
|
|||||||
|
|
||||||
def test_list(args):
|
def test_list(args):
|
||||||
"""List tests that are running or have available results."""
|
"""List tests that are running or have available results."""
|
||||||
stage_dir = _get_stage()
|
stage_dir = get_stage()
|
||||||
tests = os.listdir(stage_dir)
|
tests = os.listdir(stage_dir)
|
||||||
|
|
||||||
# Filter tests by filter argument
|
# Filter tests by filter argument
|
||||||
@@ -200,7 +200,7 @@ def match(t, f):
|
|||||||
def test_status(args):
|
def test_status(args):
|
||||||
"""Get the current status for a particular Spack test."""
|
"""Get the current status for a particular Spack test."""
|
||||||
name = args.name
|
name = args.name
|
||||||
stage = _get_stage(name)
|
stage = get_stage(name)
|
||||||
|
|
||||||
if os.path.exists(stage):
|
if os.path.exists(stage):
|
||||||
# TODO: Make this handle capability tests too
|
# TODO: Make this handle capability tests too
|
||||||
@@ -212,7 +212,7 @@ def test_status(args):
|
|||||||
def test_results(args):
|
def test_results(args):
|
||||||
"""Get the results for a particular Spack test."""
|
"""Get the results for a particular Spack test."""
|
||||||
name = args.name
|
name = args.name
|
||||||
stage = _get_stage(name)
|
stage = get_stage(name)
|
||||||
|
|
||||||
# TODO: Make this handle capability tests too
|
# TODO: Make this handle capability tests too
|
||||||
# The results file may turn out to be a placeholder for future work
|
# The results file may turn out to be a placeholder for future work
|
||||||
@@ -241,7 +241,7 @@ def test_remove(args):
|
|||||||
|
|
||||||
Removed tests can no longer be accessed for results or status, and will not
|
Removed tests can no longer be accessed for results or status, and will not
|
||||||
appear in `spack test list` results."""
|
appear in `spack test list` results."""
|
||||||
stage_dir = _get_stage(args.name)
|
stage_dir = get_stage(args.name)
|
||||||
if args.name:
|
if args.name:
|
||||||
shutil.rmtree(stage_dir)
|
shutil.rmtree(stage_dir)
|
||||||
else:
|
else:
|
||||||
@@ -252,7 +252,7 @@ def test(parser, args):
|
|||||||
globals()['test_%s' % args.test_command](args)
|
globals()['test_%s' % args.test_command](args)
|
||||||
|
|
||||||
|
|
||||||
def _get_stage(name=None):
|
def get_stage(name=None):
|
||||||
"""
|
"""
|
||||||
Return the test stage for the named test or the overall test stage.
|
Return the test stage for the named test or the overall test stage.
|
||||||
"""
|
"""
|
||||||
@@ -265,5 +265,5 @@ def _get_results_file(name):
|
|||||||
"""
|
"""
|
||||||
Return the results file for the named test.
|
Return the results file for the named test.
|
||||||
"""
|
"""
|
||||||
stage = _get_stage(name)
|
stage = get_stage(name)
|
||||||
return os.path.join(stage, 'results.txt')
|
return os.path.join(stage, 'results.txt')
|
||||||
|
|||||||
@@ -1618,10 +1618,7 @@ def do_test(self, name, remove_directory=False, dirty=False):
|
|||||||
# Clear test failures
|
# Clear test failures
|
||||||
self.test_failures = []
|
self.test_failures = []
|
||||||
|
|
||||||
self.test_stage = Prefix(os.path.join(
|
self.test_stage = Prefix(spack.cmd.test.get_stage(name))
|
||||||
sup.canonicalize_path(
|
|
||||||
spack.config.get('config:test_stage', os.getcwd())),
|
|
||||||
name))
|
|
||||||
if not os.path.exists(self.test_stage):
|
if not os.path.exists(self.test_stage):
|
||||||
mkdirp(self.test_stage)
|
mkdirp(self.test_stage)
|
||||||
self.test_log_file = os.path.join(self.test_stage, self.test_log_name)
|
self.test_log_file = os.path.join(self.test_stage, self.test_log_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user