add script/test for running tests

Instruct it to fail on Ruby syntax warnings coming from only the code in
this project.
This commit is contained in:
Mislav Marohnić 2013-07-09 23:40:52 +02:00
Родитель 0f71386f68
Коммит 5fbd7c75bd
3 изменённых файлов: 31 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,5 @@
script: script/test
language: ruby
rvm:
- 1.8.7
- 1.9.2

Просмотреть файл

@ -17,6 +17,7 @@ Gem::Specification.new do |s|
s.files += Dir.glob("lib/**/*")
s.files += Dir.glob("bin/**/*")
s.files += Dir.glob("man/**/*")
s.files += Dir.glob("script/**/*")
s.files += Dir.glob("test/**/*")
s.executables = %w( hub )

28
script/test Executable file
Просмотреть файл

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -e
STATUS=0
warnings="${TMPDIR:-/tmp}/hub-warnings.$$"
run() {
# Save warnings on stderr to a separate file
RUBYOPT="$RUBYOPT -w" bundle exec "$@" \
2> >(tee >(grep 'warning:' >>"$warnings") | grep -v 'warning:') || STATUS=$?
}
check_warnings() {
# Display Ruby warnings from this project's source files. Abort if any were found.
num="$(grep -F "$PWD" "$warnings" | grep -v "${PWD}/bundle" | sort | uniq -c | sort -rn | tee /dev/stderr | wc -l)"
rm -f "$warnings"
if [ "$num" -gt 0 ]; then
echo "FAILED: this test suite doesn't tolerate Ruby syntax warnings!" >&2
exit 1
fi
}
run rake test
run cucumber features
check_warnings
exit $STATUS