A core/test/vimsplit.bats => core/test/vimsplit.bats +102 -0
@@ 0,0 1,102 @@
+#!/usr/bin/env bats
+bats_require_minimum_version 1.5.0
+
+@test "vimsplit version" {
+ run --separate-stderr vimsplit --version
+ [ "$status" -eq 0 ]
+ [ "$output" = "vimsplit 1.0" ]
+ [ "$stderr" = "" ]
+}
+
+@test "vimsplit version short" {
+ run --separate-stderr vimsplit -v
+ [ "$status" -eq 0 ]
+ [ "$output" = "vimsplit 1.0" ]
+ [ "$stderr" = "" ]
+}
+
+@test "vimsplit help" {
+ run --separate-stderr vimsplit --help
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open two files in split windows" ]
+ [ "${lines[1]}" = "Usage: vimsplit FILE1 FILE2" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message and exit" ]
+ [ "${lines[4]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "vimsplit help short" {
+ run --separate-stderr vimsplit -h
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open two files in split windows" ]
+ [ "${lines[1]}" = "Usage: vimsplit FILE1 FILE2" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message and exit" ]
+ [ "${lines[4]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "vimsplit 1 file" {
+ run --separate-stderr vimsplit foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "vimsplit: Expected 2 arguments (given 1)" ]
+}
+
+@test "vimsplit 1 file - quiet" {
+ run --separate-stderr vimsplit foobarbaz --quiet
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "vimsplit 1 file - quiet short" {
+ run --separate-stderr vimsplit foobarbaz -q
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "vimsplit no such file" {
+ run --separate-stderr vimsplit foo bar
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "vimsplit: No such file 'foo'" ]
+}
+
+@test "vimsplit no such file - quiet" {
+ run --separate-stderr vimsplit foo bar --quiet
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "vimsplit no such file - quiet short" {
+ run --separate-stderr vimsplit foo bar -q
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "vimsplit 3 file" {
+ run --separate-stderr vimsplit foo bar baz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "vimsplit: Expected 2 arguments (given 3)" ]
+}
+
+@test "vimsplit 3 file - quiet" {
+ run --separate-stderr vimsplit foo bar baz --quiet
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "vimsplit 3 file - quiet short" {
+ run --separate-stderr vimsplit foo bar baz -q
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
M core/vimsplit => core/vimsplit +2 -2
@@ 43,12 43,12 @@ done
# check files
if [ ! -f "$file1" ]; then
- if [ "$quiet" -eq 1 ]; then
+ if [ "$quiet" -eq 0 ]; then
(>&2 /usr/bin/printf "%s: No such file '%s'\n" "$name" "$file1")
fi
exit 1
elif [ ! -f "$file2" ]; then
- if [ "$quiet" -eq 1 ]; then
+ if [ "$quiet" -eq 0 ]; then
(>&2 /usr/bin/printf "%s: No such file '%s'\n" "$name" "$file2")
fi
exit 1