mirror of
https://github.com/ivuorinen/tree-sitter-shellspec.git
synced 2026-01-26 11:43:59 +00:00
- 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
237 lines
5.3 KiB
Plaintext
237 lines
5.3 KiB
Plaintext
================================================================================
|
|
Describe with Context
|
|
================================================================================
|
|
|
|
Describe "main feature"
|
|
Context "when condition A"
|
|
echo "setup A"
|
|
End
|
|
End
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(program
|
|
(shellspec_describe_block
|
|
description: (string
|
|
(string_content))
|
|
(shellspec_context_block
|
|
description: (string
|
|
(string_content))
|
|
(command
|
|
name: (command_name
|
|
(word))
|
|
argument: (string
|
|
(string_content))))))
|
|
|
|
================================================================================
|
|
Describe with It
|
|
================================================================================
|
|
|
|
Describe "main feature"
|
|
It "should work"
|
|
echo "test"
|
|
End
|
|
End
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(program
|
|
(shellspec_describe_block
|
|
description: (string
|
|
(string_content))
|
|
(shellspec_it_block
|
|
description: (string
|
|
(string_content))
|
|
(command
|
|
name: (command_name
|
|
(word))
|
|
argument: (string
|
|
(string_content))))))
|
|
|
|
================================================================================
|
|
Context with It
|
|
================================================================================
|
|
|
|
Context "when ready"
|
|
It "should execute"
|
|
echo "executing"
|
|
End
|
|
End
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(program
|
|
(shellspec_context_block
|
|
description: (string
|
|
(string_content))
|
|
(shellspec_it_block
|
|
description: (string
|
|
(string_content))
|
|
(command
|
|
name: (command_name
|
|
(word))
|
|
argument: (string
|
|
(string_content))))))
|
|
|
|
================================================================================
|
|
Describe with hooks and tests
|
|
================================================================================
|
|
|
|
Describe "complete feature"
|
|
BeforeEach
|
|
setup_test
|
|
End
|
|
|
|
It "should work correctly"
|
|
run_test
|
|
End
|
|
|
|
AfterEach
|
|
cleanup_test
|
|
End
|
|
End
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(program
|
|
(shellspec_describe_block
|
|
description: (string
|
|
(string_content))
|
|
(shellspec_hook_block
|
|
(command
|
|
name: (command_name
|
|
(word))))
|
|
(shellspec_it_block
|
|
description: (string
|
|
(string_content))
|
|
(command
|
|
name: (command_name
|
|
(word))))
|
|
(shellspec_hook_block
|
|
(command
|
|
name: (command_name
|
|
(word))))))
|
|
|
|
================================================================================
|
|
Complex nested structure
|
|
================================================================================
|
|
|
|
Describe "main functionality"
|
|
BeforeAll
|
|
global_setup
|
|
End
|
|
|
|
Context "when user is authenticated"
|
|
BeforeEach
|
|
login_user
|
|
End
|
|
|
|
It "should access protected resource"
|
|
access_resource
|
|
End
|
|
|
|
Context "and has admin privileges"
|
|
It "should access admin panel"
|
|
access_admin
|
|
End
|
|
End
|
|
|
|
AfterEach
|
|
logout_user
|
|
End
|
|
End
|
|
|
|
AfterAll
|
|
global_cleanup
|
|
End
|
|
End
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(program
|
|
(shellspec_describe_block
|
|
description: (string
|
|
(string_content))
|
|
(shellspec_hook_block
|
|
(command
|
|
name: (command_name
|
|
(word))))
|
|
(shellspec_context_block
|
|
description: (string
|
|
(string_content))
|
|
(shellspec_hook_block
|
|
(command
|
|
name: (command_name
|
|
(word))))
|
|
(shellspec_it_block
|
|
description: (string
|
|
(string_content))
|
|
(command
|
|
name: (command_name
|
|
(word))))
|
|
(shellspec_context_block
|
|
description: (string
|
|
(string_content))
|
|
(shellspec_it_block
|
|
description: (string
|
|
(string_content))
|
|
(command
|
|
name: (command_name
|
|
(word)))))
|
|
(shellspec_hook_block
|
|
(command
|
|
name: (command_name
|
|
(word)))))
|
|
(shellspec_hook_block
|
|
(command
|
|
name: (command_name
|
|
(word))))))
|
|
|
|
================================================================================
|
|
Mixed with regular bash
|
|
================================================================================
|
|
|
|
#!/bin/bash
|
|
|
|
function helper() {
|
|
echo "helper function"
|
|
}
|
|
|
|
Describe "using bash functions"
|
|
It "should call helper"
|
|
result=$(helper)
|
|
echo "$result"
|
|
End
|
|
End
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
(program
|
|
(comment)
|
|
(function_definition
|
|
name: (word)
|
|
body: (compound_statement
|
|
(command
|
|
name: (command_name
|
|
(word))
|
|
argument: (string
|
|
(string_content)))))
|
|
(shellspec_describe_block
|
|
description: (string
|
|
(string_content))
|
|
(shellspec_it_block
|
|
description: (string
|
|
(string_content))
|
|
(variable_assignment
|
|
name: (variable_name)
|
|
value: (command_substitution
|
|
(command
|
|
name: (command_name
|
|
(word)))))
|
|
(command
|
|
name: (command_name
|
|
(word))
|
|
argument: (string
|
|
(simple_expansion
|
|
(variable_name)))))))
|