Skip to content

Spying on printf breaks coverage collection #724

@RevanProdigalKnight

Description

@RevanProdigalKnight
Q A
OS Linux (Cygwin on Windows 10)
Shell & version bash 5.2.21(1)-release
bashunit version 0.39.1

Summary

Spying on printf causes coverage information for a given test to be improperly collected (i.e. not collected)

This likely relates to #607

Current behavior

When spying on printf in a test, coverage information for any functions called during the test's execution is not collected properly.

How to reproduce

# source file
function hello_world() {
  printf '%s\n' "hello world"
}

# test file
function test_hello_world() {
  bashunit::spy printf

  hello_world

  assert_have_been_called_with printf '%s\n' "hello world"
}

Run bashunit tests/test_hello_world.sh --coverage

Open the coverage report and see that the line printf '%s\n' "hello world" in function hello_world is not marked as being covered.

Expected behavior

Coverage information for all lines is collect properly regardless of what shell builtins have been spied upon

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions