Merge remote-tracking branch 'mroth/osx-testing' into osx-testing

This commit is contained in:
Willa Drengwitz
2018-08-31 07:48:09 -04:00
7 changed files with 75 additions and 11 deletions

View File

@@ -32,11 +32,15 @@ oneTimeSetUp() {
# Test functions
function ln() { ln $@; }
# Test aliases
# Before aliasing, get original locations so we can compare them in the test
unalias mv rm sed cat 2>/dev/null
export mv_path="$(which mv)"
export rm_path="$(which rm)"
export sed_path="$(which sed)"
export cat_pathj="$(which cat)"
export cat_path="$(which cat)"
# Test aliases
alias mv="nocorrect $mv_path"
alias rm="$rm_path --option"
alias sed="$sed_path"
@@ -67,7 +71,7 @@ test_shell_command_wrapping() {
assertAliasEquals "exec_scmb_expand_args nocorrect $mv_path" "mv"
assertAliasEquals "exec_scmb_expand_args $sed_path" "sed"
assertAliasEquals "exec_scmb_expand_args $cat_path" "cat"
assertAliasEquals "exec_scmb_expand_args builtin cd" "cd"
assertAliasEquals "exec_scmb_expand_args builtin cd" "cd"
assertIncludes "$(declare -f ln)" "ln ()"
assertIncludes "$(declare -f ln)" "exec_scmb_expand_args __original_ln"
}
@@ -76,7 +80,15 @@ test_ls_with_file_shortcuts() {
export git_env_char="e"
TEST_DIR=$(mktemp -d -t scm_breeze.XXXXXXXXXX)
# Darwin actually symlinks /var inside /private, but mktemp reports back the
# logical pathat time of file creation. So make sure we always get the
# full physical path to be absolutely certain when doing comparisons later,
# because thats how the Ruby status_shortcuts.rb script is going to obtain
# them.
cd $TEST_DIR
TEST_DIR=$(pwd -P)
touch 'test file' 'test_file'
mkdir -p "a [b]" 'a "b"' "a 'b'"
touch "a \"b\"/c"
@@ -87,7 +99,7 @@ test_ls_with_file_shortcuts() {
ls_with_file_shortcuts > $temp_file
ls_output=$(<$temp_file strip_colors)
# Compare as fixed strings (F), instead of regex (P)
# Compare as fixed strings (F), instead of normal grep behavior
assertIncludes "$ls_output" '[1] a "b"' F
assertIncludes "$ls_output" "[2] a 'b'" F
assertIncludes "$ls_output" '[3] a [b]' F

View File

@@ -29,6 +29,7 @@ oneTimeSetUp() {
export ga_auto_remove="yes"
testRepo=$(mktemp -d -t scm_breeze.XXXXXXXXXX)
testRepo=$(cd $testRepo && pwd -P)
}
oneTimeTearDown() {

View File

@@ -15,7 +15,7 @@ fi
# Strip color codes from a string
strip_colors() {
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
perl -pe 's/\e\[[\d;]*m//g'
}
# Print space separated tab completion options
@@ -34,7 +34,7 @@ verboseGitCommands() {
#-----------------------------------------------------------------------------
_includes() {
if [ -n "$3" ]; then regex="$3"; else regex=P; fi
if [ -n "$3" ]; then regex="$3"; else regex=''; fi
if echo "$1" | grep -q$regex "$2"; then echo 0; else echo 1; fi
}
@@ -46,4 +46,3 @@ assertIncludes() {
assertNotIncludes() {
assertFalse "'$1' should not have contained '$2'" $(_includes "$@")
}

32
test/support/travisci_deps.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Installs dependencies for travis-ci environments.
# Install dependencies, which looks to be just bash & zsh.
#
# Darwin has zsh preinstalled already, so only need to install on Ubuntu.
#
# Note: $TRAVIS_OS_NAME will only be set on text boxes with multi-os enabled,
# so use negation test so it will fail gracefully on normal Travis linux setup.
if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then
# okay, so we know we're probably on a linux box (or at least not an osx box)
# at this point. do we need to install zsh? let's say the default case is no:
needs_zsh=false
# check if zsh is listed in the TEST_SHELLS environment variable, set by
# our travis-ci build matrix.
if [[ $TEST_SHELLS =~ zsh ]]; then needs_zsh=true; fi
# if there is NO $TEST_SHELLS env variable persent (which should never happen,
# but maybe someone has been monkeying with the .travis.yml), run_tests.sh is
# going to fall back onto the default of testing everything, so we need zsh.
if [[ -z "$TEST_SHELLS" ]]; then needs_zsh=true; fi
# finally, we install zsh if needed!
if $needs_zsh ; then
sudo apt-get install zsh
else
echo "No deps required."
fi
fi