Skip to content

Commit 3d5be3e

Browse files
authored
Merge pull request #1317 from jantrienes/bats
Add support for Bash Automated Test System (Bats)
2 parents 66abb25 + 6fcbadc commit 3d5be3e

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Currently supported grammars are:
1818
| AppleScript | Yes | Yes | |
1919
| Babel ES6 JS | Yes | Yes | |
2020
| Bash | Yes | Yes | The shell used is based on your default `$SHELL` environment variable |
21+
| Bash Automated Test System (Bats) | Yes | Yes | |
2122
| Batch | Yes | | |
2223
| Behat Feature | Yes | | |
2324
| BuckleScript | Yes | Yes | |

examples/math.bats

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bats
2+
3+
@test "addition using bc" {
4+
result="$(echo 2+2 | bc)"
5+
[ "$result" -eq 4 ]
6+
}
7+
8+
@test "addition using dc" {
9+
result="$(echo 2 2+p | dc)"
10+
[ "$result" -eq 4 ]
11+
}

lib/grammars.coffee

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ module.exports =
4444
command: "babel-node"
4545
args: (context) -> [context.filepath]
4646

47+
'Bash Automated Test System (Bats)':
48+
"File Based":
49+
command: "bats"
50+
args: (context) -> [context.filepath]
51+
"Selection Based":
52+
command: 'bats'
53+
args: (context) ->
54+
code = context.getCode(true)
55+
tmpFile = GrammarUtils.createTempFileWithCode(code)
56+
[tmpFile]
57+
4758
Batch:
4859
"File Based":
4960
command: "cmd.exe"
@@ -168,7 +179,7 @@ module.exports =
168179
'File Based':
169180
command: 'coffee'
170181
args: (context) -> [context.filepath]
171-
182+
172183
"Common Lisp":
173184
"File Based":
174185
command: "clisp"

0 commit comments

Comments
 (0)