Skip to content

Commit 807d343

Browse files
committed
feat(LEXER): support multiline subshells
1 parent 6a117bd commit 807d343

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/bashcov/lexer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Lexer
1313
IGNORE_END_WITH = %w[(].freeze
1414

1515
# Lines containing only one of these keywords are irrelevant for coverage
16-
IGNORE_IS = %w[esac if then else elif fi while do done { } ;;].freeze
16+
IGNORE_IS = %w[esac if then else elif fi while do done { } ;; ( )].freeze
1717

1818
# @param [String] filename File to analyze
1919
# @param [Hash] coverage Coverage with executed lines marked

spec/support/test_app.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def expected_coverage
2020
"#{test_app}/scripts/cd.sh" => [nil, nil, 1, 2, nil, 3, 1, 3, nil, 2, nil, nil, 1, nil, 3, nil, 6, nil, 1, nil, 1],
2121
"#{test_app}/scripts/comments.sh" => [nil, nil, 1, nil, 1, nil, nil, nil, 1, nil, 1],
2222
"#{test_app}/scripts/delete.sh" => [nil, nil, 1, 1, 1, 1, nil, 1, 1],
23-
"#{test_app}/scripts/function.sh" => [nil, nil, nil, 2, nil, nil, nil, 1, 1, nil, nil, nil, nil, 1, nil, nil, nil, 0, nil, nil, nil, 1, nil, nil, 1, 1, 1, 1],
23+
"#{test_app}/scripts/function.sh" => [nil, nil, nil, 2, nil, nil, nil, 1, 1, nil, nil, nil, nil, 1, nil, nil, nil, 0, nil, nil, nil, 0, nil, nil, 1, 1, 1, 1],
2424
"#{test_app}/scripts/long_line.sh" => [nil, nil, 1, 1, 1, 0],
2525
"#{test_app}/scripts/nested/simple.sh" => [nil, nil, nil, nil, 1, 1, nil, 0, nil, nil, 1],
2626
"#{test_app}/scripts/new\nline.sh" => [nil, nil, 1, nil, 2],
@@ -31,7 +31,7 @@ def expected_coverage
3131
"#{test_app}/scripts/source.sh" => [nil, nil, 1, nil, 2],
3232
"#{test_app}/scripts/sourced.txt" => [nil, nil, 1],
3333
"#{test_app}/scripts/unicode.sh" => [nil, nil, nil, 1, nil, 1],
34-
"#{test_app}/scripts/multiline.sh" => [nil, nil, nil, 1, nil, 0, nil, 1, nil, 1, nil, 0, nil, nil, 1, 2, 1, 1, 0, nil, nil, 2, nil, nil, 1, 1, 1, 1, nil, 1, 1, 1, 1, 1, nil, 1, 1, 1, 1, nil, 1],
34+
"#{test_app}/scripts/multiline.sh" => [nil, nil, nil, 1, nil, 0, nil, 1, nil, 1, nil, 0, nil, nil, 1, 2, 1, 1, 0, nil, nil, 2, nil, nil, 1, 1, 1, 1, nil, 1, 1, 1, 1, 1, nil, 1, 1, 1, 1, nil, nil, 1],
3535
"#{test_app}/scripts/multiline2.sh" => [nil, nil, 1, 1, 1, 1, nil, 1, 1, 1, 1, nil, 1, 1, 1, 1, 1, 1, nil, 1, 1, 1, 1, 1, 1, 1, 1, nil, 1, 1, 1, nil, 1, nil, nil, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, nil, nil, 1],
3636
"#{test_app}/scripts/multiline3.sh" => [nil, nil, 1, 1, 1, 1],
3737
"#{test_app}/scripts/multiline4.sh" => [nil, nil, 1, 1],

spec/test_app/scripts/multiline.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ hello
3838
there
3939
'
4040
# nil
41-
echo the end # 1
41+
( # nil
42+
echo the end # 1
43+
) # nil

0 commit comments

Comments
 (0)