summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>2020-03-05 16:54:29 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2020-03-20 11:38:28 -0700
commit733f9f8cfa5814cd1df6c34cf7e70f460ce75ff4 (patch)
treed81d84eb8cdbd121d7a13fd10469c360ba6fd0c3 /lib
parentfa0a5e44aa7616bdef4cc825436bfb207c03bf56 (diff)
downloadspack-733f9f8cfa5814cd1df6c34cf7e70f460ce75ff4.tar.gz
spack-733f9f8cfa5814cd1df6c34cf7e70f460ce75ff4.tar.bz2
spack-733f9f8cfa5814cd1df6c34cf7e70f460ce75ff4.tar.xz
spack-733f9f8cfa5814cd1df6c34cf7e70f460ce75ff4.zip
Recover coverage from subprocesses during unit tests (#15354)
* Recover coverage from subprocesses during unit tests
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/test.py2
-rw-r--r--lib/spack/spack/test/cmd/test.py11
-rw-r--r--lib/spack/spack/test/llnl/util/log.py9
-rw-r--r--lib/spack/spack/test/pytest.ini10
4 files changed, 13 insertions, 19 deletions
diff --git a/lib/spack/spack/cmd/test.py b/lib/spack/spack/cmd/test.py
index f2ca8fc93b..8cbc0fbccf 100644
--- a/lib/spack/spack/cmd/test.py
+++ b/lib/spack/spack/cmd/test.py
@@ -154,7 +154,7 @@ def test(parser, args, unknown_args):
# The default is to test the core of Spack. If the option `--extension`
# has been used, then test that extension.
- pytest_root = spack.paths.test_path
+ pytest_root = spack.paths.spack_root
if args.extension:
target = args.extension
extensions = spack.config.get('config:extensions')
diff --git a/lib/spack/spack/test/cmd/test.py b/lib/spack/spack/test/cmd/test.py
index 9a64209cfa..a9ef735afe 100644
--- a/lib/spack/spack/test/cmd/test.py
+++ b/lib/spack/spack/test/cmd/test.py
@@ -6,6 +6,7 @@
from spack.main import SpackCommand
spack_test = SpackCommand('test')
+cmd_test_py = 'lib/spack/spack/test/cmd/test.py'
def test_list():
@@ -16,13 +17,13 @@ def test_list():
def test_list_with_pytest_arg():
- output = spack_test('--list', 'cmd/test.py')
- assert output.strip() == "cmd/test.py"
+ output = spack_test('--list', cmd_test_py)
+ assert output.strip() == cmd_test_py
def test_list_with_keywords():
output = spack_test('--list', '-k', 'cmd/test.py')
- assert output.strip() == "cmd/test.py"
+ assert output.strip() == cmd_test_py
def test_list_long(capsys):
@@ -44,7 +45,7 @@ def test_list_long(capsys):
def test_list_long_with_pytest_arg(capsys):
with capsys.disabled():
- output = spack_test('--list-long', 'cmd/test.py')
+ output = spack_test('--list-long', cmd_test_py)
assert "test.py::\n" in output
assert "test_list" in output
assert "test_list_with_pytest_arg" in output
@@ -74,7 +75,7 @@ def test_list_names():
def test_list_names_with_pytest_arg():
- output = spack_test('--list-names', 'cmd/test.py')
+ output = spack_test('--list-names', cmd_test_py)
assert "test.py::test_list\n" in output
assert "test.py::test_list_with_pytest_arg\n" in output
assert "test.py::test_list_with_keywords\n" in output
diff --git a/lib/spack/spack/test/llnl/util/log.py b/lib/spack/spack/test/llnl/util/log.py
index 1eae1ccf69..0c879c5a6e 100644
--- a/lib/spack/spack/test/llnl/util/log.py
+++ b/lib/spack/spack/test/llnl/util/log.py
@@ -32,7 +32,8 @@ def test_log_python_output_with_fd_stream(capfd, tmpdir):
with open('foo.txt') as f:
assert f.read() == 'logged\n'
- assert capfd.readouterr() == ('', '')
+ # Coverage is cluttering stderr during tests
+ assert capfd.readouterr()[0] == ''
def test_log_python_output_and_echo_output(capfd, tmpdir):
@@ -42,7 +43,8 @@ def test_log_python_output_and_echo_output(capfd, tmpdir):
print('echo')
print('logged')
- assert capfd.readouterr() == ('echo\n', '')
+ # Coverage is cluttering stderr during tests
+ assert capfd.readouterr()[0] == 'echo\n'
with open('foo.txt') as f:
assert f.read() == 'echo\nlogged\n'
@@ -75,7 +77,8 @@ def test_log_subproc_and_echo_output(capfd, tmpdir):
echo('echo')
print('logged')
- assert capfd.readouterr() == ('echo\n', '')
+ # Coverage is cluttering stderr during tests
+ assert capfd.readouterr()[0] == 'echo\n'
with open('foo.txt') as f:
assert f.read() == 'logged\n'
diff --git a/lib/spack/spack/test/pytest.ini b/lib/spack/spack/test/pytest.ini
deleted file mode 100644
index 59839c0005..0000000000
--- a/lib/spack/spack/test/pytest.ini
+++ /dev/null
@@ -1,10 +0,0 @@
-# content of pytest.ini
-[pytest]
-addopts = --durations=20 -ra
-testpaths = .
-python_files = *.py
-markers =
- db: tests that require creating a DB
- network: tests that require access to the network
- maybeslow: tests that may be slow (e.g. access a lot the filesystem, etc.)
- regression: tests that fix a reported bug