mirror of
https://github.com/ivuorinen/tree-sitter-shellspec.git
synced 2026-02-08 01:49:35 +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:
117
test/spec/09.subject_spec.sh
Normal file
117
test/spec/09.subject_spec.sh
Normal file
@@ -0,0 +1,117 @@
|
||||
#shellcheck shell=sh
|
||||
|
||||
Describe 'subject example'
|
||||
Describe 'stdout'
|
||||
foo() { echo "ok"; }
|
||||
|
||||
It 'uses the stdout as the subject'
|
||||
When call foo
|
||||
The stdout should eq "ok"
|
||||
End
|
||||
|
||||
It 'has an alias "output"'
|
||||
When call foo
|
||||
The output should eq "ok"
|
||||
End
|
||||
|
||||
Describe 'with entire'
|
||||
It 'does not remove last LF'
|
||||
When call foo
|
||||
The entire output should eq "ok${SHELLSPEC_LF}"
|
||||
End
|
||||
|
||||
# Without "entire", the "output" subject act as like
|
||||
# the command substitution.
|
||||
#
|
||||
# For example "echo" outputs a newline at the end.
|
||||
# In spite of that `[ "$(echo ok)" = "ok" ]` will success.
|
||||
# Because the command substitution removes trailing newlines.
|
||||
#
|
||||
# The "entire output" subject does not remove trailing newlines.
|
||||
End
|
||||
End
|
||||
|
||||
Describe 'stderr'
|
||||
foo() { echo "err" >&2; }
|
||||
|
||||
It 'uses the stderr as the subject'
|
||||
When call foo
|
||||
The stderr should eq "err"
|
||||
End
|
||||
|
||||
It 'has an alias "error"'
|
||||
When call foo
|
||||
The error should eq "err"
|
||||
End
|
||||
|
||||
Describe 'with entire'
|
||||
It 'does not remove last LF'
|
||||
When call foo
|
||||
The entire error should eq "err${SHELLSPEC_LF}"
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
Describe 'status'
|
||||
foo() { return 123; }
|
||||
|
||||
It 'uses the status as the subject'
|
||||
When call foo
|
||||
The status should eq 123
|
||||
End
|
||||
End
|
||||
|
||||
Describe 'variable'
|
||||
foo() { var=456; }
|
||||
|
||||
It 'uses the variable as the subject'
|
||||
When call foo
|
||||
The variable var should eq 456
|
||||
End
|
||||
End
|
||||
|
||||
Describe 'value'
|
||||
foo() { var=789; }
|
||||
|
||||
It 'uses the value as the subject'
|
||||
When call foo
|
||||
The value "$var" should eq 789
|
||||
End
|
||||
End
|
||||
|
||||
Describe 'function'
|
||||
foo() { echo "ok"; }
|
||||
|
||||
It 'is alias for value'
|
||||
The function "foo" should eq "foo"
|
||||
The "foo()" should eq "foo" # shorthand for function
|
||||
End
|
||||
|
||||
It 'uses with result modifier'
|
||||
The result of "foo()" should eq "ok"
|
||||
End
|
||||
End
|
||||
|
||||
Describe 'path'
|
||||
# Path helper defines path alias.
|
||||
Path hosts-file='/etc/hosts'
|
||||
|
||||
It 'uses the resolved path as the subject'
|
||||
The path hosts-file should eq '/etc/hosts'
|
||||
End
|
||||
|
||||
It 'has an alias "file"'
|
||||
Path hosts='/etc/hosts'
|
||||
The file hosts should eq '/etc/hosts'
|
||||
End
|
||||
|
||||
It 'has an alias "dir"'
|
||||
Path target='/foo/bar/baz/target'
|
||||
The dir target should eq '/foo/bar/baz/target'
|
||||
End
|
||||
|
||||
It 'is same as value if path alias not found. but improve readability'
|
||||
The path '/etc/hosts' should eq '/etc/hosts'
|
||||
End
|
||||
End
|
||||
End
|
||||
Reference in New Issue
Block a user