Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cygwin support #167

Merged
merged 5 commits into from
Oct 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
* text eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/bats
.idea/
20 changes: 20 additions & 0 deletions bin/relinkSymlinks.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion bin/run-tests
Original file line number Diff line number Diff line change
@@ -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)"
Expand All @@ -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" "$@"
9 changes: 8 additions & 1 deletion sbt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,14 @@ execRunner () {
}

jar_url () { make_url "$1"; }
jar_file () { echo "$sbt_launch_dir/$1/sbt-launch.jar"; }

is_cygwin () [[ "$(uname -a)" == "CYGWIN"* ]]

jar_file () {
is_cygwin \
&& echo "$(cygpath -w $sbt_launch_dir/"$1"/sbt-launch.jar)" \
|| echo "$sbt_launch_dir/$1/sbt-launch.jar"
}

download_url () {
local url="$1"
Expand Down
22 changes: 21 additions & 1 deletion test/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,23 @@ 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"
}

normalize_paths_linux () {
stdin_or_args "$@" | \
sed "s:$TEST_ROOT:\$ROOT:g" | \
sed "s:$HOME:\$ROOT:g"
Expand All @@ -135,7 +151,11 @@ mkdircd () { mkdir -p "$1" && cd "$1"; }
assert_no_properties () { assert [ ! -f "$test_build_properties" ]; }
assert() { "$@" || flunk "failed: $@"; }
flunk() { normalize_paths "$@" ; return 1; }
assert_equal() { [ "$1" == "$2" ] || printf "\nexpected:\n%s\n\nactual:\n%s\n\n" "$1" "$2" | flunk; }
assert_equal() {
local expected=$(normalize_paths "$1")
local actual=$(normalize_paths "$2")
[ "$expected" == "$actual" ] || printf "\nexpected:\n%s\n\nactual:\n%s\n\n" "$1" "$2" | flunk;
}
assert_output() { assert_equal "${1:-$(cat -)}" "$output"; }
flunk_message() { printf "expected: %s\nactual: %s\n" "$1" "$2"; return 1; }

Expand Down