diff options
Diffstat (limited to 'lib/spack/spack/test/cmd/install.py')
-rw-r--r-- | lib/spack/spack/test/cmd/install.py | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index b0b10d1287..4fa022d168 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -393,9 +393,14 @@ def test_junit_output_with_failures(tmpdir, exc_typename, msg): '--log-format=junit', '--log-file=test.xml', 'raiser', 'exc_type={0}'.format(exc_typename), - 'msg="{0}"'.format(msg) + 'msg="{0}"'.format(msg), + fail_on_error=False, ) + assert isinstance(install.error, spack.build_environment.ChildError) + assert install.error.name == exc_typename + assert install.error.pkg.name == 'raiser' + files = tmpdir.listdir() filename = tmpdir.join('test.xml') assert filename in files @@ -407,18 +412,22 @@ def test_junit_output_with_failures(tmpdir, exc_typename, msg): assert 'failures="1"' in content assert 'errors="0"' in content + # Nothing should have succeeded + assert 'tests="0"' not in content + assert 'failures="0"' not in content + # We want to have both stdout and stderr assert '<system-out>' in content assert msg in content @pytest.mark.disable_clean_stage_check -@pytest.mark.parametrize('exc_typename,msg', [ - ('RuntimeError', 'something weird happened'), - ('KeyboardInterrupt', 'Ctrl-C strikes again') +@pytest.mark.parametrize('exc_typename,expected_exc,msg', [ + ('RuntimeError', spack.installer.InstallError, 'something weird happened'), + ('KeyboardInterrupt', KeyboardInterrupt, 'Ctrl-C strikes again') ]) def test_junit_output_with_errors( - exc_typename, msg, + exc_typename, expected_exc, msg, mock_packages, mock_archive, mock_fetch, install_mockery, config, tmpdir, monkeypatch): @@ -429,11 +438,11 @@ def test_junit_output_with_errors( monkeypatch.setattr(spack.installer.PackageInstaller, '_install_task', just_throw) - # TODO: Why does junit output capture appear to swallow the exception - # TODO: as evidenced by the two failing packages getting tagged as - # TODO: installed? with tmpdir.as_cwd(): - install('--log-format=junit', '--log-file=test.xml', 'libdwarf') + install('--log-format=junit', '--log-file=test.xml', 'libdwarf', + fail_on_error=False) + + assert isinstance(install.error, expected_exc) files = tmpdir.listdir() filename = tmpdir.join('test.xml') @@ -441,10 +450,14 @@ def test_junit_output_with_errors( content = filename.open().read() - # Count failures and errors correctly: libdwarf _and_ libelf - assert 'tests="2"' in content + # Only libelf error is reported (through libdwarf root spec). libdwarf + # install is skipped and it is not an error. + assert 'tests="1"' in content assert 'failures="0"' in content - assert 'errors="2"' in content + assert 'errors="1"' in content + + # Nothing should have succeeded + assert 'errors="0"' not in content # We want to have both stdout and stderr assert '<system-out>' in content @@ -877,7 +890,7 @@ def test_install_help_cdash(capsys): @pytest.mark.disable_clean_stage_check -def test_cdash_auth_token(tmpdir, install_mockery, capfd): +def test_cdash_auth_token(tmpdir, mock_fetch, install_mockery, capfd): # capfd interferes with Spack's capturing with tmpdir.as_cwd(): with capfd.disabled(): |