Skip to content

False negative from assert_have_been_called_with when args include a literal pipe #494

@mattness

Description

@mattness
Q A
OS macOS and Linux
Shell & version bash 5.3.3 (macOS) and bash 5.2.32 (Linux)
bashunit version 0.24.0 (both)

Summary

assert_have_been_called_with will produce a false negative when the spied command's args include a literal pipe

Current behavior

After creating a spy for a command and then calling that command with arguments that contain a literal pipe (|) character, assert_have_been_called_with will not compare the expected value against the correct actual value, and the assertion will fail erroneously.

How to reproduce

This test currently fails:

function test_grep_with_or_pattern_arg() {
  spy grep
  grep -E 'foo|bar'
  assert_have_been_called_with grep '-E foo|bar'
}

Output:

✗ Failed: Grep with or pattern arg
    Expected '-E foo|bar'
    but got  '-E foo'

Expected behavior

assert_have_been_called_with grep '-E foo|bar' should pass

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions