diff --git a/dim-testsuite/runtest.py b/dim-testsuite/runtest.py index a49f893..8069528 100755 --- a/dim-testsuite/runtest.py +++ b/dim-testsuite/runtest.py @@ -161,11 +161,12 @@ def process_command(actual_output, expected_output, out, sort_before=False): if sort_before: actual_output.sort() expected_output.sort() - for actual, expected in zip_longest(actual_output, expected_output, fillvalue=''): - expected = expected.strip('\n') - if expected.endswith(' re'): + # output and expectation are bytes, like the rest of the file handling here + for actual, expected in zip_longest(actual_output, expected_output, fillvalue=b''): + expected = expected.strip(b'\n') + if expected.endswith(b' re'): if re.match(expected[:-3], actual): - out.write(expected + '\n') + out.write(expected + b'\n') else: out.write(actual + b'\n') passed = False diff --git a/dim-testsuite/t/runtest-shell-output.t b/dim-testsuite/t/runtest-shell-output.t new file mode 100644 index 0000000..33ed599 --- /dev/null +++ b/dim-testsuite/t/runtest-shell-output.t @@ -0,0 +1,10 @@ +# The test runner compares the output of shell lines (everything that does not +# start with "ndcli") with the expected lines, exactly or as a regex when the +# expectation ends with " re". +$ echo hello +hello +$ printf 'one\ntwo\n' +one +two +$ date +%Y +^20[0-9][0-9]$ re