M .gitignore => .gitignore +1 -1
@@ 1,1 1,1 @@
-**/test/
+**/test/static
M core/Makefile => core/Makefile +2 -7
@@ 57,14 57,9 @@ uninstall:
rm $(COMP_DIR)/myutils_core.bash
test: clean
- #shellcheck *.bash *.sh $(LIB_DIR)/mylib.bash $(LIB_DIR)/myparse.bash $(LIB_DIR)/myminiparse.sh
- sh test_init.sh
- sh test_debom_rebom.sh
- sh test_ctdir.sh
- sh test_whichcat_whichhead.sh
- sh test_whiched_whichvi.sh
+ bats test/
clean:
- rm -rf test/
+ rm -rf test/static/
M core/README.md => core/README.md +2 -2
@@ 2,6 2,8 @@
Tools for everyday living.
+`bats` is required for the test suite.
+
## Specification
@@ 28,5 30,3 @@ wttr |Wrapper around `wttr` to fix double-wide runes for some fonts |
*All* scripts support `-h` and `--help` for printing built-in documentation.
-## To-Do
-
A core/test/ctdir.bats => core/test/ctdir.bats +213 -0
@@ 0,0 1,213 @@
+#!/usr/bin/env bats
+bats_require_minimum_version 1.5.0
+
+setup() {
+ mkdir -p test/static/
+ touch test/static/{a,b,c,d,e,.f,.g,.h,.i,.j}.txt
+}
+
+teardown() {
+ rm -rf test/static/
+}
+
+@test "ctdir usage" {
+ run --separate-stderr ctdir
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "Usage: ctdir TARGET [OPTIONS]" ]
+}
+
+@test "ctdir version" {
+ run --separate-stderr ctdir --version
+ [ "$status" -eq 0 ]
+ [ "$output" = "ctdir 1.0" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir version - quiet" {
+ run --separate-stderr ctdir --version --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "ctdir 1.0" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir version - quiet short" {
+ run --separate-stderr ctdir --version -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "ctdir 1.0" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir version short" {
+ run --separate-stderr ctdir -v
+ [ "$status" -eq 0 ]
+ [ "$output" = "ctdir 1.0" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir version short - quiet" {
+ run --separate-stderr ctdir -v --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "ctdir 1.0" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir version short - quiet short" {
+ run --separate-stderr ctdir -v -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "ctdir 1.0" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir help" {
+ run --separate-stderr ctdir --help
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Count entries in target directory(ies)" ]
+ [ "${lines[1]}" = "Usage: ctdir TARGETS [..] [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message and exit" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir help - quiet" {
+ run --separate-stderr ctdir --help --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Count entries in target directory(ies)" ]
+ [ "${lines[1]}" = "Usage: ctdir TARGETS [..] [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message and exit" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir help - quiet short" {
+ run --separate-stderr ctdir --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Count entries in target directory(ies)" ]
+ [ "${lines[1]}" = "Usage: ctdir TARGETS [..] [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message and exit" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir help short" {
+ run --separate-stderr ctdir -h
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Count entries in target directory(ies)" ]
+ [ "${lines[1]}" = "Usage: ctdir TARGETS [..] [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message and exit" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir help short - quiet" {
+ run --separate-stderr ctdir -h --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Count entries in target directory(ies)" ]
+ [ "${lines[1]}" = "Usage: ctdir TARGETS [..] [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message and exit" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir help short - quiet short" {
+ run --separate-stderr ctdir -h -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Count entries in target directory(ies)" ]
+ [ "${lines[1]}" = "Usage: ctdir TARGETS [..] [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message and exit" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir quiet" {
+ run --separate-stderr ctdir --quiet
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir quiet short" {
+ run --separate-stderr ctdir -q
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir no such directory" {
+ run --separate-stderr ctdir foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "ctdir: No such directory 'foobarbaz'" ]
+}
+
+@test "ctdir no such directory - quiet" {
+ run --separate-stderr ctdir foobarbaz --quiet
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir no such directory - quiet short" {
+ run --separate-stderr ctdir foobarbaz -q
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir single" {
+ run --separate-stderr ctdir test/static/
+ [ "$status" -eq 0 ]
+ [ "$output" = "10" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir single - quiet" {
+ run --separate-stderr ctdir test/static/
+ [ "$status" -eq 0 ]
+ [ "$output" = "10" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir single - quiet short" {
+ run --separate-stderr ctdir test/static/ --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "10" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir multiple" {
+ run --separate-stderr ctdir test/static/ test/static/
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "10" ]
+ [ "${lines[1]}" = "10" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir multiple - quiet" {
+ run --separate-stderr ctdir test/static/ test/static/ --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "10" ]
+ [ "${lines[1]}" = "10" ]
+ [ "$stderr" = "" ]
+}
+
+@test "ctdir multiple - quiet short" {
+ run --separate-stderr ctdir test/static/ test/static/ -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "10" ]
+ [ "${lines[1]}" = "10" ]
+ [ "$stderr" = "" ]
+}
+
A core/test/debom.bats => core/test/debom.bats +185 -0
@@ 0,0 1,185 @@
+#!/usr/bin/env bats
+bats_require_minimum_version 1.5.0
+
+setup() {
+ mkdir -p test/static/
+ printf "\xEF\xBB\xBFfoo bar\n" > test/static/with_bom.txt
+ printf "foo bar\n" > test/static/without_bom.txt
+}
+
+teardown() {
+ rm -rf test/static/
+}
+
+@test "debom usage" {
+ run --separate-stderr debom
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "Usage: debom TARGET [OPTIONS]" ]
+}
+
+@test "debom version" {
+ run --separate-stderr debom --version
+ [ "$status" -eq 0 ]
+ [ "$output" = "debom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom version - quiet" {
+ run --separate-stderr debom --version --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "debom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom version - quiet short" {
+ run --separate-stderr debom --version -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "debom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom version short" {
+ run --separate-stderr debom -V
+ [ "$status" -eq 0 ]
+ [ "$output" = "debom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom version short - quiet" {
+ run --separate-stderr debom -V --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "debom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom version short - quiet short" {
+ run --separate-stderr debom -V -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "debom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom help" {
+ run --separate-stderr debom --help
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Remove BOM from a target file" ]
+ [ "${lines[1]}" = "Usage: debom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom help - quiet" {
+ run --separate-stderr debom --help --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Remove BOM from a target file" ]
+ [ "${lines[1]}" = "Usage: debom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom help - quiet short" {
+ run --separate-stderr debom --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Remove BOM from a target file" ]
+ [ "${lines[1]}" = "Usage: debom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom help short" {
+ run --separate-stderr debom -h
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Remove BOM from a target file" ]
+ [ "${lines[1]}" = "Usage: debom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom help short - quiet" {
+ run --separate-stderr debom -h --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Remove BOM from a target file" ]
+ [ "${lines[1]}" = "Usage: debom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom help short - quiet short" {
+ run --separate-stderr debom -h -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Remove BOM from a target file" ]
+ [ "${lines[1]}" = "Usage: debom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom single" {
+ run --separate-stderr debom test/static/with_bom.txt
+ [ "$status" -eq 0 ]
+ [ "$output" = "foo bar" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom no such file" {
+ run --separate-stderr debom foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "debom: No such file 'foobarbaz'" ]
+}
+
+@test "debom no such file - verbose" {
+ run --separate-stderr debom --verbose foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "DEBUG:debom:Argument 'foobarbaz' added to positional array" ]
+ [ "$stderr" = "ERROR:debom:No such file 'foobarbaz'" ]
+}
+
+@test "debom multiple" {
+ run --separate-stderr debom test/static/with_bom.txt test/static/with_bom.txt
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "foo bar" ]
+ [ "${lines[1]}" = "foo bar" ]
+ [ "$stderr" = "" ]
+}
+
+@test "debom multiple error" {
+ run --separate-stderr debom test/static/with_bom.txt foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "foo bar" ]
+ [ "$stderr" = "debom: No such file 'foobarbaz'" ]
+}
+
+@test "debom multiple error - verbose" {
+ run --separate-stderr debom --verbose test/static/with_bom.txt foobarbaz
+ [ "$status" -eq 1 ]
+ [ "${lines[0]}" = "DEBUG:debom:Argument 'test/static/with_bom.txt' added to positional array" ]
+ [ "${lines[1]}" = "DEBUG:debom:Argument 'foobarbaz' added to positional array" ]
+ [ "${lines[2]}" = "foo bar" ]
+ [ "$stderr" = "ERROR:debom:No such file 'foobarbaz'" ]
+}
+
A core/test/rebom.bats => core/test/rebom.bats +185 -0
@@ 0,0 1,185 @@
+#!/usr/bin/env bats
+bats_require_minimum_version 1.5.0
+
+setup() {
+ mkdir -p test/static/
+ printf "\xEF\xBB\xBFfoo bar\n" > test/static/with_bom.txt
+ printf "foo bar\n" > test/static/without_bom.txt
+}
+
+teardown() {
+ rm -rf test/static/
+}
+
+@test "rebom usage" {
+ run --separate-stderr rebom
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "Usage: rebom TARGET [OPTIONS]" ]
+}
+
+@test "rebom version" {
+ run --separate-stderr rebom --version
+ [ "$status" -eq 0 ]
+ [ "$output" = "rebom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom version - quiet" {
+ run --separate-stderr rebom --version --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "rebom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom version - quiet short" {
+ run --separate-stderr rebom --version -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "rebom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom version short" {
+ run --separate-stderr rebom -V
+ [ "$status" -eq 0 ]
+ [ "$output" = "rebom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom version short - quiet" {
+ run --separate-stderr rebom -V --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "rebom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom version short - quiet short" {
+ run --separate-stderr rebom -V -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "rebom 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom help" {
+ run --separate-stderr rebom --help
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Add BOM to a target file" ]
+ [ "${lines[1]}" = "Usage: rebom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom help - quiet" {
+ run --separate-stderr rebom --help --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Add BOM to a target file" ]
+ [ "${lines[1]}" = "Usage: rebom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom help - quiet short" {
+ run --separate-stderr rebom --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Add BOM to a target file" ]
+ [ "${lines[1]}" = "Usage: rebom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom help short" {
+ run --separate-stderr rebom -h
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Add BOM to a target file" ]
+ [ "${lines[1]}" = "Usage: rebom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom help short - quiet" {
+ run --separate-stderr rebom -h --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Add BOM to a target file" ]
+ [ "${lines[1]}" = "Usage: rebom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom help short - quiet short" {
+ run --separate-stderr rebom -h -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Add BOM to a target file" ]
+ [ "${lines[1]}" = "Usage: rebom TARGET [OPTIONS]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages and prompts" ]
+ [ "${lines[5]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[6]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom single" {
+ run --separate-stderr rebom test/static/without_bom.txt
+ [ "$status" -eq 0 ]
+ [ "$output" = $'\xEF\xBB\xBFfoo bar' ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom no such file" {
+ run --separate-stderr rebom foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "rebom: No such file 'foobarbaz'" ]
+}
+
+@test "rebom no such file - verbose" {
+ run --separate-stderr rebom --verbose foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "DEBUG:rebom:Argument 'foobarbaz' added to positional array" ]
+ [ "$stderr" = "ERROR:rebom:No such file 'foobarbaz'" ]
+}
+
+@test "rebom multiple" {
+ run --separate-stderr rebom test/static/without_bom.txt test/static/without_bom.txt
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = $'\xEF\xBB\xBFfoo bar' ]
+ [ "${lines[1]}" = "foo bar" ]
+ [ "$stderr" = "" ]
+}
+
+@test "rebom multiple error" {
+ run --separate-stderr rebom test/static/without_bom.txt foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = $'\xEF\xBB\xBFfoo bar' ]
+ [ "$stderr" = "rebom: No such file 'foobarbaz'" ]
+}
+
+@test "rebom multiple error - verbose" {
+ run --separate-stderr rebom --verbose test/static/without_bom.txt foobarbaz
+ [ "$status" -eq 1 ]
+ [ "${lines[0]}" = "DEBUG:rebom:Argument 'test/static/without_bom.txt' added to positional array" ]
+ [ "${lines[1]}" = "DEBUG:rebom:Argument 'foobarbaz' added to positional array" ]
+ [ "${lines[2]}" = $'\xEF\xBB\xBFfoo bar' ]
+ [ "$stderr" = "ERROR:rebom:No such file 'foobarbaz'" ]
+}
+
A core/test/whichcat.bats => core/test/whichcat.bats +195 -0
@@ 0,0 1,195 @@
+#!/usr/bin/env bats
+bats_require_minimum_version 1.5.0
+
+@test "whichcat usage" {
+ run --separate-stderr whichcat
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat usage - quiet" {
+ run --separate-stderr whichcat --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat usage - quiet short" {
+ run --separate-stderr whichcat -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat version" {
+ run --separate-stderr whichcat --version
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichcat 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat version - quiet" {
+ run --separate-stderr whichcat --version --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichcat 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat version - quiet short" {
+ run --separate-stderr whichcat --version -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichcat 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat version short" {
+ run --separate-stderr whichcat -v
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichcat 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat version short - quiet" {
+ run --separate-stderr whichcat -v --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichcat 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat version short - quiet short" {
+ run --separate-stderr whichcat -v --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichcat 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat help" {
+ run --separate-stderr whichcat --help
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print all lines from a program to the terminal" ]
+ [ "${lines[1]}" = "Usage: whichcat [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat help - quiet" {
+ run --separate-stderr whichcat --help --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print all lines from a program to the terminal" ]
+ [ "${lines[1]}" = "Usage: whichcat [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat help - quiet short" {
+ run --separate-stderr whichcat --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print all lines from a program to the terminal" ]
+ [ "${lines[1]}" = "Usage: whichcat [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat help short" {
+ run --separate-stderr whichcat -h
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print all lines from a program to the terminal" ]
+ [ "${lines[1]}" = "Usage: whichcat [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat help short - quiet" {
+ run --separate-stderr whichcat -h --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print all lines from a program to the terminal" ]
+ [ "${lines[1]}" = "Usage: whichcat [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat help short - quiet short" {
+ run --separate-stderr whichcat --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print all lines from a program to the terminal" ]
+ [ "${lines[1]}" = "Usage: whichcat [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat no such program" {
+ run --separate-stderr whichcat foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "whichcat: No such program 'foobarbaz'" ]
+}
+
+@test "whichcat no such program - quiet" {
+ run --separate-stderr whichcat --quiet foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat no such program - quiet short" {
+ run --separate-stderr whichcat -q foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat single" {
+ run --separate-stderr whichcat pip
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = '#!/usr/bin/python' ]
+ [ "${lines[1]}" = '# -*- coding: utf-8 -*-' ]
+ [ "${lines[2]}" = 'import re' ]
+ [ "${lines[3]}" = 'import sys' ]
+ [ "${lines[4]}" = 'from pip._internal.cli.main import main' ]
+ [ "${lines[5]}" = 'if __name__ == "__main__":' ]
+ [ "${lines[6]}" = ' sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])' ]
+ [ "${lines[7]}" = ' sys.exit(main())' ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichcat multiple" {
+ run --separate-stderr whichcat pip pip
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = '#!/usr/bin/python' ]
+ [ "${lines[1]}" = '# -*- coding: utf-8 -*-' ]
+ [ "${lines[2]}" = 'import re' ]
+ [ "${lines[3]}" = 'import sys' ]
+ [ "${lines[4]}" = 'from pip._internal.cli.main import main' ]
+ [ "${lines[5]}" = 'if __name__ == "__main__":' ]
+ [ "${lines[6]}" = ' sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])' ]
+ [ "${lines[7]}" = ' sys.exit(main())' ]
+ [ "${lines[8]}" = '#!/usr/bin/python' ]
+ [ "${lines[9]}" = '# -*- coding: utf-8 -*-' ]
+ [ "${lines[10]}" = 'import re' ]
+ [ "${lines[11]}" = 'import sys' ]
+ [ "${lines[12]}" = 'from pip._internal.cli.main import main' ]
+ [ "${lines[13]}" = 'if __name__ == "__main__":' ]
+ [ "${lines[14]}" = ' sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])' ]
+ [ "${lines[15]}" = ' sys.exit(main())' ]
+ [ "$stderr" = "" ]
+}
+
A core/test/whiched.bats => core/test/whiched.bats +159 -0
@@ 0,0 1,159 @@
+#!/usr/bin/env bats
+bats_require_minimum_version 1.5.0
+
+@test "whiched usage" {
+ run --separate-stderr whiched
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "Usage: whiched [OPTIONS] PROGRAM" ]
+}
+
+@test "whiched usage - quiet" {
+ run --separate-stderr whiched --quiet
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched usage - quiet short" {
+ run --separate-stderr whiched -q
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched version" {
+ run --separate-stderr whiched --version
+ [ "$status" -eq 0 ]
+ [ "$output" = "whiched 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched version - quiet" {
+ run --separate-stderr whiched --version --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whiched 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched version - quiet short" {
+ run --separate-stderr whiched --version -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "whiched 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched version short" {
+ run --separate-stderr whiched -v
+ [ "$status" -eq 0 ]
+ [ "$output" = "whiched 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched version short - quiet" {
+ run --separate-stderr whiched -v --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whiched 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched version short - quiet short" {
+ run --separate-stderr whiched -v --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whiched 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched help" {
+ run --separate-stderr whiched --help
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your editor" ]
+ [ "${lines[1]}" = "Usage: whiched [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched help - quiet" {
+ run --separate-stderr whiched --help --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your editor" ]
+ [ "${lines[1]}" = "Usage: whiched [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched help - quiet short" {
+ run --separate-stderr whiched --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your editor" ]
+ [ "${lines[1]}" = "Usage: whiched [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched help short" {
+ run --separate-stderr whiched -h
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your editor" ]
+ [ "${lines[1]}" = "Usage: whiched [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched help short - quiet" {
+ run --separate-stderr whiched -h --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your editor" ]
+ [ "${lines[1]}" = "Usage: whiched [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched help short - quiet short" {
+ run --separate-stderr whiched --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your editor" ]
+ [ "${lines[1]}" = "Usage: whiched [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched no such program" {
+ run --separate-stderr whiched foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "whiched: No such program 'foobarbaz'" ]
+}
+
+@test "whiched no such program - quiet" {
+ run --separate-stderr whiched --quiet foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whiched no such program - quiet short" {
+ run --separate-stderr whiched -q foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
A core/test/whichhead.bats => core/test/whichhead.bats +277 -0
@@ 0,0 1,277 @@
+#!/usr/bin/env bats
+bats_require_minimum_version 1.5.0
+
+@test "whichhead usage" {
+ run --separate-stderr whichhead
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead usage - quiet" {
+ run --separate-stderr whichhead --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead usage - quiet short" {
+ run --separate-stderr whichhead -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead version" {
+ run --separate-stderr whichhead --version
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichhead 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead version - quiet" {
+ run --separate-stderr whichhead --version --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichhead 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead version - quiet short" {
+ run --separate-stderr whichhead --version -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichhead 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead version short" {
+ run --separate-stderr whichhead -V
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichhead 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead version short - quiet" {
+ run --separate-stderr whichhead -V --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichhead 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead version short - quiet short" {
+ run --separate-stderr whichhead -V --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichhead 1.1" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead help" {
+ run --separate-stderr whichhead --help
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print the first 10 lines from a program" ]
+ [ "${lines[1]}" = "Usage: whichhead [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -n N, --number N print the first N lines (Default: 10)" ]
+ [ "${lines[5]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[6]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[7]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead help - quiet" {
+ run --separate-stderr whichhead --help --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print the first 10 lines from a program" ]
+ [ "${lines[1]}" = "Usage: whichhead [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -n N, --number N print the first N lines (Default: 10)" ]
+ [ "${lines[5]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[6]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[7]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead help - quiet short" {
+ run --separate-stderr whichhead --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print the first 10 lines from a program" ]
+ [ "${lines[1]}" = "Usage: whichhead [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -n N, --number N print the first N lines (Default: 10)" ]
+ [ "${lines[5]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[6]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[7]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead help short" {
+ run --separate-stderr whichhead -h
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print the first 10 lines from a program" ]
+ [ "${lines[1]}" = "Usage: whichhead [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -n N, --number N print the first N lines (Default: 10)" ]
+ [ "${lines[5]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[6]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[7]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead help short - quiet" {
+ run --separate-stderr whichhead -h --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print the first 10 lines from a program" ]
+ [ "${lines[1]}" = "Usage: whichhead [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -n N, --number N print the first N lines (Default: 10)" ]
+ [ "${lines[5]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[6]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[7]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead help short - quiet short" {
+ run --separate-stderr whichhead --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Print the first 10 lines from a program" ]
+ [ "${lines[1]}" = "Usage: whichhead [OPTIONS] [PROGRAM ..]" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -n N, --number N print the first N lines (Default: 10)" ]
+ [ "${lines[5]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[6]}" = " -v, --verbose show additional messages" ]
+ [ "${lines[7]}" = " -V, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead no such program" {
+ run --separate-stderr whichhead foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "whichhead: No such program 'foobarbaz'" ]
+}
+
+@test "whichhead no such program - quiet" {
+ run --separate-stderr whichhead --quiet foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead no such program - quiet short" {
+ run --separate-stderr whichhead -q foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead no such program - verbose" {
+ run --separate-stderr whichhead --verbose foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "DEBUG:whichhead:Argument 'foobarbaz' added to positional array" ]
+ [ "$stderr" = "ERROR:whichhead:No such program 'foobarbaz'" ]
+}
+
+@test "whichhead no such program - verbose short" {
+ run --separate-stderr whichhead -v foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "DEBUG:whichhead:Argument 'foobarbaz' added to positional array" ]
+ [ "$stderr" = "ERROR:whichhead:No such program 'foobarbaz'" ]
+}
+
+@test "whichhead single" {
+ run --separate-stderr whichhead pip
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = '#!/usr/bin/python' ]
+ [ "${lines[1]}" = '# -*- coding: utf-8 -*-' ]
+ [ "${lines[2]}" = 'import re' ]
+ [ "${lines[3]}" = 'import sys' ]
+ [ "${lines[4]}" = 'from pip._internal.cli.main import main' ]
+ [ "${lines[5]}" = 'if __name__ == "__main__":' ]
+ [ "${lines[6]}" = ' sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])' ]
+ [ "${lines[7]}" = ' sys.exit(main())' ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead single 1 line" {
+ run --separate-stderr whichhead --number 1 pip
+ [ "$status" -eq 0 ]
+ [ "$output" = '#!/usr/bin/python' ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead single 1 line short" {
+ run --separate-stderr whichhead -n 1 pip
+ [ "$status" -eq 0 ]
+ [ "$output" = '#!/usr/bin/python' ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead single 1 line - verbose" {
+ run --separate-stderr whichhead --verbose --number 1 pip
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "DEBUG:whichhead:Setting number of lines to 1 (was 10)" ]
+ [ "${lines[1]}" = "DEBUG:whichhead:Argument 'pip' added to positional array" ]
+ [ "${lines[2]}" = "#!/usr/bin/python" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead single too many lines" {
+ run --separate-stderr whichhead pip --number 500
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = '#!/usr/bin/python' ]
+ [ "${lines[1]}" = '# -*- coding: utf-8 -*-' ]
+ [ "${lines[2]}" = 'import re' ]
+ [ "${lines[3]}" = 'import sys' ]
+ [ "${lines[4]}" = 'from pip._internal.cli.main import main' ]
+ [ "${lines[5]}" = 'if __name__ == "__main__":' ]
+ [ "${lines[6]}" = ' sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])' ]
+ [ "${lines[7]}" = ' sys.exit(main())' ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead multiple" {
+ run --separate-stderr whichhead pip pip
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = '#!/usr/bin/python' ]
+ [ "${lines[1]}" = '# -*- coding: utf-8 -*-' ]
+ [ "${lines[2]}" = 'import re' ]
+ [ "${lines[3]}" = 'import sys' ]
+ [ "${lines[4]}" = 'from pip._internal.cli.main import main' ]
+ [ "${lines[5]}" = 'if __name__ == "__main__":' ]
+ [ "${lines[6]}" = ' sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])' ]
+ [ "${lines[7]}" = ' sys.exit(main())' ]
+ [ "${lines[8]}" = '#!/usr/bin/python' ]
+ [ "${lines[9]}" = '# -*- coding: utf-8 -*-' ]
+ [ "${lines[10]}" = 'import re' ]
+ [ "${lines[11]}" = 'import sys' ]
+ [ "${lines[12]}" = 'from pip._internal.cli.main import main' ]
+ [ "${lines[13]}" = 'if __name__ == "__main__":' ]
+ [ "${lines[14]}" = ' sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])' ]
+ [ "${lines[15]}" = ' sys.exit(main())' ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead multiple 1 line" {
+ run --separate-stderr whichhead pip pip --number 1
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = '#!/usr/bin/python' ]
+ [ "${lines[1]}" = '#!/usr/bin/python' ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichhead multiple 1 line - verbose" {
+ run --separate-stderr whichhead --verbose --number 1 pip pip
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "DEBUG:whichhead:Setting number of lines to 1 (was 10)" ]
+ [ "${lines[1]}" = "DEBUG:whichhead:Argument 'pip' added to positional array" ]
+ [ "${lines[2]}" = "DEBUG:whichhead:Argument 'pip' added to positional array" ]
+ [ "${lines[3]}" = "#!/usr/bin/python" ]
+ [ "${lines[4]}" = "#!/usr/bin/python" ]
+ [ "$stderr" = "" ]
+}
+
A core/test/whichvi.bats => core/test/whichvi.bats +159 -0
@@ 0,0 1,159 @@
+#!/usr/bin/env bats
+bats_require_minimum_version 1.5.0
+
+@test "whichvi usage" {
+ run --separate-stderr whichvi
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "Usage: whichvi [OPTIONS] PROGRAM" ]
+}
+
+@test "whichvi usage - quiet" {
+ run --separate-stderr whichvi --quiet
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi usage - quiet short" {
+ run --separate-stderr whichvi -q
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi version" {
+ run --separate-stderr whichvi --version
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichvi 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi version - quiet" {
+ run --separate-stderr whichvi --version --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichvi 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi version - quiet short" {
+ run --separate-stderr whichvi --version -q
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichvi 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi version short" {
+ run --separate-stderr whichvi -v
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichvi 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi version short - quiet" {
+ run --separate-stderr whichvi -v --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichvi 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi version short - quiet short" {
+ run --separate-stderr whichvi -v --quiet
+ [ "$status" -eq 0 ]
+ [ "$output" = "whichvi 1.2" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi help" {
+ run --separate-stderr whichvi --help
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your visual editor" ]
+ [ "${lines[1]}" = "Usage: whichvi [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi help - quiet" {
+ run --separate-stderr whichvi --help --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your visual editor" ]
+ [ "${lines[1]}" = "Usage: whichvi [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi help - quiet short" {
+ run --separate-stderr whichvi --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your visual editor" ]
+ [ "${lines[1]}" = "Usage: whichvi [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi help short" {
+ run --separate-stderr whichvi -h
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your visual editor" ]
+ [ "${lines[1]}" = "Usage: whichvi [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi help short - quiet" {
+ run --separate-stderr whichvi -h --quiet
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your visual editor" ]
+ [ "${lines[1]}" = "Usage: whichvi [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi help short - quiet short" {
+ run --separate-stderr whichvi --help -q
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "Open a program with your visual editor" ]
+ [ "${lines[1]}" = "Usage: whichvi [OPTIONS] PROGRAM" ]
+ [ "${lines[2]}" = "Options:" ]
+ [ "${lines[3]}" = " -h, --help print this message" ]
+ [ "${lines[4]}" = " -q, --quiet suppress error messages" ]
+ [ "${lines[5]}" = " -v, --version print version number and exit" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi no such program" {
+ run --separate-stderr whichvi foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "whichvi: No such program 'foobarbaz'" ]
+}
+
+@test "whichvi no such program - quiet" {
+ run --separate-stderr whichvi --quiet foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
+@test "whichvi no such program - quiet short" {
+ run --separate-stderr whichvi -q foobarbaz
+ [ "$status" -eq 1 ]
+ [ "$output" = "" ]
+ [ "$stderr" = "" ]
+}
+
D core/test_ctdir.sh => core/test_ctdir.sh +0 -35
@@ 1,35 0,0 @@
-#!/bin/sh
-# tests ctdir
-
-# move to temp directory
-cd test
-
-test_exit_code() {
- $1 >/dev/null 2>&1
- if [ $? -ne $2 ]; then
- printf "Failure in ctdir tests: wrong exit code ('$1' returned '$?', should be '$2')\n"
- exit 1
- fi
-}
-test_exit_code "../ctdir -v" "0"
-test_exit_code "../ctdir -h" "0"
-test_exit_code "../ctdir" "1"
-test_exit_code "../ctdir non-existant-directory" "1"
-test_exit_code "../ctdir ." "0"
-test_exit_code "../ctdir . non-existant-directory" "1"
-test_exit_code "../ctdir non-existant-directory ." "1"
-test_exit_code "../ctdir . ." "0"
-
-count=0
-for n in $(../ctdir ./ctdir ./ctdir); do
- count=$(($count+1))
- if [ "$n" -ne 10 ]; then
- printf "Failure in ctdir tests: wrong return value\n"
- exit 1
- fi
-done
-if [ $count -ne 2 ]; then
- printf "Failure in ctdir tests: wrong number of return values\n"
- exit 1
-fi
-
D core/test_init.sh => core/test_init.sh +0 -17
@@ 1,17 0,0 @@
-#!/bin/sh
-
-# create and move into temp directory
-mkdir test
-cd test
-
-# debom target
-printf "\xEF\xBB\xBFfoo bar\n" > debom_target.txt
-
-# rebom target
-printf "foo bar\n" > rebom_target.txt
-
-# ctdir targets
-mkdir ctdir
-touch ctdir/{a,b,c,d,e}.txt
-touch ctdir/.{f,g,h,i,j}.txt
-
D core/test_whichcat_whichhead.sh => core/test_whichcat_whichhead.sh +0 -34
@@ 1,34 0,0 @@
-#!/bin/sh
-# tests whichcat and whichhead
-
-# move to temp directory
-cd test
-
-test_exit_code() {
- $1 >/dev/null 2>&1
- if [ $? -ne $2 ]; then
- printf "Failure in whichcat tests: wrong exit code ('$1' returned '$?', should be '$2')\n"
- exit 1
- fi
-}
-test_exit_code "../whichcat -v" "0"
-test_exit_code "../whichcat -h" "0"
-test_exit_code "../whichcat" "0"
-test_exit_code "../whichcat non-existant-binary" "1"
-test_exit_code "../whichhead -v" "0"
-test_exit_code "../whichhead -h" "0"
-test_exit_code "../whichhead" "0"
-test_exit_code "../whichhead non-existant-binary" "1"
-
-should_be="$(wc -l ../whichcat | cut --delimiter=' ' --fields=1)"
-if [ "$(cd .. && ./whichcat whichcat | wc -l)" -ne "$should_be" ]; then
- printf "Failure in whichcat tests: wrong file returned\n"
- exit 1
-fi
-
-should_be="$((should_be * 2))"
-if [ "$(cd .. && ./whichcat whichcat whichcat | wc -l)" -ne "$should_be" ]; then
- printf "Failure in whichcat tests: wrong files returned\n"
- exit 1
-fi
-
D core/test_whiched_whichvi.sh => core/test_whiched_whichvi.sh +0 -33
@@ 1,33 0,0 @@
-#!/bin/sh
-# tests whiched and whichvi
-
-# move to temp directory
-cd test
-
-test_exit_code() {
- $1 >/dev/null 2>&1
- if [ $? -ne $2 ]; then
- printf "Failure in whiched tests: wrong exit code ('$1' returned '$?', should be '$2')\n"
- exit 1
- fi
-}
-test_exit_code "../whiched -v" "0"
-test_exit_code "../whiched -h" "0"
-test_exit_code "../whiched" "0"
-test_exit_code "../whiched non-existant-binary" "1"
-
-EDITOR=true
-test_exit_code "../whiched sh" "0"
-EDITOR=false
-test_exit_code "../whiched sh" "1"
-
-test_exit_code "../whichvi -v" "0"
-test_exit_code "../whichvi -h" "0"
-test_exit_code "../whichvi" "0"
-test_exit_code "../whichvi non-existant-binary" "1"
-
-VISUAL=true
-test_exit_code "../whichvi sh" "0"
-VISUAL=false
-test_exit_code "../whichvi sh" "1"
-