mirror of
https://github.com/ivuorinen/tree-sitter-shellspec.git
synced 2026-02-06 17:49:03 +00:00
feat: implement complete tree-sitter-shellspec grammar with comprehensive testing
- Add full ShellSpec grammar extending tree-sitter-bash - Support all ShellSpec constructs: Describe, Context, It, hooks, utilities - Include Data block parsing with statements and argument styles - Add 61 comprehensive test cases covering real-world patterns - Implement optimized GitHub workflows with CI/CD automation - Configure complete development tooling (linting, formatting, pre-commit) - Add comprehensive documentation and contribution guidelines - Optimize grammar conflicts to zero warnings - Support editor integration for Neovim, VS Code, Emacs Breaking Changes: - Initial release, no previous API to break BREAKING CHANGE: Initial implementation of tree-sitter-shellspec grammar # Conflicts: # .github/workflows/codeql.yml # .github/workflows/pr-lint.yml # .pre-commit-config.yaml # Conflicts: # .github/workflows/pr-lint.yml # Conflicts: # .github/workflows/pr-lint.yml
This commit is contained in:
93
test/spec/16.text_directive_spec.sh
Normal file
93
test/spec/16.text_directive_spec.sh
Normal file
@@ -0,0 +1,93 @@
|
||||
#shellcheck shell=sh disable=SC2016
|
||||
|
||||
# %text directive is easy way to output text like here document.
|
||||
# Removes `#|` from the beginning of the each line in the %text directive,
|
||||
# the rest is the output text.
|
||||
|
||||
Describe '%text directive'
|
||||
It 'outputs texts'
|
||||
output() {
|
||||
echo "start" # you can write code here
|
||||
%text
|
||||
#|aaa
|
||||
#|bbb
|
||||
#|ccc
|
||||
echo "end" # you can write code here
|
||||
}
|
||||
When call output
|
||||
The line 1 of output should eq 'start'
|
||||
The line 2 of output should eq 'aaa'
|
||||
The line 3 of output should eq 'bbb'
|
||||
The line 4 of output should eq "ccc"
|
||||
The line 5 of output should eq 'end'
|
||||
End
|
||||
|
||||
It 'sets to variable'
|
||||
output() {
|
||||
texts=$(
|
||||
%text
|
||||
#|aaa
|
||||
#|bbb
|
||||
#|ccc
|
||||
)
|
||||
echo "$texts"
|
||||
}
|
||||
When call output
|
||||
The line 1 of output should eq 'aaa'
|
||||
The line 2 of output should eq 'bbb'
|
||||
The line 3 of output should eq "ccc"
|
||||
End
|
||||
|
||||
It 'outputs texts with filter'
|
||||
output() {
|
||||
%text | tr 'a-z_' 'A-Z_'
|
||||
#|abc
|
||||
}
|
||||
When call output
|
||||
The output should eq 'ABC'
|
||||
End
|
||||
|
||||
Describe 'variable expantion'
|
||||
Before 'text=abc'
|
||||
|
||||
Example 'not expand variable (default)'
|
||||
output() {
|
||||
%text:raw
|
||||
#|$text
|
||||
}
|
||||
When call output
|
||||
The output should eq '$text'
|
||||
End
|
||||
|
||||
Example 'expand variable'
|
||||
output() {
|
||||
%text:expand
|
||||
#|$text
|
||||
}
|
||||
When call output
|
||||
The output should eq 'abc'
|
||||
End
|
||||
End
|
||||
|
||||
It 'outputs texts with more complex code'
|
||||
output() {
|
||||
if true; then
|
||||
set -- 1 2 3 4 5
|
||||
while [ $# -gt 0 ]; do
|
||||
%text:expand | tr 'a-z_' 'A-Z_'
|
||||
#|value $(($1 * 10))
|
||||
shift
|
||||
done
|
||||
else
|
||||
%text
|
||||
#|text
|
||||
fi
|
||||
}
|
||||
When call output
|
||||
The line 1 of output should eq 'VALUE 10'
|
||||
The line 2 of output should eq 'VALUE 20'
|
||||
The line 3 of output should eq 'VALUE 30'
|
||||
The line 4 of output should eq "VALUE 40"
|
||||
The line 5 of output should eq 'VALUE 50'
|
||||
End
|
||||
End
|
||||
Reference in New Issue
Block a user