Skip to content

Commit

Permalink
fix: Propely iteratre over lines
Browse files Browse the repository at this point in the history
  • Loading branch information
marverix committed Feb 3, 2025
1 parent 76acb65 commit 164bdf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/log_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ function _log_x() {
fi
fi

for line in $(echo -e "$lines"); do
lines=$(echo -e "$lines")
while IFS= read -r line; do
echo_err "${prefix}${line}"
done
done <<< "$lines"
}

function log_error() {
Expand Down
14 changes: 7 additions & 7 deletions test/log_helpers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ Baz"
@test "log_error should print GHA error command with multiple errors when multiline message provided (using \n)" {
GITHUB_ACTIONS="true"

run log_error "Foo" "Bar\nBaz"
run log_error "Foo Bar" "Hello 1\nHello 2"

assert_success
assert_output "::error title=Foo::Bar
::error title=Foo::Baz"
assert_output "::error title=Foo Bar::Hello 1
::error title=Foo Bar::Hello 2"
}

@test "log_error should print GHA error command with multiple errors when multiline message provided (using multiple arguments)" {
GITHUB_ACTIONS="true"

run log_error "Foo" "Bar
Baz"
run log_error "Foo Bar" "Hello 1
Hello 2"

assert_success
assert_output "::error title=Foo::Bar
::error title=Foo::Baz"
assert_output "::error title=Foo Bar::Hello 1
::error title=Foo Bar::Hello 2"
}

@test "log_warning should print warning with title" {
Expand Down

0 comments on commit 164bdf7

Please sign in to comment.