From cfb60ab9e146e650cc5936a558bec56883a7364d Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Mon, 9 Aug 2021 00:28:53 -0700 Subject: tests: make `spack diff` test more lenient The constraints in the `spack diff` test were very specific and assumed a lot about the structure of what was being diffed. Relax them a bit to make them more resilient to changes. --- lib/spack/spack/test/cmd/diff.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/spack/spack/test/cmd/diff.py b/lib/spack/spack/test/cmd/diff.py index 9049b3f11b..949e046b56 100644 --- a/lib/spack/spack/test/cmd/diff.py +++ b/lib/spack/spack/test/cmd/diff.py @@ -29,10 +29,18 @@ def test_diff_cmd(install_mockery, mock_fetch, mock_archive, mock_packages): # Calculate the comparison (c) c = spack.cmd.diff.compare_specs(specA, specB, to_string=True) - assert len(c['a_not_b']) == 1 - assert len(c['b_not_a']) == 1 - assert c['a_not_b'][0] == ['variant_value', 'mpileaks debug False'] - assert c['b_not_a'][0] == ['variant_value', 'mpileaks debug True'] + + # these particular diffs should have the same length b/c thre aren't + # any node differences -- just value differences. + assert len(c['a_not_b']) == len(c['b_not_a']) + + # ensure that variant diffs are in here the result + assert ['variant_value', 'mpileaks debug False'] in c['a_not_b'] + assert ['variant_value', 'mpileaks debug True'] in c['b_not_a'] + + # ensure that hash diffs are in here the result + assert ['hash', 'mpileaks %s' % specA.dag_hash()] in c['a_not_b'] + assert ['hash', 'mpileaks %s' % specB.dag_hash()] in c['b_not_a'] def test_load_first(install_mockery, mock_fetch, mock_archive, mock_packages): -- cgit v1.2.3-60-g2f50