Skip to content

Commit cab34d7

Browse files
authored
Fix bug in placeholder spack cd command and add unit tests (spack#6776)
1 parent db42d08 commit cab34d7

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

lib/spack/spack/cmd/cd.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
# License along with this program; if not, write to the Free Software
2323
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2424
##############################################################################
25+
from spack.cmd.common import print_module_placeholder_help
26+
2527
import spack.cmd.location
26-
import spack.modules
2728

2829
description = "cd to spack directories in the shell"
2930
section = "environment"
@@ -38,4 +39,4 @@ def setup_parser(subparser):
3839

3940

4041
def cd(parser, args):
41-
spack.modules.print_help()
42+
print_module_placeholder_help()

lib/spack/spack/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def __call__(self, *argv, **kwargs):
388388
Returns:
389389
(str): combined output and error as a string
390390
391-
On return, if ``fail_on_error`` is False, return value of comman
391+
On return, if ``fail_on_error`` is False, return value of command
392392
is set in ``returncode`` property, and the error is set in the
393393
``error`` property. Otherwise, raise an error.
394394
"""

lib/spack/spack/test/cmd/cd.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
##############################################################################
2+
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
3+
# Produced at the Lawrence Livermore National Laboratory.
4+
#
5+
# This file is part of Spack.
6+
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
7+
# LLNL-CODE-647188
8+
#
9+
# For details, see https://github.com/spack/spack
10+
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
11+
#
12+
# This program is free software; you can redistribute it and/or modify
13+
# it under the terms of the GNU Lesser General Public License (as
14+
# published by the Free Software Foundation) version 2.1, February 1999.
15+
#
16+
# This program is distributed in the hope that it will be useful, but
17+
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
18+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
19+
# conditions of the GNU Lesser General Public License for more details.
20+
#
21+
# You should have received a copy of the GNU Lesser General Public
22+
# License along with this program; if not, write to the Free Software
23+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24+
##############################################################################
25+
from spack.main import SpackCommand
26+
27+
28+
cd = SpackCommand('cd')
29+
30+
31+
def test_cd():
32+
"""Sanity check the cd command to make sure it works."""
33+
34+
out = cd()
35+
36+
assert "To initialize spack's shell commands, you must run one of" in out

0 commit comments

Comments
 (0)