Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions altshfmt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ altshfmt() {
/^[[:space:]]*('"$SHELLSPEC_DSL_ONLINE_DATA"').*/ {
next
}
/^[[:space:]]*(Parameters:value)([[:space:]].*|$)/ {
# Parameters:value is a standalone construct and does not need braces
next
}
/^[[:space:]]*('"$SHELLSPEC_DSL_BEGIN"')([[:space:]].*|$)/ {
while(match($0, /.*\\$/)) { getline; print }
print "{ # @@altsh@@begin"
Expand Down
48 changes: 48 additions & 0 deletions spec/altshfmt_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,52 @@ Describe "altshfmt"
The output should eq "1: arg1 arg2 -l"
End
End

# Regression tests
Describe "Parameters:value handling"
Context "when Parameters:value is used in shellspec"
Data
#|#!/bin/bash
#|
#|Parameters:value aarch64 ppc64le s390x x86_64
#|
#|It 'is simple'
#| When call echo "$1"
#| The output should eq "$1"
#|End
End

It "formats without syntax errors"
When call altshfmt
The status should be success
The output should include "Parameters:value aarch64 ppc64le s390x x86_64"
End

It "produces valid shell syntax"
When call bash -c './altshfmt | bash -n'
The status should be success
End
End

Context "when other Parameters variants are used"
Data
#|#!/bin/bash
#|
#|Parameters:block
#| foo bar
#|End
#|
#|It 'test'
#| echo hello
#|End
End

It "still formats Parameters:block correctly"
When call altshfmt
The status should be success
The output should include "Parameters:block"
The output should include "foo bar"
End
End
End
End