Run shfmt
This commit is contained in:
@@ -10,7 +10,11 @@
|
|||||||
export scmbDir="$(cd -P "$(dirname "$0")" && pwd)/../../.."
|
export scmbDir="$(cd -P "$(dirname "$0")" && pwd)/../../.."
|
||||||
|
|
||||||
# Zsh compatibility
|
# Zsh compatibility
|
||||||
if [ -n "${ZSH_VERSION:-}" ]; then shell="zsh"; SHUNIT_PARENT=$0; setopt shwordsplit; fi
|
if [ -n "${ZSH_VERSION:-}" ]; then
|
||||||
|
shell="zsh"
|
||||||
|
SHUNIT_PARENT=$0
|
||||||
|
setopt shwordsplit
|
||||||
|
fi
|
||||||
|
|
||||||
# Load test helpers
|
# Load test helpers
|
||||||
source "$scmbDir/test/support/test_helper.sh"
|
source "$scmbDir/test/support/test_helper.sh"
|
||||||
@@ -19,7 +23,6 @@ source "$scmbDir/test/support/test_helper.sh"
|
|||||||
source "$scmbDir/lib/scm_breeze.sh"
|
source "$scmbDir/lib/scm_breeze.sh"
|
||||||
source "$scmbDir/lib/git/repo_index.sh"
|
source "$scmbDir/lib/git/repo_index.sh"
|
||||||
|
|
||||||
|
|
||||||
# Setup and tear down
|
# Setup and tear down
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
oneTimeSetUp() {
|
oneTimeSetUp() {
|
||||||
@@ -34,7 +37,10 @@ oneTimeSetUp() {
|
|||||||
cd $GIT_REPO_DIR
|
cd $GIT_REPO_DIR
|
||||||
# Setup test repos in temp repo dir
|
# Setup test repos in temp repo dir
|
||||||
for repo in github bitbucket source_forge TestCaps; do
|
for repo in github bitbucket source_forge TestCaps; do
|
||||||
mkdir $repo; cd $repo; git init; cd - > /dev/null
|
mkdir $repo
|
||||||
|
cd $repo
|
||||||
|
git init
|
||||||
|
cd - >/dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
# Add some nested dirs for testing resursive tab completion
|
# Add some nested dirs for testing resursive tab completion
|
||||||
@@ -55,13 +61,18 @@ EOF
|
|||||||
mkdir -p "very/nested/directory"
|
mkdir -p "very/nested/directory"
|
||||||
cd "very/nested/directory"
|
cd "very/nested/directory"
|
||||||
for repo in red_submodule green_submodule blue_submodule; do
|
for repo in red_submodule green_submodule blue_submodule; do
|
||||||
mkdir $repo; cd $repo; git init; cd - > /dev/null
|
mkdir $repo
|
||||||
|
cd $repo
|
||||||
|
git init
|
||||||
|
cd - >/dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
# Setup some custom repos outside the main repo dir
|
# Setup some custom repos outside the main repo dir
|
||||||
IFS=":"
|
IFS=":"
|
||||||
for dir in $GIT_REPOS; do
|
for dir in $GIT_REPOS; do
|
||||||
mkdir -p $dir; cd $dir; git init;
|
mkdir -p $dir
|
||||||
|
cd $dir
|
||||||
|
git init
|
||||||
done
|
done
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
@@ -85,7 +96,6 @@ index_no_newlines() {
|
|||||||
tr "\\n" " " < $git_index_file
|
tr "\\n" " " < $git_index_file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Unit tests
|
# Unit tests
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -136,16 +146,26 @@ test_repo_list() {
|
|||||||
# Test matching rules for changing directory
|
# Test matching rules for changing directory
|
||||||
test_git_index_changing_directory() {
|
test_git_index_changing_directory() {
|
||||||
ensureIndex
|
ensureIndex
|
||||||
git_index "github"; assertEquals "$GIT_REPO_DIR/github" "$PWD"
|
git_index "github"
|
||||||
git_index "github/"; assertEquals "$GIT_REPO_DIR/github" "$PWD"
|
assertEquals "$GIT_REPO_DIR/github" "$PWD"
|
||||||
git_index "bucket"; assertEquals "$GIT_REPO_DIR/bitbucket" "$PWD"
|
git_index "github/"
|
||||||
git_index "testcaps"; assertEquals "$GIT_REPO_DIR/TestCaps" "$PWD"
|
assertEquals "$GIT_REPO_DIR/github" "$PWD"
|
||||||
git_index "green_sub"; assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/green_submodule" "$PWD"
|
git_index "bucket"
|
||||||
git_index "_submod"; assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/blue_submodule" "$PWD"
|
assertEquals "$GIT_REPO_DIR/bitbucket" "$PWD"
|
||||||
git_index "test_repo_1"; assertEquals "/tmp/test_repo_1" "$PWD"
|
git_index "testcaps"
|
||||||
git_index "test_repo_11"; assertEquals "/tmp/test_repo_11" "$PWD"
|
assertEquals "$GIT_REPO_DIR/TestCaps" "$PWD"
|
||||||
git_index "test_repo_"; assertEquals "/tmp/test_repo_1" "$PWD"
|
git_index "green_sub"
|
||||||
git_index "github/videos/octocat/live_action"; assertEquals "$GIT_REPO_DIR/github/videos/octocat/live_action" "$PWD"
|
assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/green_submodule" "$PWD"
|
||||||
|
git_index "_submod"
|
||||||
|
assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/blue_submodule" "$PWD"
|
||||||
|
git_index "test_repo_1"
|
||||||
|
assertEquals "/tmp/test_repo_1" "$PWD"
|
||||||
|
git_index "test_repo_11"
|
||||||
|
assertEquals "/tmp/test_repo_11" "$PWD"
|
||||||
|
git_index "test_repo_"
|
||||||
|
assertEquals "/tmp/test_repo_1" "$PWD"
|
||||||
|
git_index "github/videos/octocat/live_action"
|
||||||
|
assertEquals "$GIT_REPO_DIR/github/videos/octocat/live_action" "$PWD"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_git_index_tab_completion() {
|
test_git_index_tab_completion() {
|
||||||
@@ -175,7 +195,6 @@ test_git_index_tab_completion() {
|
|||||||
_git_index_tab_completion
|
_git_index_tab_completion
|
||||||
assertIncludes "$(tab_completions)" "github/videos/octocat/"
|
assertIncludes "$(tab_completions)" "github/videos/octocat/"
|
||||||
|
|
||||||
|
|
||||||
# Test that completion checks for other matching projects even if one matches perfectly
|
# Test that completion checks for other matching projects even if one matches perfectly
|
||||||
COMP_WORDS="test_repo_1"
|
COMP_WORDS="test_repo_1"
|
||||||
_git_index_tab_completion
|
_git_index_tab_completion
|
||||||
@@ -183,7 +202,6 @@ test_git_index_tab_completion() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Test changing to top-level directory (when arg begins with '/')
|
# Test changing to top-level directory (when arg begins with '/')
|
||||||
test_changing_to_top_level_directory() {
|
test_changing_to_top_level_directory() {
|
||||||
mkdir "$GIT_REPO_DIR/gems"
|
mkdir "$GIT_REPO_DIR/gems"
|
||||||
@@ -191,8 +209,6 @@ test_changing_to_top_level_directory() {
|
|||||||
assertEquals "$GIT_REPO_DIR/gems" "$PWD"
|
assertEquals "$GIT_REPO_DIR/gems" "$PWD"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# load and run shUnit2
|
# load and run shUnit2
|
||||||
# Call this function to run tests
|
# Call this function to run tests
|
||||||
source "$scmbDir/test/support/shunit2"
|
source "$scmbDir/test/support/shunit2"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user