diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..a4ed9b88 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,7 @@ +os: Windows Server 2012 R2 +build: off +clone_folder: c:\sbt-extras +install: + - set PATH=C:\cygwin64\bin;%PATH% +test_script: + - bash.exe -l -c "cd /cygdrive/c/sbt-extras/ && ./bin/run-tests --tap ./test" \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..73536140 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +* text eol=lf diff --git a/.gitignore b/.gitignore index 21f271e3..fc04300e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /bats +.idea/ \ No newline at end of file diff --git a/bin/relinkSymlinks.sh b/bin/relinkSymlinks.sh new file mode 100644 index 00000000..a7328609 --- /dev/null +++ b/bin/relinkSymlinks.sh @@ -0,0 +1,20 @@ +# Sometime there are symbolic links stored in git repository +# In order to use them in windows like systems we need to link them using cygwin goodies. +# This procedure will do that. + + +repoDir=$1 +[[ "$repoDir" == "" ]] && repoDir="." + +pushd $repoDir > /dev/null + +for symlink in $(git ls-files -s | egrep "^120000" | cut -f2); do + git checkout $symlink #thanks to that it's idempotent + src=$(cat $symlink) + dst=$symlink + rm $dst + ln -s $src $dst + echo "$src <<===>> $dst" +done + +popd > /dev/null diff --git a/bin/run-tests b/bin/run-tests index 1bd2b789..2bf146df 100755 --- a/bin/run-tests +++ b/bin/run-tests @@ -1,8 +1,10 @@ #!/usr/bin/env bash # - cd "$(dirname "$0")/.." +is_cygwin () [[ "$(uname -a)" == "CYGWIN"* ]] +is_cygwin && bin/relinkSymlinks.sh + # The version of bats in brew only works if it's installed --HEAD # so trying to use it is more trouble than it's worth. # bats="$(which bats 2>/dev/null)" @@ -11,4 +13,5 @@ bats="" [[ $# -gt 0 ]] || set -- ./test [[ -x "$bats" ]] || bats="./bats/bin/bats" [[ -x "$bats" ]] || git clone --depth=1 https://github.com/sstephenson/bats.git bats +is_cygwin && bin/relinkSymlinks.sh bats [[ -x "$bats" ]] && "$bats" "$@" diff --git a/test/test_helper.bash b/test/test_helper.bash index 11059712..a01991a7 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -123,7 +123,24 @@ assert_failure() { } stdin_or_args () { if [[ $# -eq 0 ]]; then cat - ; else echo "$@"; fi; } + +is_cygwin () [[ "$(uname -a)" == "CYGWIN"* ]] + normalize_paths () { + is_cygwin && normalize_paths_cygwin $@ || normalize_paths_linux $@ +} + +normalize_paths_cygwin () { + stdin_or_args "$@" | \ + sed "s:$(cygpath -w "$TEST_ROOT" | sed 's/\\/\\\\/g' | sed 's/:/\\:/g'):\$ROOT:g" | \ + sed "s:$(cygpath -w "$HOME" | sed 's/\\/\\\\/g' | sed 's/:/\\:/g'):\$ROOT:g" | \ + sed 's/\\/\//g' | \ + sed "s:$TEST_ROOT:\$ROOT:g" | \ + sed "s:$HOME:\$ROOT:g" + tr -d '\r' +} + +normalize_paths_linux () { stdin_or_args "$@" | \ sed "s:$TEST_ROOT:\$ROOT:g" | \ sed "s:$HOME:\$ROOT:g"