From ba0044ecea3bbf4e37cf60590305a2f470e28795 Mon Sep 17 00:00:00 2001 From: Daylon Wilkins Date: Thu, 18 Jul 2019 14:21:34 -0700 Subject: [PATCH] Moved bats windows compatibility changes to separate file --- bats/git-dolt.bats | 20 +------------------- bats/helper/windows-compat.bash | 26 ++++++++++++++++++++++++++ bats/remotes.bats | 18 +----------------- bats/sql-shell.bats | 17 +---------------- 4 files changed, 29 insertions(+), 52 deletions(-) create mode 100644 bats/helper/windows-compat.bash diff --git a/bats/git-dolt.bats b/bats/git-dolt.bats index af35c136a1..1179c57971 100755 --- a/bats/git-dolt.bats +++ b/bats/git-dolt.bats @@ -7,25 +7,7 @@ setup() { export BATS_TMPDIR=$HOME/batstmp/ mkdir $BATS_TMPDIR fi - - skiponwindows() { :; } - - unameOut="$(uname -s)" - case "${unameOut}" in - CYGWIN*) machine=Windows;; - MINGW*) machine=Windows;; - *) machine=Unix;; - esac - - if [ ${machine} = "Windows" ]; then - pkill() { - taskkill -fi "IMAGENAME eq $2*" -f - } - skiponwindows() { - skip "$1" - } - fi - + load $BATS_TEST_DIRNAME/helper/windows-compat.bash export PATH=$PATH:$GOPATH/bin export NOMS_VERSION_NEXT=1 cd $BATS_TMPDIR diff --git a/bats/helper/windows-compat.bash b/bats/helper/windows-compat.bash new file mode 100644 index 0000000000..9a0283529f --- /dev/null +++ b/bats/helper/windows-compat.bash @@ -0,0 +1,26 @@ +skiponwindows() { :; } + +unameOut="$(uname -s)" +case "${unameOut}" in + CYGWIN*) machine=Windows;; + MINGW*) machine=Windows;; + *) machine=Unix;; +esac + +if [ ${machine} = "Windows" ]; then + skiponwindows() { + skip "$1" + } +fi + +if ! [ -x "$(command -v pkill)" ]; then + pkill() { + taskkill -fi "IMAGENAME eq $2*" -f + } +fi + +if ! [ -x "$(command -v pgrep)" ]; then + pgrep() { + tasklist -fi "IMAGENAME eq $1*" + } +fi diff --git a/bats/remotes.bats b/bats/remotes.bats index 9b767749f5..12c207652b 100644 --- a/bats/remotes.bats +++ b/bats/remotes.bats @@ -5,23 +5,7 @@ setup() { export BATS_TMPDIR=$HOME/batstmp/ mkdir $BATS_TMPDIR fi - - unameOut="$(uname -s)" - case "${unameOut}" in - CYGWIN*) machine=Windows;; - MINGW*) machine=Windows;; - *) machine=Unix;; - esac - - if [ ${machine} = "Windows" ]; then - pkill() { - taskkill -fi "IMAGENAME eq $2*" -f - } - pgrep() { - tasklist -fi "IMAGENAME eq $1*" - } - fi - + load $BATS_TEST_DIRNAME/helper/windows-compat.bash export PATH=$PATH:~/go/bin export NOMS_VERSION_NEXT=1 cd $BATS_TMPDIR diff --git a/bats/sql-shell.bats b/bats/sql-shell.bats index b551464429..c5d20113f3 100644 --- a/bats/sql-shell.bats +++ b/bats/sql-shell.bats @@ -3,22 +3,7 @@ setup() { export PATH=$PATH:~/go/bin export NOMS_VERSION_NEXT=1 - - skiponwindows() { :; } - - unameOut="$(uname -s)" - case "${unameOut}" in - CYGWIN*) machine=Windows;; - MINGW*) machine=Windows;; - *) machine=Unix;; - esac - - if [ ${machine} = "Windows" ]; then - skiponwindows() { - skip "$1" - } - fi - + load $BATS_TEST_DIRNAME/helper/windows-compat.bash cd $BATS_TMPDIR mkdir "dolt-repo-$$" cd "dolt-repo-$$"