Skip to content

Commit

Permalink
Inspec diagnosis (#2045)
Browse files Browse the repository at this point in the history
* Never truncate exceptions raised by sh in testing

The sh module, by default, truncates the output in string
representations of exceptions. This change tells sh to stop truncating
those strings in testing, and also fixes a few instances of direct calls
to the 'sh' module that were not using the pytest.helpers.run_command
wrapper.

Signed-off-by: Sean Myers <[email protected]>

* Comply with rubocop FrozenStringLiteralComment cop

This was fixed with `rubocop --auto-correct`, similar to running `yapf
--in-place`. I have insufficient ruby experience (and no interest) to
agree or disagree with rubocop's opinion.

Signed-off-by: Sean Myers <[email protected]>
  • Loading branch information
Sean Myers authored and jctanner committed Jul 15, 2019
1 parent cef4d6d commit 37bd3bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Molecule managed

describe file('/etc/hosts') do
Expand Down
3 changes: 3 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def run_command(cmd, env=os.environ, log=True):
if log:
cmd = _rebake_command(cmd, env)

# Never let sh truncate exceptions in testing
cmd = cmd.bake(_truncate_exc=False)

return util.run_command(cmd)


Expand Down
9 changes: 6 additions & 3 deletions test/functional/docker/test_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def test_command_init_role_inspec(temp_dir):
pytest.helpers.metadata_lint_update(role_directory)

with change_dir_to(role_directory):
sh.molecule('test')
cmd = sh.molecule.bake('test')
pytest.helpers.run_command(cmd)


def test_command_init_scenario_inspec(temp_dir):
Expand Down Expand Up @@ -138,7 +139,8 @@ def test_command_init_role_goss(temp_dir):
pytest.helpers.metadata_lint_update(role_directory)

with change_dir_to(role_directory):
sh.molecule('test')
cmd = sh.molecule.bake('test')
pytest.helpers.run_command(cmd)


def test_command_init_scenario_goss(temp_dir):
Expand Down Expand Up @@ -254,7 +256,8 @@ def test_command_init_role_with_template(temp_dir):
pytest.helpers.metadata_lint_update(role_directory)

with change_dir_to(role_directory):
sh.molecule('test')
cmd = sh.molecule.bake('test')
pytest.helpers.run_command(cmd)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 37bd3bd

Please sign in to comment.