From bca630a22a31107cfdf3cac6dfe4130425069bf4 Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Fri, 24 Apr 2020 09:55:21 -0700 Subject: [PATCH] make output comparisons regex --- lib/spack/spack/package.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 06eccad8b70..ba47fbec104 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1676,7 +1676,8 @@ def run_test(self, exe, options=[], expected=[], status=None, Args: exe (str): the name of the executable options (list of str): list of options to pass to the runner - expected (list of str): list of expected output strings + expected (list of str): list of expected output strings. Each + string is a regex expected to match part of the output. status (int, list of int, or None): possible passing status values with 0 and None meaning the test is expected to succeed installed (bool): the executable must be in the install prefix @@ -1759,9 +1760,9 @@ def _run_test_helper(self, exe, options, expected, status, installed, for check in expected: cmd = ' '.join([exe] + options) - msg = "Expected '%s' in output of `%s`" % (check, cmd) + msg = "Expected '%s' to match output of `%s`" % (check, cmd) msg += '\n\nOutput: %s' % output - assert check in output, msg + assert re.search(check, output), msg def unit_test_check(self): """Hook for unit tests to assert things about package internals.