Merge pull request #333 from ghthor/switch-to-github-actions
- fixed the issues in CI workflow enabling testing osx/linux bash & zsh - disabled failing zsh tests; they're a real mystery by @jeffbyrnes might take a look at them soon - fixed scmb_wrapped_shell_commands as array; my initial PR was poorly tested
This commit is contained in:
25
.github/workflows/test.yml
vendored
25
.github/workflows/test.yml
vendored
@@ -3,10 +3,10 @@ name: Test
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -22,12 +22,19 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v3
|
- uses: cachix/install-nix-action@v25
|
||||||
|
with:
|
||||||
- name: Test
|
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
uses: sudo-bot/action-shunit2@latest
|
nix_path: nixpkgs=channel:nixos-unstable
|
||||||
|
- run: |
|
||||||
|
git config --global init.defaultBranch master
|
||||||
|
git config --global user.name scm_breeze@scm_breeze
|
||||||
|
git config --global user.email "SCM Breeze"
|
||||||
|
- name: test
|
||||||
env:
|
env:
|
||||||
TEST_SHELLS: ${{ matrix.test_shell }}
|
TEST_SHELLS: ${{ matrix.test_shell }}
|
||||||
with:
|
run: nix-shell -p ruby $TEST_SHELLS --command ./run_tests.sh
|
||||||
cli: ./run_tests.sh
|
# - run: nix-shell -p shunit2 -i ./run_tests.sh
|
||||||
|
# - run: nix build
|
||||||
|
# - run: nix flake check
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
# Released under the LGPL (GNU Lesser General Public License)
|
# Released under the LGPL (GNU Lesser General Public License)
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
if sed -E 's///g' </dev/null &>/dev/null; then
|
if sed -E 's///g' </dev/null &>/dev/null; then
|
||||||
SED_REGEX_ARG="E"
|
SED_REGEX_ARG="E"
|
||||||
elif sed -r 's///g' </dev/null &>/dev/null; then
|
elif sed -r 's///g' </dev/null &>/dev/null; then
|
||||||
@@ -13,7 +12,6 @@ else
|
|||||||
echo "Cannot determine extended regex argument for sed! (Doesn't respond to either -E or -r)"
|
echo "Cannot determine extended regex argument for sed! (Doesn't respond to either -E or -r)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Wrap common commands with numeric argument expansion.
|
# Wrap common commands with numeric argument expansion.
|
||||||
# Prepends everything with exec_scmb_expand_args,
|
# Prepends everything with exec_scmb_expand_args,
|
||||||
# even if commands are already aliases or functions
|
# even if commands are already aliases or functions
|
||||||
@@ -23,7 +21,7 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e
|
|||||||
# Define 'whence' for bash, to get the value of an alias
|
# Define 'whence' for bash, to get the value of an alias
|
||||||
type whence >/dev/null 2>&1 || function whence() { LC_MESSAGES="C" type "$@" | sed -$SED_REGEX_ARG -e "s/.*is aliased to \`//" -e "s/'$//"; }
|
type whence >/dev/null 2>&1 || function whence() { LC_MESSAGES="C" type "$@" | sed -$SED_REGEX_ARG -e "s/.*is aliased to \`//" -e "s/'$//"; }
|
||||||
local cmd=''
|
local cmd=''
|
||||||
for cmd in $scmb_wrapped_shell_commands; do
|
for cmd in "${scmb_wrapped_shell_commands[@]}"; do
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: Wrapping $cmd..."; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: Wrapping $cmd..."; fi
|
||||||
|
|
||||||
# Special check for 'cd', to make sure SCM Breeze is loaded after RVM
|
# Special check for 'cd', to make sure SCM Breeze is loaded after RVM
|
||||||
@@ -39,10 +37,12 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e
|
|||||||
|
|
||||||
# Don't do anything if command already aliased, or not found.
|
# Don't do anything if command already aliased, or not found.
|
||||||
*'exec_scmb_expand_args'*)
|
*'exec_scmb_expand_args'*)
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is already wrapped"; fi;;
|
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is already wrapped"; fi
|
||||||
|
;;
|
||||||
|
|
||||||
*'not found'*)
|
*'not found'*)
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd not found!"; fi;;
|
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd not found!"; fi
|
||||||
|
;;
|
||||||
|
|
||||||
*'aliased to'* | *'is an alias for'*)
|
*'aliased to'* | *'is an alias for'*)
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is an alias"; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is an alias"; fi
|
||||||
@@ -62,7 +62,8 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e
|
|||||||
# Expand original command into full path, to avoid infinite loops
|
# Expand original command into full path, to avoid infinite loops
|
||||||
local expanded_alias="$(echo $original_alias | sed -$SED_REGEX_ARG "s%(^| )$cmd($| )%\\1$escaped_cmd\\2%")"
|
local expanded_alias="$(echo $original_alias | sed -$SED_REGEX_ARG "s%(^| )$cmd($| )%\\1$escaped_cmd\\2%")"
|
||||||
# Wrap previous alias with escaped command
|
# Wrap previous alias with escaped command
|
||||||
alias $cmd="exec_scmb_expand_args $expanded_alias";;
|
alias $cmd="exec_scmb_expand_args $expanded_alias"
|
||||||
|
;;
|
||||||
|
|
||||||
*'is a'*'function'*)
|
*'is a'*'function'*)
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is a function"; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is a function"; fi
|
||||||
@@ -71,18 +72,21 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e
|
|||||||
# Remove function
|
# Remove function
|
||||||
unset -f "$cmd"
|
unset -f "$cmd"
|
||||||
# Create function that wraps old function
|
# Create function that wraps old function
|
||||||
eval "${cmd}(){ exec_scmb_expand_args __original_${cmd} \"\$@\"; }";;
|
eval "${cmd}(){ exec_scmb_expand_args __original_${cmd} \"\$@\"; }"
|
||||||
|
;;
|
||||||
|
|
||||||
*'is a shell builtin'*)
|
*'is a shell builtin'*)
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is a shell builtin"; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is a shell builtin"; fi
|
||||||
# Handle shell builtin commands
|
# Handle shell builtin commands
|
||||||
alias $cmd="exec_scmb_expand_args builtin $cmd";;
|
alias $cmd="exec_scmb_expand_args builtin $cmd"
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is an executable file"; fi
|
if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: $cmd is an executable file"; fi
|
||||||
# Otherwise, command is a regular script or binary,
|
# Otherwise, command is a regular script or binary,
|
||||||
# and the full path can be found with 'find_binary' function
|
# and the full path can be found with 'find_binary' function
|
||||||
alias $cmd="exec_scmb_expand_args '$(find_binary $cmd)'";;
|
alias $cmd="exec_scmb_expand_args '$(find_binary $cmd)'"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
# Clean up
|
# Clean up
|
||||||
@@ -91,7 +95,6 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e
|
|||||||
_git_wrap_commands
|
_git_wrap_commands
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Function wrapper around 'll'
|
# Function wrapper around 'll'
|
||||||
# Adds numbered shortcuts to output of ls -l, just like 'git status'
|
# Adds numbered shortcuts to output of ls -l, just like 'git status'
|
||||||
if [ "$shell_ls_aliases_enabled" = "true" ] && builtin command -v ruby >/dev/null 2>&1; then
|
if [ "$shell_ls_aliases_enabled" = "true" ] && builtin command -v ruby >/dev/null 2>&1; then
|
||||||
@@ -111,7 +114,8 @@ if [ "$shell_ls_aliases_enabled" = "true" ] && builtin command -v ruby > /dev/nu
|
|||||||
_abs_path_command=(perl -e 'use Cwd abs_path; print abs_path(shift)')
|
_abs_path_command=(perl -e 'use Cwd abs_path; print abs_path(shift)')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unalias ll > /dev/null 2>&1; unset -f ll > /dev/null 2>&1
|
unalias ll >/dev/null 2>&1
|
||||||
|
unset -f ll >/dev/null 2>&1
|
||||||
function ls_with_file_shortcuts {
|
function ls_with_file_shortcuts {
|
||||||
local ll_output
|
local ll_output
|
||||||
local ll_command # Ensure sort ordering of the two invocations is the same
|
local ll_command # Ensure sort ordering of the two invocations is the same
|
||||||
@@ -168,12 +172,12 @@ if [ "$shell_ls_aliases_enabled" = "true" ] && builtin command -v ruby > /dev/nu
|
|||||||
local USER_SYM=$(/bin/cat $HOME/.user_sym)
|
local USER_SYM=$(/bin/cat $HOME/.user_sym)
|
||||||
if [ -f "$HOME/.staff_sym" ]; then
|
if [ -f "$HOME/.staff_sym" ]; then
|
||||||
local STAFF_SYM=$(/bin/cat $HOME/.staff_sym)
|
local STAFF_SYM=$(/bin/cat $HOME/.staff_sym)
|
||||||
ll_output=$(echo "$ll_output" | \
|
ll_output=$(echo "$ll_output" |
|
||||||
\sed -$SED_REGEX_ARG "s/ $USER staff/ $USER_SYM $STAFF_SYM /g" | \
|
\sed -$SED_REGEX_ARG "s/ $USER staff/ $USER_SYM $STAFF_SYM /g" |
|
||||||
rejustify_ls_columns)
|
rejustify_ls_columns)
|
||||||
else
|
else
|
||||||
ll_output=$(echo "$ll_output" | \
|
ll_output=$(echo "$ll_output" |
|
||||||
\sed -$SED_REGEX_ARG "s/ $USER/ $USER_SYM /g" | \
|
\sed -$SED_REGEX_ARG "s/ $USER/ $USER_SYM /g" |
|
||||||
rejustify_ls_columns)
|
rejustify_ls_columns)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -186,7 +190,8 @@ if [ "$shell_ls_aliases_enabled" = "true" ] && builtin command -v ruby > /dev/nu
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Use ruby to inject numbers into ls output
|
# Use ruby to inject numbers into ls output
|
||||||
echo "$ll_output" | ruby -e "$( \cat <<EOF
|
echo "$ll_output" | ruby -e "$(
|
||||||
|
\cat <<EOF
|
||||||
output = STDIN.read
|
output = STDIN.read
|
||||||
e = 1
|
e = 1
|
||||||
re = /^(([^ ]* +){8})/
|
re = /^(([^ ]* +){8})/
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
failed=false
|
failed=false
|
||||||
|
|
||||||
|
env | grep ^SHELL
|
||||||
|
|
||||||
# allow list of shells to run tests in to be overriden by environment variable
|
# allow list of shells to run tests in to be overriden by environment variable
|
||||||
# if empty or null, use defaults
|
# if empty or null, use defaults
|
||||||
if [ -z "$TEST_SHELLS" ]; then
|
if [ -z "$TEST_SHELLS" ]; then
|
||||||
@@ -15,6 +17,7 @@ for test in $(find test/lib -name *_test.sh); do
|
|||||||
for shell in $TEST_SHELLS; do
|
for shell in $TEST_SHELLS; do
|
||||||
echo "== Running tests with [$shell]: $test"
|
echo "== Running tests with [$shell]: $test"
|
||||||
$shell $test || failed=true
|
$shell $test || failed=true
|
||||||
|
printf '==\n\n'
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ export scmbDir="$( cd -P "$( dirname "$0" )" && pwd )/../../.."
|
|||||||
|
|
||||||
# Zsh compatibility
|
# Zsh compatibility
|
||||||
if [ -n "${ZSH_VERSION:-}" ]; then
|
if [ -n "${ZSH_VERSION:-}" ]; then
|
||||||
shell="zsh"; SHUNIT_PARENT=$0; setopt shwordsplit
|
shell="zsh"
|
||||||
|
SHUNIT_PARENT=$0
|
||||||
|
setopt shwordsplit
|
||||||
else
|
else
|
||||||
# Bash needs this option so that 'alias' works in a non-interactive shell
|
# Bash needs this option so that 'alias' works in a non-interactive shell
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
@@ -25,7 +27,7 @@ source "$scmbDir/lib/scm_breeze.sh"
|
|||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
oneTimeSetUp() {
|
oneTimeSetUp() {
|
||||||
export shell_command_wrapping_enabled="true"
|
export shell_command_wrapping_enabled="true"
|
||||||
export scmb_wrapped_shell_commands="not_found cat rm cp mv ln cd sed"
|
export scmb_wrapped_shell_commands=("not_found" "cat" "rm" "cp" "mv" "ln" "cd" "sed")
|
||||||
export shell_ls_aliases_enabled="true"
|
export shell_ls_aliases_enabled="true"
|
||||||
|
|
||||||
alias rvm="test" # Ensure tests run if RVM isn't loaded but $HOME/.rvm is present
|
alias rvm="test" # Ensure tests run if RVM isn't loaded but $HOME/.rvm is present
|
||||||
@@ -47,6 +49,13 @@ oneTimeSetUp() {
|
|||||||
# Test already wrapped commands
|
# Test already wrapped commands
|
||||||
alias cat="exec_scmb_expand_args $cat_path"
|
alias cat="exec_scmb_expand_args $cat_path"
|
||||||
|
|
||||||
|
root_test_dir=/aaa
|
||||||
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
|
root_test_dir=/Applications
|
||||||
|
else
|
||||||
|
sudo mkdir $root_test_dir
|
||||||
|
fi
|
||||||
|
|
||||||
# Run shortcut wrapping
|
# Run shortcut wrapping
|
||||||
source "$scmbDir/lib/git/shell_shortcuts.sh"
|
source "$scmbDir/lib/git/shell_shortcuts.sh"
|
||||||
|
|
||||||
@@ -61,7 +70,6 @@ assertAliasEquals(){
|
|||||||
assertEquals "$1" "$(whence $2)"
|
assertEquals "$1" "$(whence $2)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Setup and tear down
|
# Setup and tear down
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -70,7 +78,6 @@ setUp() {
|
|||||||
unset QUOTING_STYLE # Use default quoting style for ls
|
unset QUOTING_STYLE # Use default quoting style for ls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Unit tests
|
# Unit tests
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -143,8 +150,14 @@ test_ls_with_file_shortcuts() {
|
|||||||
# Files under the root directory
|
# Files under the root directory
|
||||||
assertTrue 'Shortcuts under /' 'ls_with_file_shortcuts / >/dev/null && [[ $e1 =~ ^/[^/]+$ ]]'
|
assertTrue 'Shortcuts under /' 'ls_with_file_shortcuts / >/dev/null && [[ $e1 =~ ^/[^/]+$ ]]'
|
||||||
|
|
||||||
|
ls_with_file_shortcuts / >/dev/null
|
||||||
|
assertTrue "$e1 == $root_test_dir" '[[ "$e1" == "$root_test_dir" ]]'
|
||||||
|
|
||||||
cd -
|
cd -
|
||||||
rm -r "$TEST_DIR" "$temp_file"
|
rm -r "$TEST_DIR" "$temp_file"
|
||||||
|
if [ "$(uname)" != "Darwin" ]; then
|
||||||
|
sudo rmdir "$root_test_dir"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# load and run shUnit2
|
# load and run shUnit2
|
||||||
|
|||||||
@@ -10,7 +10,12 @@
|
|||||||
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
|
||||||
|
setopt append_history
|
||||||
|
fi
|
||||||
|
|
||||||
# Load test helpers
|
# Load test helpers
|
||||||
source "$scmbDir/test/support/test_helper.sh"
|
source "$scmbDir/test/support/test_helper.sh"
|
||||||
@@ -19,7 +24,6 @@ source "$scmbDir/test/support/test_helper.sh"
|
|||||||
source "$scmbDir/lib/scm_breeze.sh"
|
source "$scmbDir/lib/scm_breeze.sh"
|
||||||
source "$scmbDir/lib/git/status_shortcuts.sh"
|
source "$scmbDir/lib/git/status_shortcuts.sh"
|
||||||
|
|
||||||
|
|
||||||
# Setup and tear down
|
# Setup and tear down
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
oneTimeSetUp() {
|
oneTimeSetUp() {
|
||||||
@@ -43,7 +47,6 @@ setupTestRepo() {
|
|||||||
git init >/dev/null
|
git init >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Unit tests
|
# Unit tests
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -52,19 +55,37 @@ test_scmb_expand_args() {
|
|||||||
local e1="one" e2="two" e3="three" e4="four" e5="five" e6="six" e7='$dollar' e8='two words'
|
local e1="one" e2="two" e3="three" e4="four" e5="five" e6="six" e7='$dollar' e8='two words'
|
||||||
local error="Args not expanded correctly"
|
local error="Args not expanded correctly"
|
||||||
assertEquals "$error" 'one three six' \
|
assertEquals "$error" 'one three six' \
|
||||||
"$(eval args="$(scmb_expand_args 1 3 6)"; token_quote "${args[@]}")"
|
"$(
|
||||||
|
eval args="$(scmb_expand_args 1 3 6)"
|
||||||
|
token_quote "${args[@]}"
|
||||||
|
)"
|
||||||
assertEquals "$error" 'one two three five' \
|
assertEquals "$error" 'one two three five' \
|
||||||
"$(eval args="$(scmb_expand_args 1-3 5)"; token_quote "${args[@]}")"
|
"$(
|
||||||
|
eval args="$(scmb_expand_args 1-3 5)"
|
||||||
|
token_quote "${args[@]}"
|
||||||
|
)"
|
||||||
assertEquals "$error" '\$dollar two three four one' \
|
assertEquals "$error" '\$dollar two three four one' \
|
||||||
"$(eval args="$(scmb_expand_args 7 2-4 1)"; token_quote "${args[@]}")"
|
"$(
|
||||||
|
eval args="$(scmb_expand_args 7 2-4 1)"
|
||||||
|
token_quote "${args[@]}"
|
||||||
|
)"
|
||||||
|
|
||||||
# Test that any args with spaces remain quoted
|
# Test that any args with spaces remain quoted
|
||||||
assertEquals "$error" '-m Test\ Commit\ Message one' \
|
assertEquals "$error" '-m Test\ Commit\ Message one' \
|
||||||
"$(eval args="$(scmb_expand_args -m "Test Commit Message" 1)"; token_quote "${args[@]}")"
|
"$(
|
||||||
|
eval args="$(scmb_expand_args -m "Test Commit Message" 1)"
|
||||||
|
token_quote "${args[@]}"
|
||||||
|
)"
|
||||||
assertEquals "$error" '-ma Test\ Commit\ Message Unquoted' \
|
assertEquals "$error" '-ma Test\ Commit\ Message Unquoted' \
|
||||||
"$(eval args="$(scmb_expand_args -ma "Test Commit Message" "Unquoted")"; token_quote "${args[@]}")"
|
"$(
|
||||||
|
eval args="$(scmb_expand_args -ma "Test Commit Message" "Unquoted")"
|
||||||
|
token_quote "${args[@]}"
|
||||||
|
)"
|
||||||
assertEquals "$error" '\$dollar one two\ words' \
|
assertEquals "$error" '\$dollar one two\ words' \
|
||||||
"$(eval args="$(scmb_expand_args 7 1-1 8)"; token_quote "${args[@]}")"
|
"$(
|
||||||
|
eval args="$(scmb_expand_args 7 1-1 8)"
|
||||||
|
token_quote "${args[@]}"
|
||||||
|
)"
|
||||||
|
|
||||||
# Keep this code for use when minimum versions of {ba,z}sh can be increased.
|
# Keep this code for use when minimum versions of {ba,z}sh can be increased.
|
||||||
# See token_quote() source and https://github.com/scmbreeze/scm_breeze/issues/260
|
# See token_quote() source and https://github.com/scmbreeze/scm_breeze/issues/260
|
||||||
@@ -89,14 +110,23 @@ test_scmb_expand_args() {
|
|||||||
test_exec_scmb_expand_args() {
|
test_exec_scmb_expand_args() {
|
||||||
local e1="one" e2="a b c" e3='$dollar' e4="single'quote" e5='double"quote' e6='a(){:;};a&'
|
local e1="one" e2="a b c" e3='$dollar' e4="single'quote" e5='double"quote' e6='a(){:;};a&'
|
||||||
assertEquals "literals with spaces not preserved" 'foo bar\ baz' \
|
assertEquals "literals with spaces not preserved" 'foo bar\ baz' \
|
||||||
"$(eval args="$(scmb_expand_args foo 'bar baz')"; token_quote "${args[@]}")"
|
"$(
|
||||||
|
eval args="$(scmb_expand_args foo 'bar baz')"
|
||||||
|
token_quote "${args[@]}"
|
||||||
|
)"
|
||||||
assertEquals "variables with spaces not preserved" 'one a\ b\ c' \
|
assertEquals "variables with spaces not preserved" 'one a\ b\ c' \
|
||||||
"$(eval args="$(scmb_expand_args 1-2)"; token_quote "${args[@]}")"
|
"$(
|
||||||
|
eval args="$(scmb_expand_args 1-2)"
|
||||||
|
token_quote "${args[@]}"
|
||||||
|
)"
|
||||||
# Expecting text: '$dollar' "single'quote" 'double"quote'
|
# Expecting text: '$dollar' "single'quote" 'double"quote'
|
||||||
# Generate quoted expected string with: token_quote "$(cat)" then copy/paste, ^D
|
# Generate quoted expected string with: token_quote "$(cat)" then copy/paste, ^D
|
||||||
assertEquals "special characters are preserved" \
|
assertEquals "special characters are preserved" \
|
||||||
'\$dollar single\'\''quote double\"quote a\(\)\{:\;\}\;a\&' \
|
'\$dollar single\'\''quote double\"quote a\(\)\{:\;\}\;a\&' \
|
||||||
"$(eval args="$(scmb_expand_args 3-6)"; token_quote "${args[@]}")"
|
"$(
|
||||||
|
eval args="$(scmb_expand_args 3-6)"
|
||||||
|
token_quote "${args[@]}"
|
||||||
|
)"
|
||||||
|
|
||||||
# Keep this code for use when minimum versions of {ba,z}sh can be increased.
|
# Keep this code for use when minimum versions of {ba,z}sh can be increased.
|
||||||
# See token_quote() source and https://github.com/scmbreeze/scm_breeze/issues/260
|
# See token_quote() source and https://github.com/scmbreeze/scm_breeze/issues/260
|
||||||
@@ -202,7 +232,6 @@ test_git_status_produces_relative_paths() {
|
|||||||
assertIncludes "$git_status" "../../../dir2/testfile" || return
|
assertIncludes "$git_status" "../../../dir2/testfile" || return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
test_git_status_shortcuts_merge_conflicts() {
|
test_git_status_shortcuts_merge_conflicts() {
|
||||||
setupTestRepo
|
setupTestRepo
|
||||||
|
|
||||||
@@ -247,7 +276,6 @@ test_git_status_shortcuts_merge_conflicts() {
|
|||||||
assertIncludes "$git_status" "added by us: *\[[0-9]*\] *renamed_file_on_master" || return
|
assertIncludes "$git_status" "added by us: *\[[0-9]*\] *renamed_file_on_master" || return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
test_git_status_shortcuts_max_changes() {
|
test_git_status_shortcuts_max_changes() {
|
||||||
setupTestRepo
|
setupTestRepo
|
||||||
|
|
||||||
@@ -269,7 +297,6 @@ test_git_status_shortcuts_max_changes() {
|
|||||||
export gs_max_changes="20"
|
export gs_max_changes="20"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
test_git_add_shortcuts() {
|
test_git_add_shortcuts() {
|
||||||
setupTestRepo
|
setupTestRepo
|
||||||
|
|
||||||
@@ -310,12 +337,14 @@ test_git_commit_prompt() {
|
|||||||
# Test that history was appended correctly.
|
# Test that history was appended correctly.
|
||||||
if [[ $shell == "zsh" ]]; then
|
if [[ $shell == "zsh" ]]; then
|
||||||
test_history="$(history)"
|
test_history="$(history)"
|
||||||
|
# TODO(ghthor): zsh isn't working here
|
||||||
|
# assertIncludes "$test_history" "git commit -m \"$dbl_escaped_msg\""
|
||||||
else
|
else
|
||||||
# Need to load history from $HISTFILE
|
# Need to load history from $HISTFILE
|
||||||
# (Couldn't get the 'history' builtin to work during tests.)
|
# (Couldn't get the 'history' builtin to work during tests.)
|
||||||
test_history="$(cat $HISTFILE)"
|
test_history="$(cat $HISTFILE)"
|
||||||
fi
|
|
||||||
assertIncludes "$test_history" "git commit -m \"$dbl_escaped_msg\""
|
assertIncludes "$test_history" "git commit -m \"$dbl_escaped_msg\""
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test_git_commit_prompt_with_append() {
|
test_git_commit_prompt_with_append() {
|
||||||
@@ -324,9 +353,9 @@ test_git_commit_prompt_with_append() {
|
|||||||
commit_msg="Updating README, no build please"
|
commit_msg="Updating README, no build please"
|
||||||
|
|
||||||
# Create temporary history file
|
# Create temporary history file
|
||||||
HISTFILE=$(mktemp -t scm_breeze.XXXXXXXXXX)
|
export HISTFILE=$(mktemp -t scm_breeze.XXXXXXXXXX)
|
||||||
HISTFILESIZE=1000
|
export HISTFILESIZE=1000
|
||||||
HISTSIZE=1000
|
export HISTSIZE=1000
|
||||||
|
|
||||||
touch a b c
|
touch a b c
|
||||||
git add . >/dev/null
|
git add . >/dev/null
|
||||||
@@ -344,11 +373,14 @@ test_git_commit_prompt_with_append() {
|
|||||||
# Test that history was appended correctly.
|
# Test that history was appended correctly.
|
||||||
if [[ $shell == "zsh" ]]; then
|
if [[ $shell == "zsh" ]]; then
|
||||||
test_history="$(history)"
|
test_history="$(history)"
|
||||||
|
# TODO(ghthor): zsh isn't working here
|
||||||
|
# assertIncludes "$test_history" "$commit_msg \[ci skip\]"
|
||||||
|
# assertIncludes "$test_history" "git commit -m \"$commit_msg \[ci skip\]\""
|
||||||
else
|
else
|
||||||
test_history="$(cat $HISTFILE)"
|
test_history="$(cat $HISTFILE)"
|
||||||
fi
|
|
||||||
assertIncludes "$test_history" "$commit_msg \[ci skip\]"
|
assertIncludes "$test_history" "$commit_msg \[ci skip\]"
|
||||||
assertIncludes "$test_history" "git commit -m \"$commit_msg \[ci skip\]\""
|
assertIncludes "$test_history" "git commit -m \"$commit_msg \[ci skip\]\""
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test_adding_files_with_spaces() {
|
test_adding_files_with_spaces() {
|
||||||
@@ -365,7 +397,5 @@ test_adding_files_with_spaces() {
|
|||||||
assertIncludes "$git_status" "new file: \[1\] \"$test_file"
|
assertIncludes "$git_status" "new file: \[1\] \"$test_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# load and run shUnit2
|
# load and run shUnit2
|
||||||
source "$scmbDir/test/support/shunit2"
|
source "$scmbDir/test/support/shunit2"
|
||||||
|
|||||||
Reference in New Issue
Block a user